Skip to content

Commit 25daac8

Browse files
committed
Add some additional test cases
1 parent c853a03 commit 25daac8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

suites/try.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
"result": 1,
1313
"data": { "hello": "world" }
1414
},
15+
{
16+
"description": "Try is variadic",
17+
"rule": { "try": [{ "error": "Some error" }, { "/": [0, 0] }, 2] },
18+
"result": 2,
19+
"data": null
20+
},
1521
{
1622
"description": "Panics if none of the values are valid",
1723
"rule": { "try": [{ "error": "Some error" }, { "error": "Some other error" }] },
@@ -24,6 +30,12 @@
2430
"error": true,
2531
"data": null
2632
},
33+
{
34+
"description": "Panics if none of the values are valid (3)",
35+
"rule": { "try": [{ "/": [0, 0] }, { "/": [1, 0] }, { "/": [2, 0] }] },
36+
"error": true,
37+
"data": null
38+
},
2739
{
2840
"description": "Can promote a soft error to a hard error",
2941
"rule": { "try": { "error": "Some error" } },
@@ -64,6 +76,17 @@
6476
},
6577
{
6678
"description": "The context switches for the try coalescing to the previous error",
79+
"rule": {
80+
"try": [
81+
{ "error": "Some error" },
82+
{ "val": [] }
83+
]
84+
},
85+
"result": { "error": "Some error"},
86+
"data": null
87+
},
88+
{
89+
"description": "The context switches for the try coalescing to the previous error (2)",
6790
"rule": {
6891
"try": [
6992
{ "if": [true, { "error": "Some error" }, null] },
@@ -73,6 +96,18 @@
7396
"result": { "error": "Some error"},
7497
"data": null
7598
},
99+
{
100+
"description": "The context switches for the try coalescing to the previous error (3)",
101+
"rule": {
102+
"try": [
103+
{ "error": "A" },
104+
{ "error": "B" },
105+
{ "val": [] }
106+
]
107+
},
108+
"result": { "error": "B" },
109+
"data": null
110+
},
76111
{
77112
"description": "Try can work further up the AST with Exceptions, and return the error",
78113
"rule": {

0 commit comments

Comments
 (0)