mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Alphabetise heuristics.
This commit is contained in:
@@ -33,6 +33,101 @@ class TestHeuristcs < Minitest::Test
|
||||
end
|
||||
end
|
||||
|
||||
def test_detect_still_works_if_nothing_matches
|
||||
blob = Linguist::FileBlob.new(File.join(samples_path, "Objective-C/hello.m"))
|
||||
match = Language.detect(blob)
|
||||
assert_equal Language["Objective-C"], match
|
||||
end
|
||||
|
||||
# Candidate languages = ["AGS Script", "AsciiDoc", "Public Key"]
|
||||
def test_asc_by_heuristics
|
||||
assert_heuristics({
|
||||
"AsciiDoc" => all_fixtures("AsciiDoc", "*.asc"),
|
||||
"AGS Script" => all_fixtures("AGS Script", "*.asc"),
|
||||
"Public Key" => all_fixtures("Public Key", "*.asc")
|
||||
})
|
||||
end
|
||||
|
||||
def test_bb_by_heuristics
|
||||
assert_heuristics({
|
||||
"BitBake" => all_fixtures("BitBake", "*.bb"),
|
||||
"BlitzBasic" => all_fixtures("BlitzBasic", "*.bb")
|
||||
})
|
||||
end
|
||||
|
||||
def test_ch_by_heuristics
|
||||
assert_heuristics({
|
||||
"xBase" => all_fixtures("xBase", ".ch")
|
||||
})
|
||||
end
|
||||
|
||||
def test_cl_by_heuristics
|
||||
assert_heuristics({
|
||||
"Common Lisp" => all_fixtures("Common Lisp", "*.cl"),
|
||||
"OpenCL" => all_fixtures("OpenCL", "*.cl")
|
||||
})
|
||||
end
|
||||
|
||||
def test_cs_by_heuristics
|
||||
assert_heuristics({
|
||||
"C#" => all_fixtures("C#", "*.cs"),
|
||||
"Smalltalk" => all_fixtures("Smalltalk", "*.cs")
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["ECL", "ECLiPSe"]
|
||||
def test_ecl_by_heuristics
|
||||
assert_heuristics({
|
||||
"ECL" => all_fixtures("ECL", "*.ecl"),
|
||||
"ECLiPSe" => all_fixtures("ECLiPSe", "*.ecl")
|
||||
})
|
||||
end
|
||||
|
||||
def test_f_by_heuristics
|
||||
assert_heuristics({
|
||||
"FORTRAN" => all_fixtures("FORTRAN", "*.f") + all_fixtures("FORTRAN", "*.for"),
|
||||
"Forth" => all_fixtures("Forth", "*.f") + all_fixtures("Forth", "*.for")
|
||||
})
|
||||
end
|
||||
|
||||
def test_fr_by_heuristics
|
||||
assert_heuristics({
|
||||
"Frege" => all_fixtures("Frege", "*.fr"),
|
||||
"Forth" => all_fixtures("Forth", "*.fr"),
|
||||
"Text" => all_fixtures("Text", "*.fr")
|
||||
})
|
||||
end
|
||||
|
||||
def test_fs_by_heuristics
|
||||
assert_heuristics({
|
||||
"F#" => all_fixtures("F#", "*.fs"),
|
||||
"Forth" => all_fixtures("Forth", "*.fs"),
|
||||
"GLSL" => all_fixtures("GLSL", "*.fs")
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["Hack", "PHP"]
|
||||
def test_hack_by_heuristics
|
||||
assert_heuristics({
|
||||
"Hack" => all_fixtures("Hack", "*.php"),
|
||||
"PHP" => all_fixtures("PHP", "*.php")
|
||||
})
|
||||
end
|
||||
|
||||
def test_ls_by_heuristics
|
||||
assert_heuristics({
|
||||
"LiveScript" => all_fixtures("LiveScript", "*.ls"),
|
||||
"LoomScript" => all_fixtures("LoomScript", "*.ls")
|
||||
})
|
||||
end
|
||||
|
||||
def test_lsp_by_heuristics
|
||||
assert_heuristics({
|
||||
"Common Lisp" => all_fixtures("Common Lisp", "*.lsp") + all_fixtures("Common Lisp", "*.lisp"),
|
||||
"NewLisp" => all_fixtures("NewLisp", "*.lsp") + all_fixtures("NewLisp", "*.lisp")
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["C++", "Objective-C"]
|
||||
def test_obj_c_by_heuristics
|
||||
# Only calling out '.h' filenames as these are the ones causing issues
|
||||
@@ -43,12 +138,6 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
def test_detect_still_works_if_nothing_matches
|
||||
blob = Linguist::FileBlob.new(File.join(samples_path, "Objective-C/hello.m"))
|
||||
match = Language.detect(blob)
|
||||
assert_equal Language["Objective-C"], match
|
||||
end
|
||||
|
||||
# Candidate languages = ["Perl", "Perl6", "Prolog"]
|
||||
def test_pl_prolog_perl_by_heuristics
|
||||
assert_heuristics({
|
||||
@@ -66,24 +155,6 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["Perl", "Perl6"]
|
||||
def test_t_perl_by_heuristics
|
||||
assert_heuristics({
|
||||
"Perl" => all_fixtures("Perl", "*.t"),
|
||||
"Perl6" => ["Perl6/01-dash-uppercase-i.t", "Perl6/01-parse.t", "Perl6/advent2009-day16.t",
|
||||
"Perl6/basic-open.t", "Perl6/calendar.t", "Perl6/for.t", "Perl6/hash.t",
|
||||
"Perl6/listquote-whitespace.t"]
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["ECL", "ECLiPSe"]
|
||||
def test_ecl_by_heuristics
|
||||
assert_heuristics({
|
||||
"ECL" => all_fixtures("ECL", "*.ecl"),
|
||||
"ECLiPSe" => all_fixtures("ECLiPSe", "*.ecl")
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["IDL", "Prolog", "QMake", "INI"]
|
||||
def test_pro_by_heuristics
|
||||
assert_heuristics({
|
||||
@@ -94,34 +165,10 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["AGS Script", "AsciiDoc", "Public Key"]
|
||||
def test_asc_by_heuristics
|
||||
def test_r_by_heuristics
|
||||
assert_heuristics({
|
||||
"AsciiDoc" => all_fixtures("AsciiDoc", "*.asc"),
|
||||
"AGS Script" => all_fixtures("AGS Script", "*.asc"),
|
||||
"Public Key" => all_fixtures("Public Key", "*.asc")
|
||||
})
|
||||
end
|
||||
|
||||
def test_cl_by_heuristics
|
||||
assert_heuristics({
|
||||
"Common Lisp" => all_fixtures("Common Lisp", "*.cl"),
|
||||
"OpenCL" => all_fixtures("OpenCL", "*.cl")
|
||||
})
|
||||
end
|
||||
|
||||
def test_f_by_heuristics
|
||||
assert_heuristics({
|
||||
"FORTRAN" => all_fixtures("FORTRAN", "*.f") + all_fixtures("FORTRAN", "*.for"),
|
||||
"Forth" => all_fixtures("Forth", "*.f") + all_fixtures("Forth", "*.for")
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["Hack", "PHP"]
|
||||
def test_hack_by_heuristics
|
||||
assert_heuristics({
|
||||
"Hack" => all_fixtures("Hack", "*.php"),
|
||||
"PHP" => all_fixtures("PHP", "*.php")
|
||||
"R" => all_fixtures("R", "*.r") + all_fixtures("R", "*.R"),
|
||||
"Rebol" => all_fixtures("Rebol", "*.r")
|
||||
})
|
||||
end
|
||||
|
||||
@@ -133,47 +180,13 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
def test_fs_by_heuristics
|
||||
# Candidate languages = ["Perl", "Perl6"]
|
||||
def test_t_perl_by_heuristics
|
||||
assert_heuristics({
|
||||
"F#" => all_fixtures("F#", "*.fs"),
|
||||
"Forth" => all_fixtures("Forth", "*.fs"),
|
||||
"GLSL" => all_fixtures("GLSL", "*.fs")
|
||||
})
|
||||
end
|
||||
|
||||
def test_fr_by_heuristics
|
||||
assert_heuristics({
|
||||
"Frege" => all_fixtures("Frege", "*.fr"),
|
||||
"Forth" => all_fixtures("Forth", "*.fr"),
|
||||
"Text" => all_fixtures("Text", "*.fr")
|
||||
})
|
||||
end
|
||||
|
||||
def test_bb_by_heuristics
|
||||
assert_heuristics({
|
||||
"BitBake" => all_fixtures("BitBake", "*.bb"),
|
||||
"BlitzBasic" => all_fixtures("BlitzBasic", "*.bb")
|
||||
})
|
||||
end
|
||||
|
||||
def test_lsp_by_heuristics
|
||||
assert_heuristics({
|
||||
"Common Lisp" => all_fixtures("Common Lisp", "*.lsp") + all_fixtures("Common Lisp", "*.lisp"),
|
||||
"NewLisp" => all_fixtures("NewLisp", "*.lsp") + all_fixtures("NewLisp", "*.lisp")
|
||||
})
|
||||
end
|
||||
|
||||
def test_cs_by_heuristics
|
||||
assert_heuristics({
|
||||
"C#" => all_fixtures("C#", "*.cs"),
|
||||
"Smalltalk" => all_fixtures("Smalltalk", "*.cs")
|
||||
})
|
||||
end
|
||||
|
||||
def test_ls_by_heuristics
|
||||
assert_heuristics({
|
||||
"LiveScript" => all_fixtures("LiveScript", "*.ls"),
|
||||
"LoomScript" => all_fixtures("LoomScript", "*.ls")
|
||||
"Perl" => all_fixtures("Perl", "*.t"),
|
||||
"Perl6" => ["Perl6/01-dash-uppercase-i.t", "Perl6/01-parse.t", "Perl6/advent2009-day16.t",
|
||||
"Perl6/basic-open.t", "Perl6/calendar.t", "Perl6/for.t", "Perl6/hash.t",
|
||||
"Perl6/listquote-whitespace.t"]
|
||||
})
|
||||
end
|
||||
|
||||
@@ -183,17 +196,4 @@ class TestHeuristcs < Minitest::Test
|
||||
"XML" => all_fixtures("XML", "*.ts")
|
||||
})
|
||||
end
|
||||
|
||||
def test_ch_by_heuristics
|
||||
assert_heuristics({
|
||||
"xBase" => all_fixtures("xBase", ".ch")
|
||||
})
|
||||
end
|
||||
|
||||
def test_r_by_heuristics
|
||||
assert_heuristics({
|
||||
"R" => all_fixtures("R", "*.r") + all_fixtures("R", "*.R"),
|
||||
"Rebol" => all_fixtures("Rebol", "*.r")
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user