Detect "use 5.xxx" as Perl

This commit is contained in:
Brandon Keepers
2015-02-09 10:19:36 -05:00
parent 74cd03de0b
commit bdc724d548
3 changed files with 5 additions and 2 deletions

View File

@@ -92,7 +92,7 @@ module Linguist
disambiguate "Perl", "Perl6", "Prolog" do |data| disambiguate "Perl", "Perl6", "Prolog" do |data|
if data.include?("use v6") if data.include?("use v6")
Language["Perl6"] Language["Perl6"]
elsif data.include?("use strict") elsif data.match(/use strict|use\s+v?5\./)
Language["Perl"] Language["Perl"]
elsif data.include?(":-") elsif data.include?(":-")
Language["Prolog"] Language["Prolog"]

3
samples/Perl/use5.pl Normal file
View File

@@ -0,0 +1,3 @@
use Mojolicious::Lite;
use 5.20.0;
use experimental 'signatures';

View File

@@ -48,7 +48,7 @@ class TestHeuristcs < Minitest::Test
def test_pl_prolog_perl_by_heuristics def test_pl_prolog_perl_by_heuristics
assert_heuristics({ assert_heuristics({
"Prolog" => "Prolog/turing.pl", "Prolog" => "Prolog/turing.pl",
"Perl" => "Perl/perl-test.t", "Perl" => ["Perl/perl-test.t", "Perl/use5.pl"]
}) })
end end