two char indent and whitespace error fixes
This commit is contained in:
parent
a2d316b20d
commit
f40e57baae
@ -1,6 +1,4 @@
|
|||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"]
|
Dir["#{File.dirname(__FILE__)}/test_*.rb"].
|
||||||
tests.each do |file|
|
each { |file| require file }
|
||||||
require file
|
|
||||||
end
|
|
||||||
|
@ -1,64 +1,63 @@
|
|||||||
require File.dirname(__FILE__) + '/helper'
|
require File.dirname(__FILE__) + '/helper'
|
||||||
|
|
||||||
class RoccoBasicTests < Test::Unit::TestCase
|
class RoccoBasicTests < Test::Unit::TestCase
|
||||||
def test_rocco_exists_and_is_instancable
|
def test_rocco_exists_and_is_instancable
|
||||||
roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" )
|
roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" )
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_filename
|
def test_filename
|
||||||
r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" )
|
r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" )
|
||||||
assert_equal "filename.rb", r.file
|
assert_equal "filename.rb", r.file
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sources
|
def test_sources
|
||||||
r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" )
|
r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" )
|
||||||
assert_equal [ "filename.rb" ], r.sources
|
assert_equal [ "filename.rb" ], r.sources
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sections
|
def test_sections
|
||||||
r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" )
|
r = roccoize( "filename.rb", "# Comment 1\ndef codeblock\nend\n" )
|
||||||
assert_equal 1, r.sections.length
|
assert_equal 1, r.sections.length
|
||||||
assert_equal 2, r.sections[ 0 ].length
|
assert_equal 2, r.sections[ 0 ].length
|
||||||
assert_equal "<p>Comment 1</p>\n", r.sections[ 0 ][ 0 ]
|
assert_equal "<p>Comment 1</p>\n", r.sections[ 0 ][ 0 ]
|
||||||
assert_equal "<span class=\"k\">def</span> <span class=\"nf\">codeblock</span>\n<span class=\"k\">end</span>", r.sections[ 0 ][ 1 ]
|
assert_equal "<span class=\"k\">def</span> <span class=\"nf\">codeblock</span>\n<span class=\"k\">end</span>", r.sections[ 0 ][ 1 ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parsing
|
def test_parsing
|
||||||
r = Rocco.new( 'test' ) { "" } # Generate throwaway instance so I can test `parse`
|
r = Rocco.new( 'test' ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "Comment 1" ], [ "def codeblock", "end" ] ]
|
[ [ "Comment 1" ], [ "def codeblock", "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "# Comment 1\ndef codeblock\nend\n" )
|
r.parse( "# Comment 1\ndef codeblock\nend\n" )
|
||||||
)
|
)
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "Comment 1" ], [ "def codeblock" ] ],
|
[ [ "Comment 1" ], [ "def codeblock" ] ],
|
||||||
[ [ "Comment 2" ], [ "end" ] ]
|
[ [ "Comment 2" ], [ "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "# Comment 1\ndef codeblock\n# Comment 2\nend\n" )
|
r.parse( "# Comment 1\ndef codeblock\n# Comment 2\nend\n" )
|
||||||
)
|
)
|
||||||
end
|
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_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
|
end
|
||||||
|
@ -1,98 +1,101 @@
|
|||||||
require File.dirname(__FILE__) + '/helper'
|
require File.dirname(__FILE__) + '/helper'
|
||||||
|
|
||||||
class RoccoBlockCommentTest < Test::Unit::TestCase
|
class RoccoBlockCommentTest < Test::Unit::TestCase
|
||||||
def test_basics
|
def test_basics
|
||||||
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
|
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "Comment 1" ], [ "def codeblock", "end" ] ]
|
[ [ "Comment 1" ], [ "def codeblock", "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n" )
|
r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n" )
|
||||||
)
|
)
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ]
|
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "/**\n * Comment 1a\n * Comment 1b\n */\ndef codeblock\nend\n" )
|
r.parse( "/**\n * Comment 1a\n * Comment 1b\n */\ndef codeblock\nend\n" )
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
def test_multiple_blocks
|
|
||||||
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
|
def test_multiple_blocks
|
||||||
assert_equal(
|
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
[
|
assert_equal(
|
||||||
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
[
|
||||||
[ [ "Comment 2" ], [] ]
|
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
||||||
],
|
[ [ "Comment 2" ], [] ]
|
||||||
r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\n" )
|
],
|
||||||
)
|
r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\n" )
|
||||||
assert_equal(
|
)
|
||||||
[
|
assert_equal(
|
||||||
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
[
|
||||||
[ [ "Comment 2" ], [ "if false", "end" ] ]
|
[ [ "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" )
|
],
|
||||||
)
|
r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\nif false\nend" )
|
||||||
end
|
)
|
||||||
def test_block_without_middle_character
|
end
|
||||||
r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse`
|
|
||||||
assert_equal(
|
def test_block_without_middle_character
|
||||||
[
|
r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
assert_equal(
|
||||||
[ [ "Comment 2" ], [] ]
|
[
|
||||||
],
|
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
||||||
r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\n" )
|
[ [ "Comment 2" ], [] ]
|
||||||
)
|
],
|
||||||
assert_equal(
|
r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\n" )
|
||||||
[
|
)
|
||||||
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
assert_equal(
|
||||||
[ [ "Comment 2" ], [ "if false", "end" ] ]
|
[
|
||||||
],
|
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
||||||
r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\nif false\nend" )
|
[ [ "Comment 2" ], [ "if false", "end" ] ]
|
||||||
)
|
],
|
||||||
end
|
r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\nif false\nend" )
|
||||||
def test_language_without_single_line_comments_parse
|
)
|
||||||
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
end
|
||||||
assert_equal(
|
|
||||||
[
|
def test_language_without_single_line_comments_parse
|
||||||
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
[ [ "Comment 2" ], [ "if false", "end" ] ]
|
assert_equal(
|
||||||
],
|
[
|
||||||
r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\nif false\nend" )
|
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
||||||
)
|
[ [ "Comment 2" ], [ "if false", "end" ] ]
|
||||||
end
|
],
|
||||||
def test_language_without_single_line_comments_split
|
r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\nif false\nend" )
|
||||||
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
)
|
||||||
assert_equal(
|
end
|
||||||
[
|
|
||||||
[ "Comment 1", "Comment 2" ],
|
def test_language_without_single_line_comments_split
|
||||||
[ "def codeblock\nend", "if false\nend" ]
|
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
],
|
assert_equal(
|
||||||
r.split( [
|
[
|
||||||
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
[ "Comment 1", "Comment 2" ],
|
||||||
[ [ "Comment 2" ], [ "if false", "end" ] ]
|
[ "def codeblock\nend", "if false\nend" ]
|
||||||
] )
|
],
|
||||||
)
|
r.split( [
|
||||||
end
|
[ [ "Comment 1" ], [ "def codeblock", "end" ] ],
|
||||||
def test_language_without_single_line_comments_highlight
|
[ [ "Comment 2" ], [ "if false", "end" ] ]
|
||||||
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; }" ) ) )
|
end
|
||||||
assert_equal(
|
|
||||||
"<p>This is a comment!</p>",
|
def test_language_without_single_line_comments_highlight
|
||||||
highlighted[0][0]
|
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
);
|
|
||||||
assert_equal(
|
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; }" ) ) )
|
||||||
"<p>Comment 2</p>\n",
|
assert_equal(
|
||||||
highlighted[1][0]
|
"<p>This is a comment!</p>",
|
||||||
);
|
highlighted[0][0]
|
||||||
assert(
|
)
|
||||||
!highlighted[0][1].include?("DIVIDER") &&
|
assert_equal(
|
||||||
!highlighted[1][1].include?("DIVIDER"),
|
"<p>Comment 2</p>\n",
|
||||||
"`DIVIDER` stripped successfully."
|
highlighted[1][0]
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
assert( true
|
!highlighted[0][1].include?("DIVIDER") &&
|
||||||
);
|
!highlighted[1][1].include?("DIVIDER"),
|
||||||
end
|
"`DIVIDER` stripped successfully."
|
||||||
|
)
|
||||||
|
assert( true )
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
require File.dirname(__FILE__) + '/helper'
|
require File.dirname(__FILE__) + '/helper'
|
||||||
|
|
||||||
class RoccoCommentNormalization < Test::Unit::TestCase
|
class RoccoCommentNormalization < Test::Unit::TestCase
|
||||||
def test_normal_comments
|
def test_normal_comments
|
||||||
r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse`
|
r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ],
|
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ],
|
||||||
[ [ "Comment 2a", " Comment 2b" ], [] ]
|
[ [ "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" )
|
r.parse( "\"\"\"\n Comment 1a\n Comment 1b\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2a\n Comment 2b\n\"\"\"\n" )
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
def test_single_line_comments
|
|
||||||
r = Rocco.new( 'test', '', { :language => "python" } ) { "" } # Generate throwaway instance so I can test `parse`
|
def test_single_line_comments
|
||||||
assert_equal(
|
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" ], [] ]
|
[ [ "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" )
|
],
|
||||||
)
|
r.parse( "# Comment 1a\n# Comment 1b\ndef codeblock\nend\n# Comment 2a\n# Comment 2b\n" )
|
||||||
end
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
require File.dirname(__FILE__) + '/helper'
|
require File.dirname(__FILE__) + '/helper'
|
||||||
|
|
||||||
class RoccoAutomaticCommentChars < Test::Unit::TestCase
|
class RoccoAutomaticCommentChars < Test::Unit::TestCase
|
||||||
def test_basic_detection
|
def test_basic_detection
|
||||||
r = Rocco.new( 'filename.js' ) { "" }
|
r = Rocco.new( 'filename.js' ) { "" }
|
||||||
assert_equal "//", r.options[:comment_chars][:single]
|
assert_equal "//", r.options[:comment_chars][:single]
|
||||||
end
|
end
|
||||||
def test_fallback_language
|
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "js" } ) { "" }
|
def test_fallback_language
|
||||||
assert_equal "//", r.options[:comment_chars][:single]
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "js" } ) { "" }
|
||||||
end
|
assert_equal "//", r.options[:comment_chars][:single]
|
||||||
def test_fallback_default
|
end
|
||||||
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."
|
def test_fallback_default
|
||||||
end
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" }
|
||||||
def test_fallback_user
|
assert_equal "#", r.options[:comment_chars][:single], "`:comment_chars` should be `#` when falling back to defaults."
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :comment_chars => "user" } ) { "" }
|
end
|
||||||
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
|
||||||
def test_fallback_user_with_unknown_language
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :comment_chars => "user" } ) { "" }
|
||||||
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."
|
||||||
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
|
|
||||||
|
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
|
end
|
||||||
|
@ -13,6 +13,7 @@ class RoccoDescriptiveSectionNamesTests < Test::Unit::TestCase
|
|||||||
"The rendered HTML should link to a named section"
|
"The rendered HTML should link to a named section"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_section_numbering
|
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" )
|
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
|
html = r.to_html
|
||||||
|
@ -1,25 +1,27 @@
|
|||||||
require File.dirname(__FILE__) + '/helper'
|
require File.dirname(__FILE__) + '/helper'
|
||||||
|
|
||||||
class RoccoLanguageDetection < Test::Unit::TestCase
|
class RoccoLanguageDetection < Test::Unit::TestCase
|
||||||
def test_basic_detection
|
def test_basic_detection
|
||||||
r = Rocco.new( 'filename.py' ) { "" }
|
r = Rocco.new( 'filename.py' ) { "" }
|
||||||
if r.pygmentize?
|
if r.pygmentize?
|
||||||
assert_equal "python", r.detect_language(), "`detect_language()` should return the correct language"
|
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"
|
assert_equal "python", r.options[:language], "`@options[:language]` should be set to the correct language"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
def test_fallback_default
|
end
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" }
|
|
||||||
if r.pygmentize?
|
def test_fallback_default
|
||||||
assert_equal "text", r.detect_language(), "`detect_language()` should return `text` when nothing else is detected"
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" }
|
||||||
assert_equal "ruby", r.options[:language], "`@options[:language]` should be set to `ruby` when nothing else is detected"
|
if r.pygmentize?
|
||||||
end
|
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_user
|
end
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "c" } ) { "" }
|
|
||||||
if r.pygmentize?
|
def test_fallback_user
|
||||||
assert_equal "text", r.detect_language(), "`detect_language()` should return `text` nothing else is detected"
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "c" } ) { "" }
|
||||||
assert_equal "c", r.options[:language], "`@options[:language]` should be set to the user's setting when nothing else is detected"
|
if r.pygmentize?
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
@ -4,57 +4,61 @@ class RoccoSkippableLines < Test::Unit::TestCase
|
|||||||
def test_shebang_first_line
|
def test_shebang_first_line
|
||||||
r = Rocco.new( 'filename.sh' ) { "" }
|
r = Rocco.new( 'filename.sh' ) { "" }
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "Comment 1" ], [ "def codeblock" ] ],
|
[ [ "Comment 1" ], [ "def codeblock" ] ],
|
||||||
[ [ "Comment 2" ], [ "end" ] ]
|
[ [ "Comment 2" ], [ "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "#!/usr/bin/env bash\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ),
|
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."
|
"Shebang should be stripped when it appears as the first line."
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_in_content
|
def test_shebang_in_content
|
||||||
r = Rocco.new( 'filename.sh' ) { "" }
|
r = Rocco.new( 'filename.sh' ) { "" }
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
# @TODO: `#!/` shouldn't be recognized as a comment.
|
# @TODO: `#!/` shouldn't be recognized as a comment.
|
||||||
[ [ "Comment 1", "!/usr/bin/env bash" ], [ "def codeblock" ] ],
|
[ [ "Comment 1", "!/usr/bin/env bash" ], [ "def codeblock" ] ],
|
||||||
[ [ "Comment 2" ], [ "end" ] ]
|
[ [ "Comment 2" ], [ "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "# Comment 1\n#!/usr/bin/env bash\ndef codeblock\n# Comment 2\nend\n" ),
|
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."
|
"Shebang shouldn't be stripped anywhere other than as the first line."
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_encoding_in_ruby
|
def test_encoding_in_ruby
|
||||||
r = Rocco.new( 'filename.rb' ) { "" }
|
r = Rocco.new( 'filename.rb' ) { "" }
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "Comment 1" ], [ "def codeblock" ] ],
|
[ [ "Comment 1" ], [ "def codeblock" ] ],
|
||||||
[ [ "Comment 2" ], [ "end" ] ]
|
[ [ "Comment 2" ], [ "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ),
|
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."
|
"Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document."
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_encoding_in_python
|
def test_encoding_in_python
|
||||||
r = Rocco.new( 'filename.py' ) { "" }
|
r = Rocco.new( 'filename.py' ) { "" }
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "Comment 1" ], [ "def codeblock" ] ],
|
[ [ "Comment 1" ], [ "def codeblock" ] ],
|
||||||
[ [ "Comment 2" ], [ "end" ] ]
|
[ [ "Comment 2" ], [ "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ),
|
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."
|
"Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document."
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_encoding_in_notpython
|
def test_encoding_in_notpython
|
||||||
r = Rocco.new( 'filename.sh' ) { "" }
|
r = Rocco.new( 'filename.sh' ) { "" }
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
[ [ "encoding: utf-8", "Comment 1" ], [ "def codeblock" ] ],
|
[ [ "encoding: utf-8", "Comment 1" ], [ "def codeblock" ] ],
|
||||||
[ [ "Comment 2" ], [ "end" ] ]
|
[ [ "Comment 2" ], [ "end" ] ]
|
||||||
],
|
],
|
||||||
r.parse( "#!/usr/bin/env bash\n# encoding: utf-8\n# Comment 1\ndef codeblock\n# Comment 2\nend\n" ),
|
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."
|
"Strings matching the PEP 263 encoding definition regex should be stripped when they appear at the top of a python document."
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,6 +13,7 @@ class RoccoSourceListTests < Test::Unit::TestCase
|
|||||||
"URLs correctly generated for files in a flat directory structure"
|
"URLs correctly generated for files in a flat directory structure"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_heiarachical_sourcelist
|
def test_heiarachical_sourcelist
|
||||||
r = Rocco.new( 'a/issue26.sh', [ 'a/issue26a.sh', 'b/issue26b.sh', 'c/issue26c.sh' ] ) {
|
r = Rocco.new( 'a/issue26.sh', [ 'a/issue26a.sh', 'b/issue26b.sh', 'c/issue26c.sh' ] ) {
|
||||||
"# Comment 1\n# Comment 1\nprint 'omg!'"
|
"# 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"
|
"URLs correctly generated for files in a flat directory structure"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user