-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add tests for pattern selection #863
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,173 +209,6 @@ | |
} | ||
] | ||
}, | ||
{ | ||
"src": ".match {$foo :number} one {{one}} * {{other}}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file tests the function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests removed from here rely on the category selection behaviour of These tests also mostly exercise the MF2 spec side of pattern selection, for which each case is now included in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably should fix these tests to use CLDR data, if that's what we want. My primary concern is not to lose tests for something that is part of our collection of specifications, even if it isn't part of MF2's core spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we keep these The spec-required parts of these tests is completely retained in the I added #868 to continue the conversation about the spec language for |
||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "one" | ||
}, | ||
{ | ||
"src": ".match {$foo :number} 1 {{=1}} one {{one}} * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "=1" | ||
}, | ||
{ | ||
"src": ".match {$foo :number} one {{one}} 1 {{=1}} * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "=1" | ||
}, | ||
{ | ||
"src": ".match {$foo :number} {$bar :number} one one {{one one}} one * {{one other}} * * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
}, | ||
{ | ||
"name": "bar", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "one one" | ||
}, | ||
{ | ||
"src": ".match {$foo :number} {$bar :number} one one {{one one}} one * {{one other}} * * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
}, | ||
{ | ||
"name": "bar", | ||
"value": 2 | ||
} | ||
], | ||
"exp": "one other" | ||
}, | ||
{ | ||
"src": ".match {$foo :number} {$bar :number} one one {{one one}} one * {{one other}} * * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 2 | ||
}, | ||
{ | ||
"name": "bar", | ||
"value": 2 | ||
} | ||
], | ||
"exp": "other" | ||
}, | ||
{ | ||
"src": ".input {$foo :number} .match {$foo} one {{one}} * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "one" | ||
}, | ||
{ | ||
"src": ".local $foo = {$bar :number} .match {$foo} one {{one}} * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "bar", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "one" | ||
}, | ||
{ | ||
"src": ".input {$foo :number} .local $bar = {$foo} .match {$bar} one {{one}} * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "one" | ||
}, | ||
{ | ||
"src": ".input {$bar :number} .match {$bar} one {{one}} * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "bar", | ||
"value": 2 | ||
} | ||
], | ||
"exp": "other" | ||
}, | ||
{ | ||
"src": ".input {$bar} .match {$bar :number} one {{one}} * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "bar", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "one" | ||
}, | ||
{ | ||
"src": ".input {$bar} .match {$bar :number} one {{one}} * {{other}}", | ||
"params": [ | ||
{ | ||
"name": "bar", | ||
"value": 2 | ||
} | ||
], | ||
"exp": "other" | ||
}, | ||
{ | ||
"src": ".input {$none} .match {$foo :number} one {{one}} * {{{$none}}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "one" | ||
}, | ||
{ | ||
"src": ".local $bar = {$none} .match {$foo :number} one {{one}} * {{{$bar}}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 1 | ||
} | ||
], | ||
"exp": "one" | ||
}, | ||
{ | ||
"src": ".local $bar = {$none} .match {$foo :number} one {{one}} * {{{$bar}}}", | ||
"params": [ | ||
{ | ||
"name": "foo", | ||
"value": 2 | ||
} | ||
], | ||
"exp": "{$none}", | ||
"expErrors": [ | ||
{ | ||
"type": "unresolved-variable" | ||
} | ||
] | ||
}, | ||
{ | ||
"src": "{42 :number @foo @bar=13}", | ||
"exp": "42", | ||
|
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" }] | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these sufficiently self-documenting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're somewhat documented by the behaviour section below. Not explicitly documenting these is also in line with what we've done for all the other functions' option values.