mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	* grammars: Update several grammars with compat issues * [WIP] Add new grammar conversion tools * Wrap in a Docker script * Proper Dockerfile support * Add Javadoc grammar * Remove NPM package.json * Remove superfluous test This is now always checked by the grammars compiler * Update JSyntax grammar to new submodule * Approve Javadoc license * grammars: Remove checked-in dependencies * grammars: Add regex checks to the compiler * grammars: Point Oz to its actual submodule * grammars: Refactor compiler to group errors by repo * grammars: Cleanups to error reporting
		
			
				
	
	
		
			28 lines
		
	
	
		
			617 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			617 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package compiler
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| )
 | |
| 
 | |
| func Test_fixRegex(t *testing.T) {
 | |
| 	tests := []struct {
 | |
| 		re   string
 | |
| 		want string
 | |
| 	}{
 | |
| 		{"foobar", "foobar"},
 | |
| 		{`testing\h`, "testing[[:xdigit:]]"},
 | |
| 		{`\htest`, `[[:xdigit:]]test`},
 | |
| 		{`abc\hdef`, `abc[[:xdigit:]]def`},
 | |
| 		{`\\\htest`, `\\[[:xdigit:]]test`},
 | |
| 		{`\\htest`, `\\htest`},
 | |
| 		{`\h\h\h\h`, `[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]`},
 | |
| 		{`abc\hdef\hghi\h`, `abc[[:xdigit:]]def[[:xdigit:]]ghi[[:xdigit:]]`},
 | |
| 	}
 | |
| 	for _, tt := range tests {
 | |
| 		got, _ := fixRegex(tt.re)
 | |
| 		if got != tt.want {
 | |
| 			t.Errorf("fixRegex() got = %v, want %v", got, tt.want)
 | |
| 		}
 | |
| 	}
 | |
| }
 |