aboutsummaryrefslogtreecommitdiff
path: root/compiler/parser_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/parser_test.go')
-rw-r--r--compiler/parser_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/compiler/parser_test.go b/compiler/parser_test.go
index 7c33fb4..e4a6fe2 100644
--- a/compiler/parser_test.go
+++ b/compiler/parser_test.go
@@ -6,6 +6,7 @@ import (
"testing"
"github.com/nihei9/maleeni/spec"
+ "github.com/nihei9/maleeni/ucd"
)
func symPos(n uint16) symbolPosition {
@@ -1241,6 +1242,37 @@ func TestParse(t *testing.T) {
}
}
+func TestParse_ContributoryPropertyIsNotExposed(t *testing.T) {
+ for _, cProp := range ucd.ContributoryProperties() {
+ t.Run(fmt.Sprintf("%v", cProp), func(t *testing.T) {
+ ast, _, err := parse([]*patternEntry{
+ {
+ id: spec.LexModeKindIDMin,
+ pattern: []byte(fmt.Sprintf(`\p{%v=yes}`, cProp)),
+ },
+ }, nil)
+ if err == nil {
+ t.Fatalf("expected syntax error; got: nil")
+ }
+ parseErrs, ok := err.(*ParseErrors)
+ if !ok {
+ t.Fatalf("expected ParseErrors; got: %v (type: %T)", err, err)
+ }
+ parseErr := parseErrs.Errors[0].Cause
+ synErr, ok := parseErr.(*SyntaxError)
+ if !ok {
+ t.Fatalf("expected SyntaxError; got: %v (type: %T)", parseErr, parseErr)
+ }
+ if synErr != synErrCharPropUnsupported {
+ t.Fatalf("unexpected syntax error; want: %v, got: %v", synErrCharPropUnsupported, synErr)
+ }
+ if ast != nil {
+ t.Fatalf("ast is not nil")
+ }
+ })
+ }
+}
+
func TestParse_FollowAndSymbolTable(t *testing.T) {
root, symTab, err := parse([]*patternEntry{
{