Skip to content

Commit bcc0de7

Browse files
committed
Break up some of the tests into different files
1 parent 38599d2 commit bcc0de7

File tree

4 files changed

+137
-51
lines changed

4 files changed

+137
-51
lines changed

suites/errors.json

-51
This file was deleted.

suites/panic.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"description": "Can promote a soft error to a hard error with panic",
4+
"rule": { "panic": { "error": "Some error" } },
5+
"error": true,
6+
"data": null
7+
},
8+
{
9+
"description": "Panic with an error emitted from an operator",
10+
"rule": { "panic": [{ "/": [1, 0] }] },
11+
"error": true,
12+
"data": null
13+
},
14+
{
15+
"description": "Panic with an error pulled from context",
16+
"rule": { "panic": [{ "val": "x" }] },
17+
"error": true,
18+
"data": { "x": { "error": "Some error" } }
19+
}
20+
]

suites/truthiness.json

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
[
2+
"# This can also be seen as a test suite for !!",
3+
"# Primitive Truthiness tests",
4+
{
5+
"description": "Truthy: true",
6+
"rule": { "!!": true },
7+
"result": true,
8+
"data": null
9+
},
10+
{
11+
"description": "Falsey: false",
12+
"rule": { "!!": false },
13+
"result": false,
14+
"data": null
15+
},
16+
{
17+
"description": "Truthy: 1",
18+
"rule": { "!!": 1 },
19+
"result": true,
20+
"data": null
21+
},
22+
{
23+
"description": "Falsey: 0",
24+
"rule": { "!!": 0 },
25+
"result": false,
26+
"data": null
27+
},
28+
{
29+
"description": "Truthy: -1",
30+
"rule": { "!!": -1 },
31+
"result": true,
32+
"data": null
33+
},
34+
{
35+
"description": "Falsey: []",
36+
"rule": { "!!": [[]] },
37+
"result": false,
38+
"data": null
39+
},
40+
{
41+
"description": "Truthy: {}",
42+
"rule": { "!!": [{}] },
43+
"result": true,
44+
"data": null
45+
},
46+
{
47+
"description": "Falsey: ''",
48+
"rule": { "!!": "" },
49+
"result": false,
50+
"data": null
51+
},
52+
{
53+
"description": "Falsey: null",
54+
"rule": { "!!": null },
55+
"result": false,
56+
"data": null
57+
},
58+
"# Some error tests",
59+
{
60+
"description": "Truthy: NaN",
61+
"rule": { "!!": { "error": "NaN" } },
62+
"result": true,
63+
"data": null
64+
},
65+
{
66+
"description": "Truthy: Arbitrary error",
67+
"rule": { "!!": { "error": "Some error" } },
68+
"result": true,
69+
"data": null
70+
},
71+
"# Context Object Tests",
72+
{
73+
"description": "Truthy: Zero Key Object",
74+
"rule": { "!!": { "val": "obj" } },
75+
"result": true,
76+
"data": { "obj": {} }
77+
},
78+
{
79+
"description": "Truthy: Single Key Object",
80+
"rule": { "!!": { "val": "obj" } },
81+
"result": true,
82+
"data": { "obj": { "a": 0 } }
83+
},
84+
{
85+
"description": "Truthy: Multi Key Object",
86+
"rule": { "!!": { "val": "obj" } },
87+
"result": true,
88+
"data": { "obj": { "a": 0, "b": 0 } }
89+
},
90+
{
91+
"description": "Truthy: Single Key Object (Empty Key)",
92+
"rule": { "!!": { "val": "obj" } },
93+
"result": true,
94+
"data": { "obj": { "": 0 } }
95+
}
96+
]

suites/try.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
"# Collection of Tests for Try",
3+
{
4+
"description": "Coalesce an error",
5+
"rule": { "try": [{ "error": "Some error" }, 1] },
6+
"result": 1,
7+
"data": null
8+
},
9+
{
10+
"description": "Coalesce an error emitted from an operator",
11+
"rule": { "try": [{ "/": [0, 0]}, 1] },
12+
"result": 1,
13+
"data": { "hello": "world" }
14+
},
15+
{
16+
"description": "Coalesce an error pulled from context; errors are just data.",
17+
"rule": { "try": [{ "val": "x" }, 1]},
18+
"data": { "x": { "error": "Some error" }},
19+
"result": 1
20+
}
21+
]

0 commit comments

Comments
 (0)