rocco/test/test_block_comment_styles.rb
2011-03-30 23:22:37 -04:00

65 lines
2.1 KiB
Ruby

require File.expand_path('../helper', __FILE__)
class RoccoBlockCommentTest < Test::Unit::TestCase
def test_one_liner
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
assert_equal(
[
[ [ "Comment 1" ], [ "def codeblock", "end" ] ]
],
r.parse( "/** Comment 1 */\ndef codeblock\nend\n" )
)
end
def test_block_start_with_comment
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
assert_equal(
[
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ]
],
r.parse( "/** Comment 1a\n * Comment 1b\n */\ndef codeblock\nend\n" )
)
end
def test_block_end_with_comment
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
assert_equal(
[
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ]
],
r.parse( "/**\n * Comment 1a\n Comment 1b */\ndef codeblock\nend\n" )
)
end
def test_block_end_with_comment_and_middle
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
assert_equal(
[
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ]
],
r.parse( "/**\n * Comment 1a\n * Comment 1b */\ndef codeblock\nend\n" )
)
end
def test_block_start_with_comment_and_end_with_comment
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
assert_equal(
[
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ]
],
r.parse( "/** Comment 1a\n Comment 1b */\ndef codeblock\nend\n" )
)
end
def test_block_start_with_comment_and_end_with_comment_and_middle
r = Rocco.new( 'test', '', { :language => "c" } ) { "" } # Generate throwaway instance so I can test `parse`
assert_equal(
[
[ [ "Comment 1a", "Comment 1b" ], [ "def codeblock", "end" ] ]
],
r.parse( "/** Comment 1a\n * Comment 1b */\ndef codeblock\nend\n" )
)
end
end