mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Add some tests for grammars.yml
It must be sorted, because it will get re-sorted when script/download-grammars is next run and that would clutter up diffs. And it must not contain any duplicate scopes.
This commit is contained in:
@@ -3,6 +3,7 @@ require_relative "./helper"
|
||||
class TestPedantic < Test::Unit::TestCase
|
||||
filename = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
|
||||
LANGUAGES = YAML.load(File.read(filename))
|
||||
GRAMMARS = YAML.load(File.read(File.expand_path("../../grammars.yml", __FILE__)))
|
||||
|
||||
def test_language_names_are_sorted
|
||||
assert_sorted LANGUAGES.keys
|
||||
@@ -21,6 +22,16 @@ class TestPedantic < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_grammars_are_sorted
|
||||
assert_sorted GRAMMARS.keys
|
||||
end
|
||||
|
||||
def test_scopes_are_sorted
|
||||
GRAMMARS.values.each do |scopes|
|
||||
assert_sorted scopes
|
||||
end
|
||||
end
|
||||
|
||||
def assert_sorted(list)
|
||||
list.each_cons(2) do |previous, item|
|
||||
flunk "#{previous} should come after #{item}" if previous > item
|
||||
|
||||
Reference in New Issue
Block a user