From efde4ffd2a7390ef5bdfc8c0588c3e380448bd02 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 21 Oct 2024 09:42:06 -0700 Subject: [PATCH] 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 * Update test/tests/syntax.json Co-authored-by: Eemeli Aro * Update test/tests/functions/string.json Co-authored-by: Eemeli Aro * Added tests for reordering and special case mapping * Add another selection test --------- Co-authored-by: Eemeli Aro --- test/tests/functions/string.json | 25 +++++++++++++++++++++ test/tests/syntax.json | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/test/tests/functions/string.json b/test/tests/functions/string.json index 3543e7844..231868180 100644 --- a/test/tests/functions/string.json +++ b/test/tests/functions/string.json @@ -44,6 +44,31 @@ "type": "unresolved-variable" } ] + }, + { + "description": "NFC: keys are normalized (unquoted)", + "src": ".local $x = {\u1E0A\u0323 :string} .match $x \u1E0A\u0323 {{Not normalized}} \u1E0C\u0307 {{Normalized}} * {{Wrong}}", + "expErrors": [{"type": "duplicate-variant"}] + }, + { + "description": "NFC: keys are normalized (quoted)", + "src": ".local $x = {\u1E0A\u0323 :string} .match $x |\u1E0A\u0323| {{Not normalized}} |\u1E0C\u0307| {{Normalized}} * {{Wrong}}", + "expErrors": [{"type": "duplicate-variant"}] + }, + { + "description": "NFC: keys are normalized (mixed)", + "src": ".local $x = {\u1E0A\u0323 :string} .match $x \u1E0A\u0323 {{Not normalized}} |\u1E0C\u0307| {{Normalized}} * {{Wrong}}", + "expErrors": [{"type": "duplicate-variant"}] + }, + { + "description": "NFC: :string normalizes the comparison value (un-normalized selector, normalized key)", + "src": ".local $x = {\u1E0A\u0323 :string} .match $x \u1E0C\u0307 {{Right}} * {{Wrong}}", + "exp": "Right" + }, + { + "description": "NFC: keys are normalized (normalized selector, un-normalized key)", + "src": ".local $x = {\u1E0C\u0307 :string} .match $x \u1E0A\u0323 {{Right}} * {{Wrong}}", + "exp": "Right" } ] } diff --git a/test/tests/syntax.json b/test/tests/syntax.json index 27b74b2f3..6082d094a 100644 --- a/test/tests/syntax.json +++ b/test/tests/syntax.json @@ -697,6 +697,43 @@ { "src": "{{trailing whitespace}} \n", "exp": "trailing whitespace" + }, + { + "description": "NFC: text is not normalized", + "src": "\u1E0A\u0323", + "exp": "\u1E0A\u0323" + }, + { + "description": "NFC: variables are compared to each other as-if normalized; decl is non-normalized, use is", + "src": ".local $\u0044\u0323\u0307 = {foo} {{{$\u1E0c\u0307}}}", + "exp": "foo" + }, + { + "description": "NFC: variables are compared to each other as-if normalized; decl is normalized, use isn't", + "src": ".local $\u1E0c\u0307 = {foo} {{{$\u0044\u0323\u0307}}}", + "exp": "foo" + }, + { + "description": "NFC: variables are compared to each other as-if normalized; decl is normalized, use isn't", + "src": ".input {$\u1E0c\u0307} {{{$\u0044\u0323\u0307}}}", + "params": [{"name": "\u1E0c\u0307", "value": "foo"}], + "exp": "foo" + }, + { + "description": "NFC: variables are compared to each other as-if normalized; decl is non-normalized, use is", + "src": ".input {$\u0044\u0323\u0307} {{{$\u1E0c\u0307}}}", + "params": [{"name": "\u0044\u0323\u0307", "value": "foo"}], + "exp": "foo" + }, + { + "description": "NFC: variables are compared to each other as-if normalized; decl is non-normalized, use is; reordering", + "src": ".local $\u0044\u0307\u0323 = {foo} {{{$\u1E0c\u0307}}}", + "exp": "foo" + }, + { + "description": "NFC: variables are compared to each other as-if normalized; decl is non-normalized, use is; special case mapping", + "src": ".local $\u0041\u030A\u0301 = {foo} {{{$\u01FA}}}", + "exp": "foo" } ] }