diff --git a/test/suite.rb b/test/suite.rb index 373baa4..c943985 100644 --- a/test/suite.rb +++ b/test/suite.rb @@ -1,6 +1,4 @@ require 'test/unit' -tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"] -tests.each do |file| - require file -end +Dir["#{File.dirname(__FILE__)}/test_*.rb"]. +each { |file| require file } diff --git a/test/test_basics.rb b/test/test_basics.rb index ad315ab..8cd0fb3 100644 --- a/test/test_basics.rb +++ b/test/test_basics.rb @@ -1,64 +1,63 @@ require File.dirname(__FILE__) + '/helper' class RoccoBasicTests < Test::Unit::TestCase - def test_rocco_exists_and_is_instancable - roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" ) - end + def test_rocco_exists_and_is_instancable + roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" ) + end - def test_filename - r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" ) - assert_equal "filename.rb", r.file - end + def test_filename + r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" ) + assert_equal "filename.rb", r.file + end - def test_sources - r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" ) - assert_equal [ "filename.rb" ], r.sources - end + def test_sources + r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" ) + assert_equal [ "filename.rb" ], r.sources + end - def test_sections - r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" ) - assert_equal 1, r.sections.length - assert_equal 2, r.sections[ 0 ].length - assert_equal "
Comment 1
\n", r.sections[ 0 ][ 0 ] - assert_equal "def codeblock\nend", r.sections[ 0 ][ 1 ] - end + def test_sections + r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" ) + assert_equal 1, r.sections.length + assert_equal 2, r.sections[ 0 ].length + assert_equal "Comment 1
\n", r.sections[ 0 ][ 0 ] + assert_equal "def codeblock\nend", r.sections[ 0 ][ 1 ] + end - def test_parsing - r = Rocco.new( 'test' ) { "" } # Generate throwaway instance so I can test `parse` - assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock", "end" ] ] - ], - r.parse( "# Comment 1\ndef codeblock\nend\n" ) - ) - assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock" ] ], - [ [ "Comment 2" ], [ "end" ] ] - ], - r.parse( "# Comment 1\ndef codeblock\n# Comment 2\nend\n" ) - ) - end - - def test_splitting - r = Rocco.new( 'test' ) { "" } # Generate throwaway instance so I can test `split` - assert_equal( - [ - [ "Comment 1" ], - [ "def codeblock\nend" ] - ], - r.split([ [ [ "Comment 1" ], [ "def codeblock", "end" ] ] ]) - ) - assert_equal( - [ - [ "Comment 1", "Comment 2" ], - [ "def codeblock", "end" ] - ], - r.split( [ - [ [ "Comment 1" ], [ "def codeblock" ] ], - [ [ "Comment 2" ], [ "end" ] ] - ] ) - ) - end + def test_parsing + r = Rocco.new( 'test' ) { "" } # Generate throwaway instance so I can test `parse` + assert_equal( + [ + [ [ "Comment 1" ], [ "def codeblock", "end" ] ] + ], + r.parse( "# Comment 1\ndef codeblock\nend\n" ) + ) + assert_equal( + [ + [ [ "Comment 1" ], [ "def codeblock" ] ], + [ [ "Comment 2" ], [ "end" ] ] + ], + r.parse( "# Comment 1\ndef codeblock\n# Comment 2\nend\n" ) + ) + end + def test_splitting + r = Rocco.new( 'test' ) { "" } # Generate throwaway instance so I can test `split` + assert_equal( + [ + [ "Comment 1" ], + [ "def codeblock\nend" ] + ], + r.split([ [ [ "Comment 1" ], [ "def codeblock", "end" ] ] ]) + ) + assert_equal( + [ + [ "Comment 1", "Comment 2" ], + [ "def codeblock", "end" ] + ], + r.split( [ + [ [ "Comment 1" ], [ "def codeblock" ] ], + [ [ "Comment 2" ], [ "end" ] ] + ] ) + ) + end end diff --git a/test/test_block_comments.rb b/test/test_block_comments.rb index 408aff4..1aede51 100644 --- a/test/test_block_comments.rb +++ b/test/test_block_comments.rb @@ -1,98 +1,101 @@ require File.dirname(__FILE__) + '/helper' class RoccoBlockCommentTest < Test::Unit::TestCase - def test_basics - r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse` - assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock", "end" ] ] - ], - r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n" ) - ) - assert_equal( - [ - [ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ] - ], - r.parse( "/**\n * Comment 1a\n * Comment 1b\n */\ndef codeblock\nend\n" ) - ) - end - def test_multiple_blocks - r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse` - assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock", "end" ] ], - [ [ "Comment 2" ], [] ] - ], - r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\n" ) - ) - assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock", "end" ] ], - [ [ "Comment 2" ], [ "if false", "end" ] ] - ], - r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\nif false\nend" ) - ) - end - def test_block_without_middle_character - r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse` - assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock", "end" ] ], - [ [ "Comment 2" ], [] ] - ], - r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\n" ) - ) - assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock", "end" ] ], - [ [ "Comment 2" ], [ "if false", "end" ] ] - ], - r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\nif false\nend" ) - ) - end - def test_language_without_single_line_comments_parse - r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse` - assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock", "end" ] ], - [ [ "Comment 2" ], [ "if false", "end" ] ] - ], - r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\nif false\nend" ) - ) - end - def test_language_without_single_line_comments_split - r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse` - assert_equal( - [ - [ "Comment 1", "Comment 2" ], - [ "def codeblock\nend", "if false\nend" ] - ], - r.split( [ - [ [ "Comment 1" ], [ "def codeblock", "end" ] ], - [ [ "Comment 2" ], [ "if false", "end" ] ] - ] ) - ) - end - def test_language_without_single_line_comments_highlight - r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse` - - highlighted = r.highlight( r.split( r.parse( "/**\n * This is a comment!\n */\n.rule { goes: here; }\n/**\n * Comment 2\n */\n.rule2 { goes: here; }" ) ) ) - assert_equal( - "This is a comment!
", - highlighted[0][0] - ); - assert_equal( - "Comment 2
\n", - highlighted[1][0] - ); - assert( - !highlighted[0][1].include?("DIVIDER") && - !highlighted[1][1].include?("DIVIDER"), - "`DIVIDER` stripped successfully." - ) - - assert( true - ); - end + def test_basics + r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse` + assert_equal( + [ + [ [ "Comment 1" ], [ "def codeblock", "end" ] ] + ], + r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n" ) + ) + assert_equal( + [ + [ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ] + ], + r.parse( "/**\n * Comment 1a\n * Comment 1b\n */\ndef codeblock\nend\n" ) + ) + end + + def test_multiple_blocks + r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse` + assert_equal( + [ + [ [ "Comment 1" ], [ "def codeblock", "end" ] ], + [ [ "Comment 2" ], [] ] + ], + r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\n" ) + ) + assert_equal( + [ + [ [ "Comment 1" ], [ "def codeblock", "end" ] ], + [ [ "Comment 2" ], [ "if false", "end" ] ] + ], + r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\nif false\nend" ) + ) + end + + def test_block_without_middle_character + r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse` + assert_equal( + [ + [ [ "Comment 1" ], [ "def codeblock", "end" ] ], + [ [ "Comment 2" ], [] ] + ], + r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\n" ) + ) + assert_equal( + [ + [ [ "Comment 1" ], [ "def codeblock", "end" ] ], + [ [ "Comment 2" ], [ "if false", "end" ] ] + ], + r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\nif false\nend" ) + ) + end + + def test_language_without_single_line_comments_parse + r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse` + assert_equal( + [ + [ [ "Comment 1" ], [ "def codeblock", "end" ] ], + [ [ "Comment 2" ], [ "if false", "end" ] ] + ], + r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\nif false\nend" ) + ) + end + + def test_language_without_single_line_comments_split + r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse` + assert_equal( + [ + [ "Comment 1", "Comment 2" ], + [ "def codeblock\nend", "if false\nend" ] + ], + r.split( [ + [ [ "Comment 1" ], [ "def codeblock", "end" ] ], + [ [ "Comment 2" ], [ "if false", "end" ] ] + ] ) + ) + end + + def test_language_without_single_line_comments_highlight + r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse` + + highlighted = r.highlight( r.split( r.parse( "/**\n * This is a comment!\n */\n.rule { goes: here; }\n/**\n * Comment 2\n */\n.rule2 { goes: here; }" ) ) ) + assert_equal( + "This is a comment!
", + highlighted[0][0] + ) + assert_equal( + "Comment 2
\n", + highlighted[1][0] + ) + assert( + !highlighted[0][1].include?("DIVIDER") && + !highlighted[1][1].include?("DIVIDER"), + "`DIVIDER` stripped successfully." + ) + assert( true ) + end end diff --git a/test/test_comment_normalization.rb b/test/test_comment_normalization.rb index 9c6919d..d7b3f59 100644 --- a/test/test_comment_normalization.rb +++ b/test/test_comment_normalization.rb @@ -1,24 +1,25 @@ require File.dirname(__FILE__) + '/helper' class RoccoCommentNormalization < Test::Unit::TestCase - def test_normal_comments - r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse` - assert_equal( - [ - [ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ], - [ [ "Comment 2a", " Comment 2b" ], [] ] - ], - r.parse( "\"\"\"\n Comment 1a\n Comment 1b\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2a\n Comment 2b\n\"\"\"\n" ) - ) - end - def test_single_line_comments - r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse` - assert_equal( - [ - [ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ], - [ [ "Comment 2a", " Comment 2b" ], [] ] - ], - r.parse( "# Comment 1a\n# Comment 1b\ndef codeblock\nend\n# Comment 2a\n# Comment 2b\n" ) - ) - end + def test_normal_comments + r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse` + assert_equal( + [ + [ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ], + [ [ "Comment 2a", " Comment 2b" ], [] ] + ], + r.parse( "\"\"\"\n Comment 1a\n Comment 1b\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2a\n Comment 2b\n\"\"\"\n" ) + ) + end + + def test_single_line_comments + r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse` + assert_equal( + [ + [ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ], + [ [ "Comment 2a", " Comment 2b" ], [] ] + ], + r.parse( "# Comment 1a\n# Comment 1b\ndef codeblock\nend\n# Comment 2a\n# Comment 2b\n" ) + ) + end end diff --git a/test/test_commentchar_detection.rb b/test/test_commentchar_detection.rb index efb4ee2..46e65e6 100644 --- a/test/test_commentchar_detection.rb +++ b/test/test_commentchar_detection.rb @@ -1,24 +1,28 @@ require File.dirname(__FILE__) + '/helper' class RoccoAutomaticCommentChars < Test::Unit::TestCase - def test_basic_detection - r = Rocco.new( 'filename.js' ) { "" } - assert_equal "//", r.options[:comment_chars][:single] - end - def test_fallback_language - r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "js" } ) { "" } - assert_equal "//", r.options[:comment_chars][:single] - end - def test_fallback_default - r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" } - assert_equal "#", r.options[:comment_chars][:single], "`:comment_chars` should be `#` when falling back to defaults." - end - def test_fallback_user - r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :comment_chars => "user" } ) { "" } - assert_equal "user", r.options[:comment_chars][:single], "`:comment_chars` should be the user's default when falling back to user-provided settings." - end - def test_fallback_user_with_unknown_language - r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "not-a-language", :comment_chars => "user" } ) { "" } - assert_equal "user", r.options[:comment_chars][:single], "`:comment_chars` should be the user's default when falling back to user-provided settings." - end + def test_basic_detection + r = Rocco.new( 'filename.js' ) { "" } + assert_equal "//", r.options[:comment_chars][:single] + end + + def test_fallback_language + r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "js" } ) { "" } + assert_equal "//", r.options[:comment_chars][:single] + end + + def test_fallback_default + r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" } + assert_equal "#", r.options[:comment_chars][:single], "`:comment_chars` should be `#` when falling back to defaults." + end + + def test_fallback_user + r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :comment_chars => "user" } ) { "" } + assert_equal "user", r.options[:comment_chars][:single], "`:comment_chars` should be the user's default when falling back to user-provided settings." + end + + def test_fallback_user_with_unknown_language + r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "not-a-language", :comment_chars => "user" } ) { "" } + assert_equal "user", r.options[:comment_chars][:single], "`:comment_chars` should be the user's default when falling back to user-provided settings." + end end diff --git a/test/test_descriptive_section_names.rb b/test/test_descriptive_section_names.rb index 21c42ce..5c36e5e 100644 --- a/test/test_descriptive_section_names.rb +++ b/test/test_descriptive_section_names.rb @@ -13,6 +13,7 @@ class RoccoDescriptiveSectionNamesTests < Test::Unit::TestCase "The rendered HTML should link to a named section" ) end + def test_section_numbering r = roccoize( "filename.rb", "# # Header 1\ndef codeblock\nend\n# Comment 1\ndef codeblock1\nend\n# # Header 2\ndef codeblock2\nend" ) html = r.to_html diff --git a/test/test_language_detection.rb b/test/test_language_detection.rb index ddd7e71..92c69c4 100644 --- a/test/test_language_detection.rb +++ b/test/test_language_detection.rb @@ -1,25 +1,27 @@ require File.dirname(__FILE__) + '/helper' class RoccoLanguageDetection < Test::Unit::TestCase - def test_basic_detection - r = Rocco.new( 'filename.py' ) { "" } - if r.pygmentize? - assert_equal "python", r.detect_language(), "`detect_language()` should return the correct language" - assert_equal "python", r.options[:language], "`@options[:language]` should be set to the correct language" - end + def test_basic_detection + r = Rocco.new( 'filename.py' ) { "" } + if r.pygmentize? + assert_equal "python", r.detect_language(), "`detect_language()` should return the correct language" + assert_equal "python", r.options[:language], "`@options[:language]` should be set to the correct language" end - def test_fallback_default - r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" } - if r.pygmentize? - assert_equal "text", r.detect_language(), "`detect_language()` should return `text` when nothing else is detected" - assert_equal "ruby", r.options[:language], "`@options[:language]` should be set to `ruby` when nothing else is detected" - end + end + + def test_fallback_default + r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" } + if r.pygmentize? + assert_equal "text", r.detect_language(), "`detect_language()` should return `text` when nothing else is detected" + assert_equal "ruby", r.options[:language], "`@options[:language]` should be set to `ruby` when nothing else is detected" end - def test_fallback_user - r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "c" } ) { "" } - if r.pygmentize? - assert_equal "text", r.detect_language(), "`detect_language()` should return `text` nothing else is detected" - assert_equal "c", r.options[:language], "`@options[:language]` should be set to the user's setting when nothing else is detected" - end + end + + def test_fallback_user + r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "c" } ) { "" } + if r.pygmentize? + assert_equal "text", r.detect_language(), "`detect_language()` should return `text` nothing else is detected" + assert_equal "c", r.options[:language], "`@options[:language]` should be set to the user's setting when nothing else is detected" end + end end diff --git a/test/test_skippable_lines.rb b/test/test_skippable_lines.rb index 2672afe..efc9a41 100644 --- a/test/test_skippable_lines.rb +++ b/test/test_skippable_lines.rb @@ -4,57 +4,61 @@ class RoccoSkippableLines < Test::Unit::TestCase def test_shebang_first_line r = Rocco.new( 'filename.sh' ) { "" } assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock" ] ], - [ [ "Comment 2" ], [ "end" ] ] - ], - r.parse( "#!/usr/bin/env bash\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ), - "Shebang should be stripped when it appears as the first line." + [ + [ [ "Comment 1" ], [ "def codeblock" ] ], + [ [ "Comment 2" ], [ "end" ] ] + ], + r.parse( "#!/usr/bin/env bash\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ), + "Shebang should be stripped when it appears as the first line." ) end + def test_shebang_in_content r = Rocco.new( 'filename.sh' ) { "" } assert_equal( - [ - # @TODO: `#!/` shouldn't be recognized as a comment. - [ [ "Comment 1", "!/usr/bin/env bash" ], [ "def codeblock" ] ], - [ [ "Comment 2" ], [ "end" ] ] - ], - r.parse( "# Comment 1\n#!/usr/bin/env bash\ndef codeblock\n# Comment 2\nend\n" ), - "Shebang shouldn't be stripped anywhere other than as the first line." + [ + # @TODO: `#!/` shouldn't be recognized as a comment. + [ [ "Comment 1", "!/usr/bin/env bash" ], [ "def codeblock" ] ], + [ [ "Comment 2" ], [ "end" ] ] + ], + r.parse( "# Comment 1\n#!/usr/bin/env bash\ndef codeblock\n# Comment 2\nend\n" ), + "Shebang shouldn't be stripped anywhere other than as the first line." ) end + def test_encoding_in_ruby r = Rocco.new( 'filename.rb' ) { "" } assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock" ] ], - [ [ "Comment 2" ], [ "end" ] ] - ], - r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ), - "Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document." + [ + [ [ "Comment 1" ], [ "def codeblock" ] ], + [ [ "Comment 2" ], [ "end" ] ] + ], + r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ), + "Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document." ) end + def test_encoding_in_python r = Rocco.new( 'filename.py' ) { "" } assert_equal( - [ - [ [ "Comment 1" ], [ "def codeblock" ] ], - [ [ "Comment 2" ], [ "end" ] ] - ], - r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ), - "Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document." + [ + [ [ "Comment 1" ], [ "def codeblock" ] ], + [ [ "Comment 2" ], [ "end" ] ] + ], + r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ), + "Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document." ) end + def test_encoding_in_notpython r = Rocco.new( 'filename.sh' ) { "" } assert_equal( - [ - [ [ "encoding: utf-8", "Comment 1" ], [ "def codeblock" ] ], - [ [ "Comment 2" ], [ "end" ] ] - ], - r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ), - "Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document." + [ + [ [ "encoding: utf-8", "Comment 1" ], [ "def codeblock" ] ], + [ [ "Comment 2" ], [ "end" ] ] + ], + r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ), + "Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document." ) end end diff --git a/test/test_source_list.rb b/test/test_source_list.rb index 9da31bc..c21fe47 100644 --- a/test/test_source_list.rb +++ b/test/test_source_list.rb @@ -13,6 +13,7 @@ class RoccoSourceListTests < Test::Unit::TestCase "URLs correctly generated for files in a flat directory structure" ) end + def test_heiarachical_sourcelist r = Rocco.new( 'a/issue26.sh', [ 'a/issue26a.sh', 'b/issue26b.sh', 'c/issue26c.sh' ] ) { "# Comment 1\n# Comment 1\nprint 'omg!'" @@ -25,5 +26,4 @@ class RoccoSourceListTests < Test::Unit::TestCase "URLs correctly generated for files in a flat directory structure" ) end - end