-
-
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 a :math function, for addition and subtraction (#932)
* Add a :math function, for addition and subtraction * Clarify utility note Co-authored-by: Addison Phillips <addison@unicode.org> * Add note on integer overflow Co-authored-by: Addison Phillips <addison@unicode.org> --------- Co-authored-by: Addison Phillips <addison@unicode.org>
- Loading branch information
Showing
2 changed files
with
148 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json", | ||
"scenario": "Math function", | ||
"description": "The built-in formatter and selector for addition and subtraction.", | ||
"defaultTestProperties": { | ||
"bidiIsolation": "none", | ||
"locale": "en-US" | ||
}, | ||
"tests": [ | ||
{ | ||
"src": "{:math add=13}", | ||
"expErrors": [{ "type": "bad-operand" }] | ||
}, | ||
{ | ||
"src": "{foo :math add=13}", | ||
"expErrors": [{ "type": "bad-operand" }] | ||
}, | ||
{ | ||
"src": "{42 :math}", | ||
"expErrors": [{ "type": "bad-option" }] | ||
}, | ||
{ | ||
"src": "{42 :math add=foo}", | ||
"expErrors": [{ "type": "bad-option" }] | ||
}, | ||
{ | ||
"src": "{42 :math subtract=foo}", | ||
"expErrors": [{ "type": "bad-option" }] | ||
}, | ||
{ | ||
"src": "{42 :math foo=13}", | ||
"expErrors": [{ "type": "bad-option" }] | ||
}, | ||
{ | ||
"src": "{42 :math add=13 subtract=13}", | ||
"expErrors": [{ "type": "bad-option" }] | ||
}, | ||
{ | ||
"src": "{41 :math add=1}", | ||
"exp": "42" | ||
}, | ||
{ | ||
"src": "{52 :math subtract=10}", | ||
"exp": "42" | ||
}, | ||
{ | ||
"src": "{41 :math add=1 foo=13}", | ||
"exp": "42" | ||
}, | ||
{ | ||
"src": ".local $x = {41 :integer signDisplay=always} {{{$x :math add=1}}}", | ||
"exp": "+42" | ||
}, | ||
{ | ||
"src": ".local $x = {52 :number signDisplay=always} {{{$x :math subtract=10}}}", | ||
"exp": "+42" | ||
}, | ||
{ | ||
"src": "{$x :math add=1}", | ||
"params": [{ "name": "x", "value": 41 }], | ||
"exp": "42" | ||
}, | ||
{ | ||
"src": "{$x :math subtract=10}", | ||
"params": [{ "name": "x", "value": 52 }], | ||
"exp": "42" | ||
}, | ||
{ | ||
"src": ".local $x = {1 :math add=1} .match $x 1 {{=1}} 2 {{=2}} * {{other}}", | ||
"exp": "=2" | ||
}, | ||
{ | ||
"src": ".local $x = {10 :integer} .local $y = {$x :math subtract=6} .match $y 10 {{=10}} 4 {{=4}} * {{other}}", | ||
"exp": "=4" | ||
} | ||
] | ||
} |