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
|
|
||||||
|
@ -60,5 +60,4 @@ class RoccoBasicTests < Test::Unit::TestCase
|
|||||||
] )
|
] )
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -16,6 +16,7 @@ class RoccoBlockCommentTest < Test::Unit::TestCase
|
|||||||
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
|
def test_multiple_blocks
|
||||||
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(
|
||||||
@ -33,6 +34,7 @@ class RoccoBlockCommentTest < Test::Unit::TestCase
|
|||||||
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
|
end
|
||||||
|
|
||||||
def test_block_without_middle_character
|
def test_block_without_middle_character
|
||||||
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(
|
||||||
@ -50,6 +52,7 @@ class RoccoBlockCommentTest < Test::Unit::TestCase
|
|||||||
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
|
end
|
||||||
|
|
||||||
def test_language_without_single_line_comments_parse
|
def test_language_without_single_line_comments_parse
|
||||||
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
assert_equal(
|
assert_equal(
|
||||||
@ -60,6 +63,7 @@ class RoccoBlockCommentTest < Test::Unit::TestCase
|
|||||||
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
|
end
|
||||||
|
|
||||||
def test_language_without_single_line_comments_split
|
def test_language_without_single_line_comments_split
|
||||||
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
assert_equal(
|
assert_equal(
|
||||||
@ -73,6 +77,7 @@ class RoccoBlockCommentTest < Test::Unit::TestCase
|
|||||||
] )
|
] )
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_language_without_single_line_comments_highlight
|
def test_language_without_single_line_comments_highlight
|
||||||
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
|
||||||
|
|
||||||
@ -80,19 +85,17 @@ class RoccoBlockCommentTest < Test::Unit::TestCase
|
|||||||
assert_equal(
|
assert_equal(
|
||||||
"<p>This is a comment!</p>",
|
"<p>This is a comment!</p>",
|
||||||
highlighted[0][0]
|
highlighted[0][0]
|
||||||
);
|
)
|
||||||
assert_equal(
|
assert_equal(
|
||||||
"<p>Comment 2</p>\n",
|
"<p>Comment 2</p>\n",
|
||||||
highlighted[1][0]
|
highlighted[1][0]
|
||||||
);
|
)
|
||||||
assert(
|
assert(
|
||||||
!highlighted[0][1].include?("DIVIDER") &&
|
!highlighted[0][1].include?("DIVIDER") &&
|
||||||
!highlighted[1][1].include?("DIVIDER"),
|
!highlighted[1][1].include?("DIVIDER"),
|
||||||
"`DIVIDER` stripped successfully."
|
"`DIVIDER` stripped successfully."
|
||||||
)
|
)
|
||||||
|
assert( true )
|
||||||
assert( true
|
|
||||||
);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,6 +11,7 @@ class RoccoCommentNormalization < Test::Unit::TestCase
|
|||||||
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
|
def test_single_line_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(
|
||||||
|
@ -5,18 +5,22 @@ class RoccoAutomaticCommentChars < Test::Unit::TestCase
|
|||||||
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
|
def test_fallback_language
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "js" } ) { "" }
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "js" } ) { "" }
|
||||||
assert_equal "//", r.options[:comment_chars][:single]
|
assert_equal "//", r.options[:comment_chars][:single]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fallback_default
|
def test_fallback_default
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" }
|
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."
|
assert_equal "#", r.options[:comment_chars][:single], "`:comment_chars` should be `#` when falling back to defaults."
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fallback_user
|
def test_fallback_user
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :comment_chars => "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."
|
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
|
def test_fallback_user_with_unknown_language
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "not-a-language", :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."
|
||||||
|
@ -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
|
||||||
|
@ -8,6 +8,7 @@ class RoccoLanguageDetection < Test::Unit::TestCase
|
|||||||
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
|
end
|
||||||
|
|
||||||
def test_fallback_default
|
def test_fallback_default
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" }
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever' ) { "" }
|
||||||
if r.pygmentize?
|
if r.pygmentize?
|
||||||
@ -15,6 +16,7 @@ class RoccoLanguageDetection < Test::Unit::TestCase
|
|||||||
assert_equal "ruby", r.options[:language], "`@options[:language]` should be set to `ruby` 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
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fallback_user
|
def test_fallback_user
|
||||||
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "c" } ) { "" }
|
r = Rocco.new( 'filename.an_extension_with_no_meaning_whatsoever', '', { :language => "c" } ) { "" }
|
||||||
if r.pygmentize?
|
if r.pygmentize?
|
||||||
|
@ -12,6 +12,7 @@ class RoccoSkippableLines < Test::Unit::TestCase
|
|||||||
"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(
|
||||||
@ -24,6 +25,7 @@ class RoccoSkippableLines < Test::Unit::TestCase
|
|||||||
"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(
|
||||||
@ -35,6 +37,7 @@ class RoccoSkippableLines < Test::Unit::TestCase
|
|||||||
"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(
|
||||||
@ -46,6 +49,7 @@ class RoccoSkippableLines < Test::Unit::TestCase
|
|||||||
"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(
|
||||||
|
@ -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