1+ [
2+ " Collection of Chained Arithmetic Tests" ,
3+ " Plus" ,
4+ {
5+ "description" : " Plus can be chained with other operators" ,
6+ "rule" : { "+" : { "val" : " arr" } },
7+ "data" : { "arr" : [1 , 2 , 3 ] },
8+ "result" : 6
9+ },
10+ {
11+ "description" : " Plus can be chained with other operators (2)" ,
12+ "rule" : { "+" : { "merge" : [[1 , 2 ], 3 , [4 , 5 ]] } },
13+ "data" : null ,
14+ "result" : 15
15+ },
16+ {
17+ "description" : " Plus can be chained with other operators (3)" ,
18+ "rule" : { "+" : { "map" : [{ "val" : " people" }, { "val" : " age" }] } },
19+ "data" : {
20+ "people" : [
21+ { "name" : " John" , "age" : 30 },
22+ { "name" : " Jane" , "age" : 25 },
23+ { "name" : " Bob" , "age" : 35 },
24+ { "name" : " Alice" , "age" : 28 }
25+ ]
26+ },
27+ "result" : 118
28+ },
29+ " Multiply" ,
30+ {
31+ "description" : " Multiply can be chained with other operators" ,
32+ "rule" : { "*" : { "val" : " arr" } },
33+ "data" : { "arr" : [1 , 2 , 3 ] },
34+ "result" : 6
35+ },
36+ {
37+ "description" : " Multiply can be chained with other operators (2)" ,
38+ "rule" : { "*" : { "merge" : [[1 , 2 ], 3 , [4 , 5 ]] } },
39+ "data" : null ,
40+ "result" : 120
41+ },
42+ {
43+ "description" : " Multiply can be chained with other operators (3)" ,
44+ "rule" : { "*" : { "map" : [{ "val" : " arr" }, { "val" : " x" }] } },
45+ "data" : {
46+ "arr" : [
47+ { "x" : 30 },
48+ { "x" : 25 },
49+ { "x" : 35 },
50+ { "x" : 28 }
51+ ]
52+ },
53+ "result" : 735000
54+ },
55+ " Minus" ,
56+ {
57+ "description" : " Minus can be chained with other operators" ,
58+ "rule" : { "-" : { "val" : " arr" } },
59+ "data" : { "arr" : [10 , 7 ] },
60+ "result" : 3
61+ },
62+ {
63+ "description" : " Minus can be chained with other operators (2)" ,
64+ "rule" : { "-" : { "merge" : [[1 ], 5 ] } },
65+ "data" : null ,
66+ "result" : -4
67+ },
68+ {
69+ "description" : " Minus can be chained with other operators (3)" ,
70+ "rule" : { "-" : { "map" : [{ "val" : " people" }, { "val" : " age" }] } },
71+ "data" : {
72+ "people" : [
73+ { "name" : " John" , "age" : 30 },
74+ { "name" : " Jane" , "age" : 25 },
75+ { "name" : " Bob" , "age" : 35 },
76+ { "name" : " Alice" , "age" : 28 }
77+ ]
78+ },
79+ "result" : -58
80+ },
81+ " Divide" ,
82+ {
83+ "description" : " Divide can be chained with other operators" ,
84+ "rule" : { "/" : { "val" : " arr" } },
85+ "data" : { "arr" : [10 , 5 ] },
86+ "result" : 2
87+ },
88+ {
89+ "description" : " Divide can be chained with other operators (2)" ,
90+ "rule" : { "/" : { "merge" : [[20 ], 5 ] } },
91+ "data" : null ,
92+ "result" : 4
93+ },
94+ {
95+ "description" : " Divide can be chained with other operators (3)" ,
96+ "rule" : { "/" : { "map" : [{ "val" : " arr" }, { "val" : " x" }] } },
97+ "data" : {
98+ "arr" : [
99+ { "x" : 16 },
100+ { "x" : 2 },
101+ { "x" : 2 },
102+ { "x" : 2 }
103+ ]
104+ },
105+ "result" : 2
106+ },
107+ " Modulo" ,
108+ {
109+ "description" : " Modulo can be chained with other operators" ,
110+ "rule" : { "%" : { "val" : " arr" } },
111+ "data" : { "arr" : [10 , 3 ] },
112+ "result" : 1
113+ },
114+ {
115+ "description" : " Modulo can be chained with other operators (2)" ,
116+ "rule" : { "%" : { "merge" : [[20 ], 3 ] } },
117+ "data" : null ,
118+ "result" : 2
119+ },
120+ {
121+ "description" : " Modulo can be chained with other operators (3)" ,
122+ "rule" : { "%" : { "map" : [{ "val" : " arr" }, { "val" : " x" }] } },
123+ "data" : {
124+ "arr" : [
125+ { "x" : 17 },
126+ { "x" : 4 }
127+ ]
128+ },
129+ "result" : 1
130+ }
131+ ]
0 commit comments