Skip to content

Commit efde4ff

Browse files
catamorphismeemeli
andauthored
Add tests for changes due to #885 (name/literal equality) (#904)
* Add tests for changes due to #885 (name/literal equality) * Update test/tests/functions/string.json Co-authored-by: Eemeli Aro <[email protected]> * Update test/tests/syntax.json Co-authored-by: Eemeli Aro <[email protected]> * Update test/tests/functions/string.json Co-authored-by: Eemeli Aro <[email protected]> * Added tests for reordering and special case mapping * Add another selection test --------- Co-authored-by: Eemeli Aro <[email protected]>
1 parent 218c61c commit efde4ff

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

test/tests/functions/string.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,31 @@
4444
"type": "unresolved-variable"
4545
}
4646
]
47+
},
48+
{
49+
"description": "NFC: keys are normalized (unquoted)",
50+
"src": ".local $x = {\u1E0A\u0323 :string} .match $x \u1E0A\u0323 {{Not normalized}} \u1E0C\u0307 {{Normalized}} * {{Wrong}}",
51+
"expErrors": [{"type": "duplicate-variant"}]
52+
},
53+
{
54+
"description": "NFC: keys are normalized (quoted)",
55+
"src": ".local $x = {\u1E0A\u0323 :string} .match $x |\u1E0A\u0323| {{Not normalized}} |\u1E0C\u0307| {{Normalized}} * {{Wrong}}",
56+
"expErrors": [{"type": "duplicate-variant"}]
57+
},
58+
{
59+
"description": "NFC: keys are normalized (mixed)",
60+
"src": ".local $x = {\u1E0A\u0323 :string} .match $x \u1E0A\u0323 {{Not normalized}} |\u1E0C\u0307| {{Normalized}} * {{Wrong}}",
61+
"expErrors": [{"type": "duplicate-variant"}]
62+
},
63+
{
64+
"description": "NFC: :string normalizes the comparison value (un-normalized selector, normalized key)",
65+
"src": ".local $x = {\u1E0A\u0323 :string} .match $x \u1E0C\u0307 {{Right}} * {{Wrong}}",
66+
"exp": "Right"
67+
},
68+
{
69+
"description": "NFC: keys are normalized (normalized selector, un-normalized key)",
70+
"src": ".local $x = {\u1E0C\u0307 :string} .match $x \u1E0A\u0323 {{Right}} * {{Wrong}}",
71+
"exp": "Right"
4772
}
4873
]
4974
}

test/tests/syntax.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,43 @@
697697
{
698698
"src": "{{trailing whitespace}} \n",
699699
"exp": "trailing whitespace"
700+
},
701+
{
702+
"description": "NFC: text is not normalized",
703+
"src": "\u1E0A\u0323",
704+
"exp": "\u1E0A\u0323"
705+
},
706+
{
707+
"description": "NFC: variables are compared to each other as-if normalized; decl is non-normalized, use is",
708+
"src": ".local $\u0044\u0323\u0307 = {foo} {{{$\u1E0c\u0307}}}",
709+
"exp": "foo"
710+
},
711+
{
712+
"description": "NFC: variables are compared to each other as-if normalized; decl is normalized, use isn't",
713+
"src": ".local $\u1E0c\u0307 = {foo} {{{$\u0044\u0323\u0307}}}",
714+
"exp": "foo"
715+
},
716+
{
717+
"description": "NFC: variables are compared to each other as-if normalized; decl is normalized, use isn't",
718+
"src": ".input {$\u1E0c\u0307} {{{$\u0044\u0323\u0307}}}",
719+
"params": [{"name": "\u1E0c\u0307", "value": "foo"}],
720+
"exp": "foo"
721+
},
722+
{
723+
"description": "NFC: variables are compared to each other as-if normalized; decl is non-normalized, use is",
724+
"src": ".input {$\u0044\u0323\u0307} {{{$\u1E0c\u0307}}}",
725+
"params": [{"name": "\u0044\u0323\u0307", "value": "foo"}],
726+
"exp": "foo"
727+
},
728+
{
729+
"description": "NFC: variables are compared to each other as-if normalized; decl is non-normalized, use is; reordering",
730+
"src": ".local $\u0044\u0307\u0323 = {foo} {{{$\u1E0c\u0307}}}",
731+
"exp": "foo"
732+
},
733+
{
734+
"description": "NFC: variables are compared to each other as-if normalized; decl is non-normalized, use is; special case mapping",
735+
"src": ".local $\u0041\u030A\u0301 = {foo} {{{$\u01FA}}}",
736+
"exp": "foo"
700737
}
701738
]
702739
}

0 commit comments

Comments
 (0)