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:
13
test/test_grammars.rb
Normal file
13
test/test_grammars.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require_relative "./helper"
|
||||
|
||||
class TestGrammars < Test::Unit::TestCase
|
||||
def setup
|
||||
@grammars = YAML.load(File.read(File.expand_path("../../grammars.yml", __FILE__)))
|
||||
end
|
||||
|
||||
def test_no_duplicate_scopes
|
||||
scopes = @grammars.values.flatten
|
||||
duplicates = scopes.group_by { |s| s }.select { |k, v| v.length > 1 }.map(&:first)
|
||||
assert duplicates.empty?, "The following scopes appear in grammars.yml more than once:\n#{duplicates.sort.join("\n")}"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user