Skip to content

Commit

Permalink
Fix tests for bidirectional isolation (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli authored Nov 4, 2024
1 parent 2a28704 commit 313bc38
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 23 deletions.
27 changes: 27 additions & 0 deletions test/schemas/v0/tests.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
"src": {
"$ref": "#/$defs/src"
},
"bidiIsolation": {
"$ref": "#/$defs/bidiIsolation"
},
"params": {
"$ref": "#/$defs/params"
},
Expand Down Expand Up @@ -146,6 +149,9 @@
"src": {
"$ref": "#/$defs/src"
},
"bidiIsolation": {
"$ref": "#/$defs/bidiIsolation"
},
"params": {
"$ref": "#/$defs/params"
},
Expand All @@ -172,6 +178,10 @@
"description": "The MF2 syntax source.",
"type": "string"
},
"bidiIsolation": {
"description": "The bidi isolation strategy.",
"enum": ["default", "none"]
},
"params": {
"description": "Parameters to pass in to the formatter for resolving external variables.",
"type": "array",
Expand Down Expand Up @@ -243,6 +253,23 @@
}
}
},
{
"description": "Bidi isolation part.",
"type": "object",
"additionalProperties": false,
"required": [
"type",
"value"
],
"properties": {
"type": {
"const": "bidiIsolation"
},
"value": {
"enum": ["\u2066", "\u2067", "\u2068", "\u2069"]
}
}
},
{
"description": "Message markup part.",
"type": "object",
Expand Down
19 changes: 10 additions & 9 deletions test/tests/bidi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"scenario": "Bidi support",
"description": "Tests for correct parsing of messages with bidirectional marks and isolates",
"defaultTestProperties": {
"bidiIsolation": "default",
"locale": "en-US"
},
"tests": [
Expand All @@ -13,17 +14,17 @@
{
"description": "complex-message = o *(declaration o) complex-body o",
"src": "\u200E .local $x = {1} {{ {$x}}}",
"exp": " 1"
"exp": " \u20681\u2069"
},
{
"description": "complex-message = o *(declaration o) complex-body o",
"src": ".local $x = {1} \u200F {{ {$x}}}",
"exp": " 1"
"exp": " \u20681\u2069"
},
{
"description": "complex-message = o *(declaration o) complex-body o",
"src": ".local $x = {1} {{ {$x}}} \u2066",
"exp": " 1"
"exp": " \u20681\u2069"
},
{
"description": "input-declaration = input o variable-expression",
Expand Down Expand Up @@ -79,12 +80,12 @@
{
"description": "literal-expression = \"{\" o literal [s function] *(s attribute) o \"}\"",
"src": "{\u200E hello \u200F}",
"exp": "hello"
"exp": "\u2068hello\u2069"
},
{
"description": "variable-expression = \"{\" o variable [s function] *(s attribute) o \"}\"",
"src": ".local $x = {1} {{ {\u200E $x \u200F} }}",
"exp": " 1 "
"exp": " \u20681\u2069 "
},
{
"description": "function-expression = \"{\" o function *(s attribute) o \"}\"",
Expand Down Expand Up @@ -114,7 +115,7 @@
{
"description": " name... excludes U+FFFD and U+061C -- this pases as name -> [bidi] name-start *name-char",
"src": ".local $\u061Cfoo = {1} {{ {$\u061Cfoo} }}",
"exp": " 1 "
"exp": " \u20681\u2069 "
},
{
"description": " name matches https://www.w3.org/TR/REC-xml-names/#NT-NCName but excludes U+FFFD and U+061C",
Expand All @@ -124,17 +125,17 @@
{
"description": "name = [bidi] name-start *name-char [bidi]",
"src": ".local $\u200Efoo\u200F = {3} {{{$\u200Efoo\u200F}}}",
"exp": "3"
"exp": "\u20683\u2069"
},
{
"description": "name = [bidi] name-start *name-char [bidi]",
"src": ".local $foo = {4} {{{$\u200Efoo\u200F}}}",
"exp": "4"
"exp": "\u20684\u2069"
},
{
"description": "name = [bidi] name-start *name-char [bidi]",
"src": ".local $\u200Efoo\u200F = {5} {{{$foo}}}",
"exp": "5"
"exp": "\u20685\u2069"
},
{
"description": "name = [bidi] name-start *name-char [bidi]",
Expand Down
1 change: 1 addition & 0 deletions test/tests/functions/date.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scenario": "Date function",
"description": "The built-in formatter for dates.",
"defaultTestProperties": {
"bidiIsolation": "none",
"locale": "en-US",
"expErrors": false
},
Expand Down
1 change: 1 addition & 0 deletions test/tests/functions/datetime.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scenario": "Datetime function",
"description": "The built-in formatter for datetimes.",
"defaultTestProperties": {
"bidiIsolation": "none",
"locale": "en-US",
"expErrors": false
},
Expand Down
1 change: 1 addition & 0 deletions test/tests/functions/integer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scenario": "Integer function",
"description": "The built-in formatter for integers.",
"defaultTestProperties": {
"bidiIsolation": "none",
"locale": "en-US"
},
"tests": [
Expand Down
1 change: 1 addition & 0 deletions test/tests/functions/number.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scenario": "Number function",
"description": "The built-in formatter for numbers.",
"defaultTestProperties": {
"bidiIsolation": "none",
"locale": "en-US"
},
"tests": [
Expand Down
1 change: 1 addition & 0 deletions test/tests/functions/string.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scenario": "String function",
"description": "The built-in formatter for strings.",
"defaultTestProperties": {
"bidiIsolation": "none",
"locale": "en-US"
},
"tests": [
Expand Down
1 change: 1 addition & 0 deletions test/tests/functions/time.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scenario": "Time function",
"description": "The built-in formatter for times.",
"defaultTestProperties": {
"bidiIsolation": "none",
"locale": "en-US",
"expErrors": false
},
Expand Down
1 change: 1 addition & 0 deletions test/tests/syntax.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scenario": "Syntax",
"description": "Test cases that do not depend on any registry definitions.",
"defaultTestProperties": {
"bidiIsolation": "none",
"locale": "en-US"
},
"tests": [
Expand Down
28 changes: 14 additions & 14 deletions test/tests/u-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"scenario": "u: Options",
"description": "Common options affecting the function context",
"defaultTestProperties": {
"bidiIsolation": "default",
"locale": "en-US"
},
"tests": [
Expand All @@ -24,7 +25,7 @@
"type": "markup",
"kind": "close",
"id": "x",
"name": "tag"
"name": "ns:tag"
}
]
},
Expand All @@ -45,7 +46,7 @@
{
"type": "markup",
"kind": "close",
"name": "tag"
"name": "ns:tag"
}
]
},
Expand Down Expand Up @@ -74,32 +75,31 @@
"src": "hello {world :string u:dir=rtl}",
"exp": "hello \u2067world\u2069",
"expParts": [
{
"type": "literal",
"value": "hello "
},
{ "type": "literal", "value": "hello " },
{ "type": "bidiIsolation", "value": "\u2067" },
{
"type": "string",
"source": "|world|",
"dir": "rtl",
"locale": "en-US",
"value": "world"
}
},
{ "type": "bidiIsolation", "value": "\u2069" }
]
},
{
"src": "hello {world :string u:dir=auto}",
"exp": "hello \u2068world\u2069",
"expParts": [
{
"type": "literal",
"value": "hello "
},
{ "type": "literal", "value": "hello " },
{ "type": "bidiIsolation", "value": "\u2068" },
{
"type": "string",
"source": "|world|",
"dir": "auto",
"locale": "en-US",
"value": "world"
}
},
{ "type": "bidiIsolation", "value": "\u2069" }
]
},
{
Expand All @@ -120,7 +120,7 @@
{
"locale": "ar",
"src": "أهلاً {بالعالم :string}",
"exp": "أهلاً \u2067بالعالم\u2069"
"exp": "أهلاً \u2068بالعالم\u2069"
}
]
}

0 comments on commit 313bc38

Please sign in to comment.