mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Adding Charity and heuristic for xBase .ch files
This commit is contained in:
		| @@ -333,5 +333,11 @@ module Linguist | |||||||
|         Language["GAS"] |         Language["GAS"] | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  |     disambiguate "xBase", "Charity" do |data| | ||||||
|  |       if /^\s*#\s*(if|ifdef|ifndef|define|command|xcommand|translate|xtranslate|include|pragma|undef)\b/i.match(data) | ||||||
|  |         Language["xBase"] | ||||||
|  |       end | ||||||
|  |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
| @@ -501,6 +501,13 @@ Chapel: | |||||||
|   - .chpl |   - .chpl | ||||||
|   ace_mode: text |   ace_mode: text | ||||||
|  |  | ||||||
|  | Charity: | ||||||
|  |   type: programming | ||||||
|  |   extensions: | ||||||
|  |     - .ch | ||||||
|  |   tm_scope: none | ||||||
|  |   ace_mode: text | ||||||
|  |  | ||||||
| ChucK: | ChucK: | ||||||
|   type: programming |   type: programming | ||||||
|   extensions: |   extensions: | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								samples/Charity/example.ch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								samples/Charity/example.ch
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | % | ||||||
|  | %   Some very badly written Charity | ||||||
|  | % | ||||||
|  |  | ||||||
|  | data LA(A) -> D = ss: A -> D | ||||||
|  |                 | ff: -> D. | ||||||
| @@ -22,6 +22,17 @@ class TestHeuristcs < Minitest::Test | |||||||
|     assert_equal [], results |     assert_equal [], results | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  |   def assert_heuristics(hash) | ||||||
|  |     candidates = hash.keys.map { |l| Language[l] } | ||||||
|  |  | ||||||
|  |     hash.each do |language, blobs| | ||||||
|  |       Array(blobs).each do |blob| | ||||||
|  |         result = Heuristics.call(file_blob(blob), candidates) | ||||||
|  |         assert_equal [Language[language]], result, "Failed for #{blob}" | ||||||
|  |       end | ||||||
|  |     end | ||||||
|  |   end | ||||||
|  |  | ||||||
|   # Candidate languages = ["C++", "Objective-C"] |   # Candidate languages = ["C++", "Objective-C"] | ||||||
|   def test_obj_c_by_heuristics |   def test_obj_c_by_heuristics | ||||||
|     # Only calling out '.h' filenames as these are the ones causing issues |     # Only calling out '.h' filenames as these are the ones causing issues | ||||||
| @@ -147,17 +158,6 @@ class TestHeuristcs < Minitest::Test | |||||||
|     }) |     }) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def assert_heuristics(hash) |  | ||||||
|     candidates = hash.keys.map { |l| Language[l] } |  | ||||||
|  |  | ||||||
|     hash.each do |language, blobs| |  | ||||||
|       Array(blobs).each do |blob| |  | ||||||
|         result = Heuristics.call(file_blob(blob), candidates) |  | ||||||
|         assert_equal [Language[language]], result, "Failed for #{blob}" |  | ||||||
|       end |  | ||||||
|     end |  | ||||||
|   end |  | ||||||
|  |  | ||||||
|   def test_ls_by_heuristics |   def test_ls_by_heuristics | ||||||
|     assert_heuristics({ |     assert_heuristics({ | ||||||
|       "LiveScript" => "LiveScript/hello.ls", |       "LiveScript" => "LiveScript/hello.ls", | ||||||
| @@ -171,4 +171,10 @@ class TestHeuristcs < Minitest::Test | |||||||
|       "XML" => all_fixtures("XML", "*.ts") |       "XML" => all_fixtures("XML", "*.ts") | ||||||
|     }) |     }) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  |   def test_ch_by_heuristics | ||||||
|  |     assert_heuristics({ | ||||||
|  |       "xBase" => all_fixtures("xBase") | ||||||
|  |     }) | ||||||
|  |   end | ||||||
| end | end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user