mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Fix heuristics after rename (#3556)
* fix Roff detection in heuristics This affects extensions .l, .ms, .n and .rno. Groff was renamed to Roff in 673aeb32b9851cc58429c4b598c876292aaf70c7, but heuristic was not updated. * replace FORTRAN with Fortran It was already renamed in most places since 4fd8fce08574809aa58e9771e2a9da5d135127be heuristics.rb was missing though. * fix caseness of GCC Machine Description
This commit is contained in:
committed by
Colin Seymour
parent
eb38c8dcf8
commit
c0e242358a
@@ -165,7 +165,7 @@ module Linguist
|
||||
elsif data.include?("flowop")
|
||||
Language["Filebench WML"]
|
||||
elsif fortran_rx.match(data)
|
||||
Language["FORTRAN"]
|
||||
Language["Fortran"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -173,7 +173,7 @@ module Linguist
|
||||
if /^: /.match(data)
|
||||
Language["Forth"]
|
||||
elsif fortran_rx.match(data)
|
||||
Language["FORTRAN"]
|
||||
Language["Fortran"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -226,7 +226,7 @@ module Linguist
|
||||
elsif /^(%[%{}]xs|<.*>)/.match(data)
|
||||
Language["Lex"]
|
||||
elsif /^\.[a-z][a-z](\s|$)/i.match(data)
|
||||
Language["Groff"]
|
||||
Language["Roff"]
|
||||
elsif /^\((de|class|rel|code|data|must)\s/.match(data)
|
||||
Language["PicoLisp"]
|
||||
end
|
||||
@@ -270,7 +270,7 @@ module Linguist
|
||||
if /(^[-a-z0-9=#!\*\[|>])|<\//i.match(data) || data.empty?
|
||||
Language["Markdown"]
|
||||
elsif /^(;;|\(define_)/.match(data)
|
||||
Language["GCC machine description"]
|
||||
Language["GCC Machine Description"]
|
||||
else
|
||||
Language["Markdown"]
|
||||
end
|
||||
@@ -296,7 +296,7 @@ module Linguist
|
||||
|
||||
disambiguate ".ms" do |data|
|
||||
if /^[.'][a-z][a-z](\s|$)/i.match(data)
|
||||
Language["Groff"]
|
||||
Language["Roff"]
|
||||
elsif /(?<!\S)\.(include|globa?l)\s/.match(data) || /(?<!\/\*)(\A|\n)\s*\.[A-Za-z]/.match(data.gsub(/"([^\\"]|\\.)*"|'([^\\']|\\.)*'|\\\s*(?:--.*)?\n/, ""))
|
||||
Language["Unix Assembly"]
|
||||
else
|
||||
@@ -306,7 +306,7 @@ module Linguist
|
||||
|
||||
disambiguate ".n" do |data|
|
||||
if /^[.']/.match(data)
|
||||
Language["Groff"]
|
||||
Language["Roff"]
|
||||
elsif /^(module|namespace|using)\s/.match(data)
|
||||
Language["Nemerle"]
|
||||
end
|
||||
@@ -392,7 +392,7 @@ module Linguist
|
||||
if /^\.!|^\.end lit(?:eral)?\b/i.match(data)
|
||||
Language["RUNOFF"]
|
||||
elsif /^\.\\" /.match(data)
|
||||
Language["Groff"]
|
||||
Language["Roff"]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class TestHeuristcs < Minitest::Test
|
||||
|
||||
def test_f_by_heuristics
|
||||
assert_heuristics({
|
||||
"FORTRAN" => all_fixtures("FORTRAN", "*.f") + all_fixtures("FORTRAN", "*.for"),
|
||||
"Fortran" => all_fixtures("Fortran", "*.f") + all_fixtures("Fortran", "*.for"),
|
||||
"Forth" => all_fixtures("Forth", "*.f") + all_fixtures("Forth", "*.for")
|
||||
})
|
||||
end
|
||||
@@ -144,6 +144,15 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
def test_l_by_heuristics
|
||||
assert_heuristics({
|
||||
"Common Lisp" => all_fixtures("Common Lisp", "*.l"),
|
||||
"Lex" => all_fixtures("Lex", "*.l"),
|
||||
"Roff" => all_fixtures("Roff", "*.l"),
|
||||
"PicoLisp" => all_fixtures("PicoLisp", "*.l")
|
||||
})
|
||||
end
|
||||
|
||||
def test_ls_by_heuristics
|
||||
assert_heuristics({
|
||||
"LiveScript" => all_fixtures("LiveScript", "*.ls"),
|
||||
@@ -174,17 +183,25 @@ class TestHeuristcs < Minitest::Test
|
||||
def test_md_by_heuristics
|
||||
assert_heuristics({
|
||||
"Markdown" => all_fixtures("Markdown", "*.md"),
|
||||
"GCC machine description" => all_fixtures("GCC machine description", "*.md")
|
||||
"GCC Machine Description" => all_fixtures("GCC Machine Description", "*.md")
|
||||
})
|
||||
end
|
||||
|
||||
def test_ms_by_heuristics
|
||||
assert_heuristics({
|
||||
"Roff" => all_fixtures("Roff", "*.ms"),
|
||||
"Unix Assembly" => all_fixtures("Unix Assembly", "*.ms"),
|
||||
"MAXScript" => all_fixtures("MAXScript", "*.ms")
|
||||
})
|
||||
end
|
||||
|
||||
def test_n_by_heuristics
|
||||
assert_heuristics({
|
||||
"Roff" => all_fixtures("Roff", "*.n"),
|
||||
"Nemerle" => all_fixtures("Nemerle", "*.n")
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["C++", "Objective-C"]
|
||||
def test_obj_c_by_heuristics
|
||||
# Only calling out '.h' filenames as these are the ones causing issues
|
||||
@@ -237,6 +254,13 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
def test_rno_by_heuristics
|
||||
assert_heuristics({
|
||||
"RUNOFF" => all_fixtures("RUNOFF", "*.rno"),
|
||||
"Roff" => all_fixtures("Roff", "*.rno")
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["Scala", "SuperCollider"]
|
||||
def test_sc_supercollider_scala_by_heuristics
|
||||
assert_heuristics({
|
||||
|
||||
Reference in New Issue
Block a user