Language detection test for non-sample files

This commit is contained in:
Paul Chaignon
2014-06-14 11:53:45 +02:00
parent b1c2820299
commit 2143699aab
3 changed files with 1546 additions and 0 deletions

View File

@@ -407,6 +407,25 @@ class TestBlob < Test::Unit::TestCase
assert blob.language, "No language for #{sample[:path]}"
assert_equal sample[:language], blob.language.name, blob.name
end
# Test language detection for files which shouldn't be used as samples
root = File.expand_path('../../test-files', __FILE__)
Dir.entries(root).each do |language|
next if language == '.' || language == '..'
# Each directory contains test files of a language
dirname = File.join(root, language)
Dir.entries(dirname).each do |filename|
next if filename == '.' || filename == '..'
# By default blob search the file in the samples;
# thus, we need to give it the absolute path
filepath = File.join(dirname, filename)
blob = blob(filepath)
assert blob.language, "No language for #{filepath}"
assert_equal language, blob.language.name, blob.name
end
end
end
def test_lexer