1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-07-17 01:22:22 +02:00

Add a bunch of automatically translated lexers.

This commit is contained in:
Alec Thomas
2017-06-04 22:18:35 +10:00
parent b30de35ff1
commit 5dedc6e45b
20 changed files with 749 additions and 214 deletions

55
mutators_test.go Normal file
View File

@ -0,0 +1,55 @@
package chroma
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestInclude(t *testing.T) {
include := Include("other")
actual := CompiledRules{
"root": {
CompiledRule{Rule: include},
},
"other": {
CompiledRule{Rule: Rule{
Pattern: "//.+",
Type: Comment,
}},
CompiledRule{Rule: Rule{
Pattern: `"[^"]*"`,
Type: String,
}},
},
}
state := &LexerState{
State: "root",
Rules: actual,
}
err := include.Mutator.Mutate(state)
require.NoError(t, err)
expected := CompiledRules{
"root": {
CompiledRule{Rule: Rule{
Pattern: "//.+",
Type: Comment,
}},
CompiledRule{Rule: Rule{
Pattern: `"[^"]*"`,
Type: String,
}},
},
"other": {
CompiledRule{Rule: Rule{
Pattern: "//.+",
Type: Comment,
}},
CompiledRule{Rule: Rule{
Pattern: `"[^"]*"`,
Type: String,
}},
},
}
require.Equal(t, expected, actual)
}