2011-03-05 12:46:40 +00:00
|
|
|
require File.expand_path('../helper', __FILE__)
|
2010-10-24 09:07:44 +00:00
|
|
|
|
|
|
|
class RoccoAutomaticCommentChars < Test::Unit::TestCase
|
2011-03-05 11:48:15 +00:00
|
|
|
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
|
2010-10-24 09:07:44 +00:00
|
|
|
end
|