aboutsummaryrefslogtreecommitdiff
path: root/compiler/parser_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-11-28 00:37:03 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-11-28 13:53:18 +0900
commitcb9d92f0b4e0097579f6e5da1dc6e2f063b532a9 (patch)
tree3d43aa9f3463f93451532d6dec9442a664d2d0a9 /compiler/parser_test.go
parentMove all UCD-related processes to ucd package (diff)
downloadtre-cb9d92f0b4e0097579f6e5da1dc6e2f063b532a9.tar.gz
tre-cb9d92f0b4e0097579f6e5da1dc6e2f063b532a9.tar.xz
Make contributory properties unavailable except internal use
This change follows [UAX #44 5.13 Property APIs]. > The following subtypes of Unicode character properties should generally not be exposed in APIs, > except in limited circumstances. They may not be useful, particularly in public API collections, > and may instead prove misleading to the users of such API collections. > > * Contributory properties are not recommended for public APIs. > ... https://unicode.org/reports/tr44/#Property_APIs
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{
{