Skip to content

Commit 45b7e41

Browse files
mihnitaeemeliaphillips
authored
Make expErrors use an array (and only an array) (#1076)
* Issue 993: make expErrors only * Adding `expErrors` values for fallback.json * Update test/README.md Co-authored-by: Eemeli Aro <[email protected]> * Update test/README.md Co-authored-by: Eemeli Aro <[email protected]> * Update test/tests/fallback.json Co-authored-by: Eemeli Aro <[email protected]> * Update test/tests/fallback.json Co-authored-by: Eemeli Aro <[email protected]> * Update test/tests/fallback.json Co-authored-by: Eemeli Aro <[email protected]> * Update test/tests/fallback.json Co-authored-by: Eemeli Aro <[email protected]> * Fix 'Bad Operand' to 'Bad Option' * Update test/README.md Co-authored-by: Addison Phillips <[email protected]> * Fix test case with proper error code * Fix test case with proper error code --------- Co-authored-by: Eemeli Aro <[email protected]> Co-authored-by: Addison Phillips <[email protected]>
1 parent 61c470d commit 45b7e41

File tree

7 files changed

+39
-35
lines changed

7 files changed

+39
-35
lines changed

test/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ the behaviour of calling it as the `rv` value of Match(`rv`, `key`)
155155
depends on its `Input`, `DecimalPlaces` and `FailsSelect` values.
156156
157157
- If `FailsSelect` is `true`,
158-
calling the method will emit a _Message Function Error_
158+
calling the method will emit a _Bad Option_ error
159159
and not return any value.
160160
- If the `Input` is 1 and `DecimalPlaces` is 1,
161161
the method will return true for either `'1.0'` or `'1'`,
@@ -193,8 +193,14 @@ rather than being concatenated into a single string.
193193
194194
If `FailsFormat` is `true`,
195195
attempting to format the _placeholder_ to any formatting target will
196-
emit a _Message Function Error_.
197-
196+
emit a _Bad Option_ error.
197+
198+
> Note that emitting _Bad Option_ here does not indicate an incorrect option.
199+
> Actual functions in your implementation might emit
200+
> an implementation-defined or platform-specific runtime error or exception
201+
> when the function handler is called.
202+
> Your implementation might thus produce a _Message Function Error_
203+
> not provided with a label in the JSON Schema of this test suite.
198204
### `:test:select`
199205
200206
This _function_ accepts the same _operands_ and _options_,

test/schemas/v0/tests.schema.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,7 @@
382382
},
383383
"expErrors": {
384384
"description": "The runtime errors expected to be emitted when formatting the message. If expErrors is either absent or empty, the message must be formatted without errors.",
385-
"type": [
386-
"array",
387-
"boolean"
388-
],
385+
"type": "array",
389386
"items": {
390387
"type": "object",
391388
"additionalProperties": false,

test/tests/fallback.json

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,59 @@
44
"description": "Test cases for fallback behaviour.",
55
"defaultTestProperties": {
66
"bidiIsolation": "none",
7-
"locale": "en-US",
8-
"expErrors": true
7+
"locale": "en-US"
98
},
109
"tests": [
1110
{
1211
"description": "function with unquoted literal operand",
1312
"src": "{42 :test:function fails=format}",
1413
"exp": "{|42|}",
15-
"expParts": [{ "type": "fallback", "source": "|42|" }]
14+
"expParts": [{ "type": "fallback", "source": "|42|" }],
15+
"expErrors": [{ "type": "bad-option" }]
1616
},
1717
{
1818
"description": "function with quoted literal operand",
1919
"src": "{|C:\\\\| :test:function fails=format}",
20-
"exp": "{|C:\\\\|}"
20+
"exp": "{|C:\\\\|}",
21+
"expErrors": [{ "type": "bad-operand" }]
2122
},
2223
{
2324
"description": "unannotated implicit input variable",
2425
"src": "{$var}",
25-
"exp": "{$var}"
26+
"exp": "{$var}",
27+
"expErrors": [{ "type": "unresolved-variable" }]
2628
},
2729
{
2830
"description": "annotated implicit input variable",
2931
"src": "{$var :number}",
3032
"exp": "{$var}",
31-
"expParts": [{ "type": "fallback", "source": "$var" }]
33+
"expParts": [{ "type": "fallback", "source": "$var" }],
34+
"expErrors": [{ "type": "unresolved-variable" }, { "type": "bad-operand" }]
3235
},
3336
{
3437
"description": "local variable with unknown function in declaration",
3538
"src": ".local $var = {|val| :test:undefined} {{{$var}}}",
36-
"exp": "{$var}"
39+
"exp": "{$var}",
40+
"expErrors": [{ "type": "unknown-function" }]
3741
},
3842
{
3943
"description": "function with local variable operand with unknown function in declaration",
4044
"src": ".local $var = {|val| :test:undefined} {{{$var :test:function}}}",
41-
"exp": "{$var}"
45+
"exp": "{$var}",
46+
"expErrors": [{ "type": "unknown-function" }, { "type": "bad-operand" }]
4247
},
4348
{
4449
"description": "local variable with unknown function in placeholder",
4550
"src": ".local $var = {|val|} {{{$var :test:undefined}}}",
46-
"exp": "{$var}"
51+
"exp": "{$var}",
52+
"expErrors": [{ "type": "unknown-function" }]
4753
},
4854
{
4955
"description": "function with no operand",
5056
"src": "{:test:undefined}",
5157
"exp": "{:test:undefined}",
52-
"expParts": [{ "type": "fallback", "source": ":test:undefined" }]
58+
"expParts": [{ "type": "fallback", "source": ":test:undefined" }],
59+
"expErrors": [{ "type": "unknown-function" }]
5360
}
5461
]
5562
}

test/tests/functions/currency.json

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "The built-in formatter and selector for currencies.",
55
"defaultTestProperties": {
66
"bidiIsolation": "none",
7-
"locale": "en-US"
7+
"locale": "en-US",
8+
"expErrors": []
89
},
910
"tests": [
1011
{
@@ -24,33 +25,26 @@
2425
"expErrors": [{ "type": "bad-operand" }]
2526
},
2627
{
27-
"src": "{42 :currency currency=EUR}",
28-
"expErrors": false
28+
"src": "{42 :currency currency=EUR}"
2929
},
3030
{
31-
"src": ".local $n = {42 :number} {{{$n :currency currency=EUR}}}",
32-
"expErrors": false
31+
"src": ".local $n = {42 :number} {{{$n :currency currency=EUR}}}"
3332
},
3433
{
35-
"src": ".local $n = {42 :integer} {{{$n :currency currency=EUR}}}",
36-
"expErrors": false
34+
"src": ".local $n = {42 :integer} {{{$n :currency currency=EUR}}}"
3735
},
3836
{
39-
"src": ".local $n = {42 :currency currency=EUR} {{{$n :currency}}}",
40-
"expErrors": false
37+
"src": ".local $n = {42 :currency currency=EUR} {{{$n :currency}}}"
4138
},
4239
{
43-
"src": "{42 :currency currency=EUR fractionDigits=auto}",
44-
"expErrors": false
40+
"src": "{42 :currency currency=EUR fractionDigits=auto}"
4541
},
4642
{
47-
"src": "{42 :currency currency=EUR fractionDigits=2}",
48-
"expErrors": false
43+
"src": "{42 :currency currency=EUR fractionDigits=2}"
4944
},
5045
{
5146
"src": "{$x :currency currency=EUR}",
52-
"params": [{ "name": "x", "value": 41 }],
53-
"expErrors": false
47+
"params": [{ "name": "x", "value": 41 }]
5448
},
5549
{
5650
"src": ".local $n = {42 :currency currency=EUR} .match $n * {{other}}",

test/tests/functions/date.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"defaultTestProperties": {
66
"bidiIsolation": "none",
77
"locale": "en-US",
8-
"expErrors": false
8+
"expErrors": []
99
},
1010
"tests": [
1111
{

test/tests/functions/datetime.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"defaultTestProperties": {
66
"bidiIsolation": "none",
77
"locale": "en-US",
8-
"expErrors": false
8+
"expErrors": []
99
},
1010
"tests": [
1111
{

test/tests/functions/time.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"defaultTestProperties": {
66
"bidiIsolation": "none",
77
"locale": "en-US",
8-
"expErrors": false
8+
"expErrors": []
99
},
1010
"tests": [
1111
{

0 commit comments

Comments
 (0)