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