Skip to content

Commit

Permalink
Add heuristic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-NotTheMuss committed Dec 18, 2021
1 parent d1c85e7 commit 1a48c40
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ disambiguations:
pattern: '![\w\s]+methodsFor: '
- language: 'C#'
pattern: '^(\s*namespace\s*[\w\.]+\s*{|\s*\/\/)'
- extensions: ['.csc']
rules:
- language: GSC
named_pattern: gsc
- extensions: ['.csl']
rules:
- language: XML
Expand Down Expand Up @@ -229,14 +233,14 @@ disambiguations:
pattern: '^uses (java|gw)\.'
- language: Genie
pattern: '^\[indent=[0-9]+\]'
- extensions: ['.gsc', '.csc', '.gsh']
- extensions: ['.gsc']
rules:
- language: GSC
pattern:
- '^\s*#\s*(using|insert|include|define|namespace)\s+\w+'
- '^\s*function\s+\w+\w*\('
- '^\s*[[:alpha:]_][[:alnum:]_]*\s*\('
- '^\s*#\s*(precache|using_animtree)\s*\('
named_pattern: gsc
- extensions: ['.gsh']
rules:
- language: GSC
named_pattern: gsc
- extensions: ['.h']
rules:
- language: Objective-C
Expand Down Expand Up @@ -642,6 +646,11 @@ named_patterns:
- 'std::\w+'
fortran: '^(?i:[c*][^abd-z]| (subroutine|program|end|data)\s|\s*!)'
key_equals_value: '^[^#!;][^=]*='
gsc:
- '^\s*#\s*(using|insert|include|define|namespace)\s+\w+'
- '^\s*((autoexec|private)\s+)*function\s+((autoexec|private)\s+)*\w+\w*\('
- '(level|self)\s+thread\s+(\[\[\s*(\w+\.)*\w+\s*\]\]|\w+)s*\([^\)]*\)\s*;'
- '^\s*#\s*(precache|using_animtree)\s*\('
m68k:
- '(?im)\bmoveq(?:\.l)?\s+#(?:\$-?[0-9a-f]{1,3}|%[0-1]{1,8}|-?[0-9]{1,3}),\s*d[0-7]\b'
- '(?im)^\s*move(?:\.[bwl])?\s+(?:sr|usp),\s*[^\s]+'
Expand Down
18 changes: 18 additions & 0 deletions test/test_heuristics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ def test_cs_by_heuristics
})
end

def test_csc_by_heuristics
assert_heuristics({
"GSC" => all_fixtures("GSC", "*.csc")
})
end

def test_csl_by_heuristics
assert_heuristics({
"Kusto" => all_fixtures("Kusto", "*.csl"),
Expand Down Expand Up @@ -430,6 +436,18 @@ def test_gs_by_heuristics
}, alt_name="test.gs")
end

def test_gsc_by_heuristics
assert_heuristics({
"GSC" => all_fixtures("GSC", "*.gsc")
})
end

def test_gsh_by_heuristics
assert_heuristics({
"GSC" => all_fixtures("GSC", "*.gsh")
})
end

def test_h_by_heuristics
assert_heuristics({
"Objective-C" => all_fixtures("Objective-C", "*.h"),
Expand Down

0 comments on commit 1a48c40

Please sign in to comment.