Skip to content

In test suite, drop source from non-fallback formatted parts #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/validate_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
paths:
- test/**
pull_request:
branches: '**'
paths:
- test/**

Expand All @@ -22,7 +21,7 @@ jobs:
run: npm install --global ajv-cli
- name: Validate tests using the latest schema version
run: >
ajv validate --spec=draft2020
ajv validate --spec=draft2020 --allow-union-types
-s $(ls -1v schemas/*/*schema.json | tail -1)
-d 'tests/**/*.json'
working-directory: ./test
51 changes: 32 additions & 19 deletions test/schemas/v0/tests.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
{
"properties": {
"defaultTestProperties": {
"type": "object",
"required": [
"locale"
]
Expand All @@ -50,6 +51,7 @@
"tests": {
"type": "array",
"items": {
"type": "object",
"required": [
"locale"
]
Expand All @@ -64,6 +66,7 @@
{
"properties": {
"defaultTestProperties": {
"type": "object",
"required": [
"src"
]
Expand All @@ -75,6 +78,7 @@
"tests": {
"type": "array",
"items": {
"type": "object",
"required": [
"src"
]
Expand Down Expand Up @@ -290,9 +294,6 @@
"close"
]
},
"source": {
"type": "string"
},
"name": {
"type": "string"
},
Expand All @@ -308,23 +309,21 @@
"description": "Message expression part.",
"type": "object",
"required": [
"type",
"source"
"type"
],
"not": {
"required": [
"parts",
"value"
]
},
"properties": {
"type": {
"type": "string"
"enum": [
"datetime",
"number",
"string",
"test"
]
},
"source": {
"locale": {
"type": "string"
},
"locale": {
"id": {
"type": "string"
},
"parts": {
Expand All @@ -334,11 +333,7 @@
"properties": {
"type": {
"type": "string"
},
"source": {
"type": "string"
},
"value": {}
}
},
"required": [
"type"
Expand All @@ -347,6 +342,23 @@
},
"value": {}
}
},
{
"description": "Fallback part.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be more verbose with the descriptions? They're here as documentation, after all...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is literally a fallback part, i.e. the result of formatting a value that experienes fallback. I don't really know what else to say about it?

"type": "object",
"additionalProperties": false,
"required": [
"type",
"source"
],
"properties": {
"type": {
"const": "fallback"
},
"source": {
"type": "string"
}
}
}
]
}
Expand Down Expand Up @@ -385,6 +397,7 @@
}
},
"anyExp": {
"type": "object",
"anyOf": [
{
"required": [
Expand Down
1 change: 1 addition & 0 deletions test/tests/bidi.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../schemas/v0/tests.schema.json",
"scenario": "Bidi support",
"description": "Tests for correct parsing of messages with bidirectional marks and isolates",
"defaultTestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/data-model-errors.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../schemas/v0/tests.schema.json",
"scenario": "Data model errors",
"defaultTestProperties": {
"locale": "en-US"
Expand Down
11 changes: 7 additions & 4 deletions test/tests/fallback.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../schemas/v0/tests.schema.json",
"scenario": "Fallback",
"description": "Test cases for fallback behaviour.",
"defaultTestProperties": {
Expand All @@ -11,7 +11,8 @@
{
"description": "function with unquoted literal operand",
"src": "{42 :test:function fails=format}",
"exp": "{|42|}"
"exp": "{|42|}",
"expParts": [{ "type": "fallback", "source": "|42|" }]
},
{
"description": "function with quoted literal operand",
Expand All @@ -26,7 +27,8 @@
{
"description": "annotated implicit input variable",
"src": "{$var :number}",
"exp": "{$var}"
"exp": "{$var}",
"expParts": [{ "type": "fallback", "source": "$var" }]
},
{
"description": "local variable with unknown function in declaration",
Expand All @@ -46,7 +48,8 @@
{
"description": "function with no operand",
"src": "{:test:undefined}",
"exp": "{:test:undefined}"
"exp": "{:test:undefined}",
"expParts": [{ "type": "fallback", "source": ":test:undefined" }]
}
]
}
2 changes: 1 addition & 1 deletion test/tests/functions/currency.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../../schemas/v0/tests.schema.json",
"scenario": "Currency function",
"description": "The built-in formatter and selector for currencies.",
"defaultTestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/functions/date.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../../schemas/v0/tests.schema.json",
"scenario": "Date function",
"description": "The built-in formatter for dates.",
"defaultTestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/functions/datetime.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../../schemas/v0/tests.schema.json",
"scenario": "Datetime function",
"description": "The built-in formatter for datetimes.",
"defaultTestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/functions/integer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../../schemas/v0/tests.schema.json",
"scenario": "Integer function",
"description": "The built-in formatter for integers.",
"defaultTestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/functions/math.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../../schemas/v0/tests.schema.json",
"scenario": "Math function",
"description": "The built-in formatter and selector for addition and subtraction.",
"defaultTestProperties": {
Expand Down
10 changes: 2 additions & 8 deletions test/tests/functions/number.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../../schemas/v0/tests.schema.json",
"scenario": "Number function",
"description": "The built-in formatter for numbers.",
"defaultTestProperties": {
Expand Down Expand Up @@ -326,13 +326,7 @@
"expParts": [
{
"type": "number",
"source": "|42|",
"parts": [
{
"type": "integer",
"value": "42"
}
]
"parts": [{ "type": "integer", "value": "42" }]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion test/tests/functions/string.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../../schemas/v0/tests.schema.json",
"scenario": "String function",
"description": "The built-in formatter for strings.",
"defaultTestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/functions/time.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../../schemas/v0/tests.schema.json",
"scenario": "Time function",
"description": "The built-in formatter for times.",
"defaultTestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/pattern-selection.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../schemas/v0/tests.schema.json",
"scenario": "Pattern selection",
"description": "Tests for pattern selection",
"defaultTestProperties": {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/syntax-errors.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../schemas/v0/tests.schema.json",
"scenario": "Syntax errors",
"description": "Strings that produce syntax errors when parsed.",
"defaultTestProperties": {
Expand Down
18 changes: 3 additions & 15 deletions test/tests/syntax.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../schemas/v0/tests.schema.json",
"scenario": "Syntax",
"description": "Test cases that do not depend on any registry definitions.",
"defaultTestProperties": {
Expand Down Expand Up @@ -412,13 +412,7 @@
"description": "... attribute -> \"@\" identifier s \"=\" s quoted-literal ...",
"src": "{42 @foo=|bar|}",
"exp": "42",
"expParts": [
{
"type": "string",
"source": "|42|",
"value": "42"
}
]
"expParts": [{ "type": "string", "value": "42" }]
},
{
"description": "... quoted-literal",
Expand Down Expand Up @@ -722,13 +716,7 @@
{
"src": "{42 @foo @bar=13}",
"exp": "42",
"expParts": [
{
"type": "string",
"source": "|42|",
"value": "42"
}
]
"expParts": [{ "type": "string", "value": "42" }]
},
{
"src": "{{trailing whitespace}} \n",
Expand Down
27 changes: 4 additions & 23 deletions test/tests/u-options.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json",
"$schema": "../schemas/v0/tests.schema.json",
"scenario": "u: Options",
"description": "Common options affecting the function context",
"defaultTestProperties": {
Expand Down Expand Up @@ -54,13 +54,7 @@
"expParts": [
{ "type": "text", "value": "hello " },
{ "type": "bidiIsolation", "value": "\u2066" },
{
"type": "string",
"source": "|world|",
"dir": "ltr",
"id": "foo",
"value": "world"
},
{ "type": "string", "dir": "ltr", "id": "foo", "value": "world" },
{ "type": "bidiIsolation", "value": "\u2069" }

]
Expand All @@ -71,13 +65,7 @@
"expParts": [
{ "type": "text", "value": "hello " },
{ "type": "bidiIsolation", "value": "\u2067" },
{
"type": "string",
"source": "|world|",
"dir": "rtl",
"locale": "en-US",
"value": "world"
},
{ "type": "string", "dir": "rtl", "locale": "en-US", "value": "world" },
{ "type": "bidiIsolation", "value": "\u2069" }
]
},
Expand All @@ -89,7 +77,6 @@
{ "type": "bidiIsolation", "value": "\u2068" },
{
"type": "string",
"source": "|world|",
"locale": "en-US",
"value": "world"
},
Expand All @@ -102,13 +89,7 @@
"expParts": [
{ "type": "text", "value": "hello " },
{ "type": "bidiIsolation", "value": "\u2066" },
{
"type": "string",
"source": "|world|",
"dir": "ltr",
"id": "foo",
"value": "world"
},
{ "type": "string", "dir": "ltr", "id": "foo", "value": "world" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to lose the formatting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that this is on a single line, rather than the multiple lines it had previously? It's because with the change, it's now short enough to easily fit on a single line.

{ "type": "bidiIsolation", "value": "\u2069" }
]
},
Expand Down