Skip to content

Commit f5de662

Browse files
committed
Update arithmetic
1 parent e8300f7 commit f5de662

File tree

6 files changed

+123
-131
lines changed

6 files changed

+123
-131
lines changed

suites/arithmetic/chain.json

-131
This file was deleted.

suites/arithmetic/divide.json

+25
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,30 @@
189189
"rule": { "/": [8, 2, 0] },
190190
"error": { "type": "NaN" },
191191
"data": null
192+
},
193+
{
194+
"description": "Divide can be chained with other operators",
195+
"rule": { "/": { "val": "arr" } },
196+
"data": { "arr": [10, 5] },
197+
"result": 2
198+
},
199+
{
200+
"description": "Divide can be chained with other operators (2)",
201+
"rule": { "/": { "merge": [[20], 5] } },
202+
"data": null,
203+
"result": 4
204+
},
205+
{
206+
"description": "Divide can be chained with other operators (3)",
207+
"rule": { "/": { "map": [{ "val": "arr" }, { "val": "x" }] } },
208+
"data": {
209+
"arr": [
210+
{ "x": 16 },
211+
{ "x": 2 },
212+
{ "x": 2 },
213+
{ "x": 2 }
214+
]
215+
},
216+
"result": 2
192217
}
193218
]

suites/arithmetic/minus.json

+25
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,30 @@
132132
"rule": { "-": [[1], 1] },
133133
"error": { "type": "NaN" },
134134
"data": null
135+
},
136+
{
137+
"description": "Minus can be chained with other operators",
138+
"rule": { "-": { "val": "arr" } },
139+
"data": { "arr": [10, 7] },
140+
"result": 3
141+
},
142+
{
143+
"description": "Minus can be chained with other operators (2)",
144+
"rule": { "-": { "merge": [[1], 5] } },
145+
"data": null,
146+
"result": -4
147+
},
148+
{
149+
"description": "Minus can be chained with other operators (3)",
150+
"rule": { "-": { "map": [{ "val": "people" }, { "val": "age" }] } },
151+
"data": {
152+
"people": [
153+
{ "name": "John", "age": 30 },
154+
{ "name": "Jane", "age": 25 },
155+
{ "name": "Bob", "age": 35 },
156+
{ "name": "Alice", "age": 28 }
157+
]
158+
},
159+
"result": -58
135160
}
136161
]

suites/arithmetic/modulo.json

+23
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,28 @@
187187
"rule": { "%": [8, -3] },
188188
"result": 2,
189189
"data": null
190+
},
191+
{
192+
"description": "Modulo can be chained with other operators",
193+
"rule": { "%": { "val": "arr" } },
194+
"data": { "arr": [10, 3] },
195+
"result": 1
196+
},
197+
{
198+
"description": "Modulo can be chained with other operators (2)",
199+
"rule": { "%": { "merge": [[20], 3] } },
200+
"data": null,
201+
"result": 2
202+
},
203+
{
204+
"description": "Modulo can be chained with other operators (3)",
205+
"rule": { "%": { "map": [{ "val": "arr" }, { "val": "x" }] } },
206+
"data": {
207+
"arr": [
208+
{ "x": 17 },
209+
{ "x": 4 }
210+
]
211+
},
212+
"result": 1
190213
}
191214
]

suites/arithmetic/multiply.json

+25
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,30 @@
168168
"rule": { "*": [[1], 1] },
169169
"error": { "type": "NaN" },
170170
"data": null
171+
},
172+
{
173+
"description": "Multiply can be chained with other operators",
174+
"rule": { "*": { "val": "arr" } },
175+
"data": { "arr": [1, 2, 3] },
176+
"result": 6
177+
},
178+
{
179+
"description": "Multiply can be chained with other operators (2)",
180+
"rule": { "*": { "merge": [[1, 2], 3, [4, 5]] } },
181+
"data": null,
182+
"result": 120
183+
},
184+
{
185+
"description": "Multiply can be chained with other operators (3)",
186+
"rule": { "*": { "map": [{ "val": "arr" }, { "val": "x" }] } },
187+
"data": {
188+
"arr": [
189+
{ "x": 30 },
190+
{ "x": 25 },
191+
{ "x": 35 },
192+
{ "x": 28 }
193+
]
194+
},
195+
"result": 735000
171196
}
172197
]

suites/arithmetic/plus.json

+25
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,30 @@
194194
"rule": { "+": {} },
195195
"error": { "type": "NaN" },
196196
"data": null
197+
},
198+
{
199+
"description": "Plus can be chained with other operators",
200+
"rule": { "+": { "val": "arr" } },
201+
"data": { "arr": [1, 2, 3] },
202+
"result": 6
203+
},
204+
{
205+
"description": "Plus can be chained with other operators (2)",
206+
"rule": { "+": { "merge": [[1, 2], 3, [4, 5]] } },
207+
"data": null,
208+
"result": 15
209+
},
210+
{
211+
"description": "Plus can be chained with other operators (3)",
212+
"rule": { "+": { "map": [{ "val": "people" }, { "val": "age" }] } },
213+
"data": {
214+
"people": [
215+
{ "name": "John", "age": 30 },
216+
{ "name": "Jane", "age": 25 },
217+
{ "name": "Bob", "age": 35 },
218+
{ "name": "Alice", "age": 28 }
219+
]
220+
},
221+
"result": 118
197222
}
198223
]

0 commit comments

Comments
 (0)