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:
55
mutators_test.go
Normal file
55
mutators_test.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user