mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	This gives us a consistent test framework across all Ruby versions which should help avoid errors that are only found when CI runs the tests on different Rubies. (And this fixes an immediate bug where there's no `skip` method in the version of test-unit we're currently using only on Ruby 2.2.)
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require_relative "./helper"
 | |
| 
 | |
| class TestPedantic < Minitest::Test
 | |
|   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
 | |
|   end
 | |
| 
 | |
|   def test_extensions_are_sorted
 | |
|     LANGUAGES.each do |name, language|
 | |
|       extensions = language['extensions']
 | |
|       assert_sorted extensions[1..-1] if extensions && extensions.size > 1
 | |
|     end
 | |
|   end
 | |
| 
 | |
|   def test_filenames_are_sorted
 | |
|     LANGUAGES.each do |name, language|
 | |
|       assert_sorted language['filenames'] if language['filenames']
 | |
|     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
 | |
|     end
 | |
|   end
 | |
| end
 |