mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Only exact matches
This commit is contained in:
@@ -38,7 +38,7 @@ module Linguist
|
||||
# Returns an array of Languages or []
|
||||
def self.disambiguate_c(data, languages)
|
||||
matches = []
|
||||
if (/@(interface|class|protocol|property|end|synchronised|selector|implementation)/.match(data))
|
||||
if (/@\b(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data))
|
||||
matches << Language["Objective-C"]
|
||||
end
|
||||
if (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set|(i|o|io)stream)>/.match(data) or
|
||||
|
||||
@@ -25,7 +25,7 @@ class TestHeuristcs < Test::Unit::TestCase
|
||||
# Only calling out '.h' filenames as these are the ones causing issues
|
||||
all_fixtures("Objective-C", "*.h").each do |fixture|
|
||||
results = Heuristics.disambiguate_c(fixture("Objective-C/#{File.basename(fixture)}"), languages)
|
||||
assert_equal Language["Objective-C"], results.first
|
||||
assert_equal Language["Objective-C"], results.first, "Failed for #{File.basename(fixture)}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,25 +49,25 @@ class TestHeuristcs < Test::Unit::TestCase
|
||||
match = Language.detect(blob)
|
||||
assert_equal Language["Objective-C"], match
|
||||
end
|
||||
|
||||
|
||||
def test_pl_prolog_by_heuristics
|
||||
languages = ["Perl", "Prolog"]
|
||||
results = Heuristics.disambiguate_pl(fixture("Prolog/turing.pl"), languages)
|
||||
assert_equal Language["Prolog"], results.first
|
||||
end
|
||||
|
||||
|
||||
def test_pl_perl_by_heuristics
|
||||
languages = ["Perl", "Prolog"]
|
||||
results = Heuristics.disambiguate_pl(fixture("Perl/perl-test.t"), languages)
|
||||
assert_equal Language["Perl"], results.first
|
||||
end
|
||||
|
||||
|
||||
def test_ecl_prolog_by_heuristics
|
||||
languages = ["ECL", "Prolog"]
|
||||
results = Heuristics.disambiguate_ecl(fixture("Prolog/or-constraint.ecl"), languages)
|
||||
assert_equal Language["Prolog"], results.first
|
||||
end
|
||||
|
||||
|
||||
def test_ecl_ecl_by_heuristics
|
||||
languages = ["ECL", "Prolog"]
|
||||
results = Heuristics.disambiguate_ecl(fixture("ECL/sample.ecl"), languages)
|
||||
|
||||
Reference in New Issue
Block a user