Adding Charity and heuristic for xBase .ch files

This commit is contained in:
Arfon Smith
2015-07-21 14:59:47 +01:00
parent aef19d72f9
commit 6b747f7d65
4 changed files with 36 additions and 11 deletions

View File

@@ -22,6 +22,17 @@ class TestHeuristcs < Minitest::Test
assert_equal [], results
end
def assert_heuristics(hash)
candidates = hash.keys.map { |l| Language[l] }
hash.each do |language, blobs|
Array(blobs).each do |blob|
result = Heuristics.call(file_blob(blob), candidates)
assert_equal [Language[language]], result, "Failed for #{blob}"
end
end
end
# Candidate languages = ["C++", "Objective-C"]
def test_obj_c_by_heuristics
# Only calling out '.h' filenames as these are the ones causing issues
@@ -147,17 +158,6 @@ class TestHeuristcs < Minitest::Test
})
end
def assert_heuristics(hash)
candidates = hash.keys.map { |l| Language[l] }
hash.each do |language, blobs|
Array(blobs).each do |blob|
result = Heuristics.call(file_blob(blob), candidates)
assert_equal [Language[language]], result, "Failed for #{blob}"
end
end
end
def test_ls_by_heuristics
assert_heuristics({
"LiveScript" => "LiveScript/hello.ls",
@@ -171,4 +171,10 @@ class TestHeuristcs < Minitest::Test
"XML" => all_fixtures("XML", "*.ts")
})
end
def test_ch_by_heuristics
assert_heuristics({
"xBase" => all_fixtures("xBase")
})
end
end