mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Load classifer db into sample data hash
This commit is contained in:
@@ -18,7 +18,7 @@ class TestClassifier < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_instance_freshness
|
||||
serialized = Linguist::MD5.hexdigest(Classifier.instance.to_hash)
|
||||
serialized = Linguist::MD5.hexdigest(Sample::DATA)
|
||||
latest = Linguist::MD5.hexdigest(Linguist::Sample.classifier.to_hash)
|
||||
|
||||
# Just warn, it shouldn't scare people off by breaking the build.
|
||||
@@ -55,16 +55,16 @@ class TestClassifier < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_instance_classify_empty
|
||||
results = Classifier.instance.classify("")
|
||||
results = Classifier.new(Sample::DATA).classify("")
|
||||
assert results.first[1] < 0.5, results.first.inspect
|
||||
end
|
||||
|
||||
def test_instance_classify_nil
|
||||
assert_equal [], Classifier.instance.classify(nil)
|
||||
assert_equal [], Classifier.new(Sample::DATA).classify(nil)
|
||||
end
|
||||
|
||||
def test_verify
|
||||
data = Classifier.instance.to_hash
|
||||
data = Sample::DATA
|
||||
|
||||
assert_equal data['languages_total'], data['languages'].inject(0) { |n, (_, c)| n += c }
|
||||
assert_equal data['tokens_total'], data['language_tokens'].inject(0) { |n, (_, c)| n += c }
|
||||
@@ -80,7 +80,7 @@ class TestClassifier < Test::Unit::TestCase
|
||||
languages = Language.all.select { |l| l.extensions.include?(extname) }.map(&:name)
|
||||
next unless languages.length > 1
|
||||
|
||||
results = Classifier.instance.classify(File.read(sample[:path]), languages)
|
||||
results = Classifier.new(Sample::DATA).classify(File.read(sample[:path]), languages)
|
||||
assert_equal language.name, results.first[0], "#{sample[:path]}\n#{results.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user