mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Sample returns simple hash objects
This commit is contained in:
@@ -276,8 +276,9 @@ class TestBlob < Test::Unit::TestCase
|
||||
|
||||
def test_language
|
||||
Sample.each do |sample|
|
||||
blob = blob(sample.path)
|
||||
assert_equal sample.language, blob.language, blob.name
|
||||
blob = blob(sample[:path])
|
||||
language = Linguist::Language.find_by_alias(sample[:language])
|
||||
assert_equal language, blob.language, blob.name
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -69,14 +69,15 @@ class TestClassifier < Test::Unit::TestCase
|
||||
|
||||
def test_classify_ambiguous_languages
|
||||
Sample.each do |sample|
|
||||
next unless sample.language.overrides.any?
|
||||
language = Linguist::Language.find_by_alias(sample[:language])
|
||||
next unless language.overrides.any?
|
||||
|
||||
extname = File.extname(sample.path)
|
||||
extname = File.extname(sample[:path])
|
||||
languages = Language.all.select { |l| l.extensions.include?(extname) }.map(&:name)
|
||||
next unless languages.length > 1
|
||||
|
||||
results = Classifier.instance.classify(sample.data, languages)
|
||||
assert_equal sample.language.name, results.first[0], "#{sample.path}\n#{results.inspect}"
|
||||
results = Classifier.instance.classify(File.read(sample[:path]), languages)
|
||||
assert_equal language.name, results.first[0], "#{sample[:path]}\n#{results.inspect}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user