mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Adding Perl heuristic (and fixing up Prolog)
This commit is contained in:
@@ -33,9 +33,10 @@ module Linguist
|
||||
matches
|
||||
end
|
||||
|
||||
def self_disambiguate_pl(data, languages)
|
||||
def self.disambiguate_pl(data, languages)
|
||||
matches = []
|
||||
matches << Language["Prolog"] if data.include?(":-")
|
||||
matches << Language["Perl"] if data.include?("use strict")
|
||||
matches
|
||||
end
|
||||
|
||||
|
||||
@@ -38,4 +38,16 @@ class TestHeuristcs < Test::Unit::TestCase
|
||||
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
|
||||
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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user