-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for pattern selection (#863)
* Add tests for pattern selection * Add missing errors * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> --------- Co-authored-by: Addison Phillips <[email protected]>
- Loading branch information
Showing
3 changed files
with
179 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json", | ||
"scenario": "Pattern selection", | ||
"description": "Tests for pattern selection", | ||
"defaultTestProperties": { | ||
"locale": "und" | ||
}, | ||
"tests": [ | ||
{ | ||
"src": ".match {1 :test:select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"exp": "1" | ||
}, | ||
{ | ||
"src": ".match {0 :test:select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"exp": "other" | ||
}, | ||
{ | ||
"src": ".match {$x :test:select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "1" | ||
}, | ||
{ | ||
"src": ".match {$x :test:select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 2 }], | ||
"exp": "other" | ||
}, | ||
{ | ||
"src": ".input {$x} .match {$x :test:select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "1" | ||
}, | ||
{ | ||
"src": ".input {$x} .match {$x :test:select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 2 }], | ||
"exp": "other" | ||
}, | ||
{ | ||
"src": ".input {$x :test:select} .match {$x} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "1" | ||
}, | ||
{ | ||
"src": ".input {$x :test:select} .match {$x} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 2 }], | ||
"exp": "other" | ||
}, | ||
{ | ||
"src": ".input {$x :test:select} .local $y = {$x} .match {$y} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "1" | ||
}, | ||
{ | ||
"src": ".input {$x :test:select} .local $y = {$x} .match {$y} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 2 }], | ||
"exp": "other" | ||
}, | ||
{ | ||
"src": ".match {1 :test:select decimalPlaces=1} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"exp": "1.0" | ||
}, | ||
{ | ||
"src": ".match {1 :test:select decimalPlaces=1} 1 {{1}} 1.0 {{1.0}} * {{other}}", | ||
"exp": "1.0" | ||
}, | ||
{ | ||
"src": ".match {1 :test:select decimalPlaces=9} 1.0 {{1.0}} 1 {{1}} * {{bad-option-value}}", | ||
"exp": "bad-option-value", | ||
"expErrors": [{ "type": "bad-option" }, { "type": "bad-selector" }] | ||
}, | ||
{ | ||
"src": ".input {$x :test:select} .match {$x :test:select decimalPlaces=1} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "1.0" | ||
}, | ||
{ | ||
"src": ".input {$x :test:select decimalPlaces=1} .match {$x :test:select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "1.0" | ||
}, | ||
{ | ||
"src": ".input {$x :test:select} .local $y = {$x :test:select decimalPlaces=1} .match {$y} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "1.0" | ||
}, | ||
{ | ||
"src": ".input {$x :test:select decimalPlaces=1} .local $y = {$x :test:select} .match {$y} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "1.0" | ||
}, | ||
{ | ||
"src": ".input {$x :test:select decimalPlaces=9} .match {$x :test:select decimalPlaces=1} 1.0 {{1.0}} 1 {{1}} * {{bad-option-value}}", | ||
"params": [{ "name": "x", "value": 1 }], | ||
"exp": "bad-option-value", | ||
"expErrors": [ | ||
{ "type": "bad-option" }, | ||
{ "type": "bad-operand" }, | ||
{ "type": "bad-selector" } | ||
] | ||
}, | ||
{ | ||
"src": ".match {1 :test:select fails=select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"exp": "other", | ||
"expErrors": [{ "type": "bad-selector" }] | ||
}, | ||
{ | ||
"src": ".match {1 :test:select fails=format} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"exp": "1" | ||
}, | ||
{ | ||
"src": ".match {1 :test:format} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"exp": "other", | ||
"expErrors": [{ "type": "bad-selector" }] | ||
}, | ||
{ | ||
"src": ".match {$x :test:select} 1.0 {{1.0}} 1 {{1}} * {{other}}", | ||
"exp": "other", | ||
"expErrors": [ | ||
{ "type": "unresolved-variable" }, | ||
{ "type": "bad-operand" }, | ||
{ "type": "bad-selector" } | ||
] | ||
}, | ||
{ | ||
"src": ".match {1 :test:select} {1 :test:select} 1 1 {{1,1}} 1 * {{1,*}} * 1 {{*,1}} * * {{*,*}}", | ||
"exp": "1,1" | ||
}, | ||
{ | ||
"src": ".match {1 :test:select} {0 :test:select} 1 1 {{1,1}} 1 * {{1,*}} * 1 {{*,1}} * * {{*,*}}", | ||
"exp": "1,*" | ||
}, | ||
{ | ||
"src": ".match {0 :test:select} {1 :test:select} 1 1 {{1,1}} 1 * {{1,*}} * 1 {{*,1}} * * {{*,*}}", | ||
"exp": "*,1" | ||
}, | ||
{ | ||
"src": ".match {0 :test:select} {0 :test:select} 1 1 {{1,1}} 1 * {{1,*}} * 1 {{*,1}} * * {{*,*}}", | ||
"exp": "*,*" | ||
}, | ||
{ | ||
"src": ".match {1 :test:select fails=select} {1 :test:select} 1 1 {{1,1}} 1 * {{1,*}} * 1 {{*,1}} * * {{*,*}}", | ||
"exp": "*,1", | ||
"expErrors": [{ "type": "bad-selector" }] | ||
}, | ||
{ | ||
"src": ".match {1 :test:select} {1 :test:format} 1 1 {{1,1}} 1 * {{1,*}} * 1 {{*,1}} * * {{*,*}}", | ||
"exp": "1,*", | ||
"expErrors": [{ "type": "bad-selector" }] | ||
} | ||
] | ||
} |