forked from Jukkorsis/json-logic-java
-
Notifications
You must be signed in to change notification settings - Fork 2
/
BulkTests.txt
executable file
·177 lines (142 loc) · 5.58 KB
/
BulkTests.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#Equals with Constants
{"==" : [{"var":"abc"}, false]} {"abc" : false, "c" : 42} true
{"==" : [1, 1]} true
{"==" : [1, 3]} false
{"==" : [1, "1"]} true
{"==" : [0, false]} true
#Strict Equals with Constants
{"===" : [1, 1]} true
{"===" : [1, "1"]} false
#Not Equals with Constants
{"!=" : [1, 2]} true
{"!=" : [1, "1"]} false
#Strict Not Equals with Constants
{"!==" : [1, 2]} true
{"!==" : [1, "1"]} true
#Not with Constants
{"!" : [true]} false
{"!" : [false]} true
{"!" : true} false
{"!" : false} true
#Greater Than with Constants
{">" : [3, 1]} true
{">" : [1, 1]} false
{">" : [1, 3]} false
#Greater Than Or Equal with Constants
{">=" : [8, 7]} true
{">=" : [8, 8]} true
{">=" : [8, 9]} false
#Less Than with Constants
{"<" : [2, 7]} true
{"<" : [2, 2]} false
{"<" : [7, 2]} false
#Less Than Or Equal with Constants
{"<=" : [7, 6]} false
{"<=" : [7, 7]} true
{"<=" : [7, 8]} true
#Between
{"<" : [1, 2, 3]} true
{"<" : [1, 1, 3]} false
{"<" : [1, 3, 3]} false
{"<=" : [1, 2, 3]} true
{"<=" : [1, 1, 3]} true
{"<=" : [1, 0, 3]} false
{"<=" : [1, 4, 3]} false
{ "<": [0, {"var":"temp"}, 100]} {"temp" : 37} true
#And with Constants
{"and" : [true, true]} true
{"and" : [true, false]} false
{"and" : [true, true, true]} true
{"and" : [true, true, false]} false
{"and" : [true, "a", 3]} 3
#And with Compare
{"and" : [{">" : [3,1]}, {"<" : [1,3]}]} true
{"and" : [{">" : [4,5]}, {"<" : [1,3]}]} false
{"and" : [{">" : [1,3]}, {"<" : [6,4]}]} false
{"and" : [{">" : [3,1]}, true, {"<" : [1,3]}]} true
#Or with Constants
{"or" : [true, true]} true
{"or" : [true, false]} true
{"or" : [false, false]} false
{"or" : [true, true, true]} true
{"or" : [true, false, true]} true
{"or" : [false, false, false]} false
{"or" : [false, "a"]} a
{"or" : [false, 0, "a"]} a
#Or with Compare
{"or" : [{">" : [3,1]}, {"<" : [1,3]}]} true
{"or" : [{">" : [4,5]}, {"<" : [1,3]}]} true
{"or" : [{">" : [2,7]}, {"<" : [6,4]}]} false
{"or" : [{">" : [3,1]}, {"<" : [1,3]}, {"==" : [8, 8]}]} true
#Min and Max
{"max":[1,2,3]} 3
{"min":[1,2,3]} 1
#Arithmetic
{"+":[4,2]} 6
{"+":[2,2,2,2,2]} 10
{"+":"3.14"} 3.14
{"-":[4,2]} 2
{"-":[2]} -2
{"-":[-2]} 2
{"*":[4,2]} 8
{"*":[2,2,2,2,2]} 32
{"/":[4,2]} 2
{"%":[101,2]} 1
#Simple Var
{"var" : "a"} {"a" : "good", "b" : true, "c" : 42} good
{"var" : ["a"]} {"a" : "good", "b" : true, "c" : 42} good
{"var" : "b"} {"a" : "good", "b" : true, "c" : 42} true
{"var" : ["c"]} {"a" : "good", "b" : true, "c" : 42} 42
#Var with dot notation attributes
{"var" : ["champ.name"]} {"champ" : {"name" : "Fezzig","height" : 223},"challenger" : {"name" : "Dread Pirate Roberts","height" : 183}} Fezzig
{"var" : ["challenger.height"]} {"champ" : {"name" : "Fezzig","height" : 223},"challenger" : {"name" : "Dread Pirate Roberts","height" : 183}} 183
{">" : [{"var" : ["champ.height"]}, {"var" : ["challenger.height"]}]} {"champ" : {"name" : "Fezzig","height" : 223},"challenger" : {"name" : "Dread Pirate Roberts","height" : 183}} true
{"and" : [{">" : [{"var" : ["champ.height"]}, {"var" : ["challenger.height"]}]}, {"==" : [1,1]}]} {"champ" : {"name" : "Fezzig","height" : 223},"challenger" : {"name" : "Dread Pirate Roberts","height" : 183}} true
#Var with default value
{"var":["z", 26]} {"a":1,"b":2} 26
{"var":["z", "good"]} {"a":1,"b":2} good
{"var":["z", true]} {"a":1,"b":2} true
#if operator
{"if" : [ true, "yes", "no" ]} yes
{"if" : [ false, "yes", "no" ]} no
{"if" : [{"<": [{"var":"temp"}, 0]}, "freezing", {"<": [{"var":"temp"}, 100]}, "liquid", "gas"]} {"temp":55} liquid
#Missing operator
{"missing":["a", "b"]} {"a":"apple", "b":"banana", "c":"carrot"} []
{"missing":["a", "b"]} {"a":"apple", "c":"carrot"} ["b"]
{"missing":["a", "b", "c", "d"]} {"a":"apple", "c":"carrot"} ["b","d"]
{"if":[{"missing":["a", "b"]},"Not enough fruit","OK to proceed"]} {"a":"apple", "b":"banana", "c":"carrot"} OK to proceed
#MissingSome operator
{"missing_some":[1, ["a", "b", "c"]]} {"a":"apple"} []
{"missing_some":[2, ["a", "b", "c"]]} {"a":"apple"} ["b","c"]
#Array Operations
{"merge":[ [1,2], [3,4] ]} [1.0,2.0,3.0,4.0]
{"merge":[ 1, 2, [3,4] ]} [1.0,2.0,3.0,4.0]
{"missing" :{ "merge" : ["vin",{"if": [{"var":"financing"}, ["apr", "term"], [] ]}]}} {"financing":true} ["vin","apr","term"]
{"missing" :{ "merge" : ["vin",{"if": [{"var":"financing"}, ["apr", "term"], [] ]}]}} {"financing":false} ["vin"]
#in operator
{"in":[ "Ringo", ["John", "Paul", "George", "Ringo"] ]} true
{"in":["Spring", "Springfield"]} true
#All operator
{"all" : [ [1,2,3], {">":[{"var":""}, 0]} ]} true
{"all" : [ {"var":"pies"}, {"==":[{"var":"filling"}, "apple"]} ]} {"pies":[{"filling":"pumpkin","temp":110},{"filling":"rhubarb","temp":210},{"filling":"apple","temp":310}]} false
#Some operator
{"some" : [ {"var":"pies"}, {"==":[{"var":"filling"}, "apple"]} ]} {"pies":[{"filling":"pumpkin","temp":110},{"filling":"rhubarb","temp":210},{"filling":"apple","temp":310}]} true
{"some" : [ [-1,0,1], {">":[{"var":""}, 0]} ]} true
#None operator
{"none" : [ [-3,-2,-1], {">":[{"var":""}, 0]} ]} true
#Map operator
{"map":[{"var":"integers"}, {"*":[{"var":""},2]}]} {"integers":[1,2,3,4,5]} [2.0,4.0,6.0,8.0,10.0]
#Filter operator
{"filter":[ {"var":"integers"}, {"%":[{"var":""},2]}]} {"integers":[1,2,3,4,5]} [1.0,3.0,5.0]
#Reduce operator
{"reduce":[{"var":"integers"},{"+":[{"var":"current"}, {"var":"accumulator"}]},0]} {"integers":[1,2,3,4,5]} 15
#Cat operator
{"cat": ["I love", " pie"]} I love pie
{"cat": ["I love ", {"var":"filling"}, " pie"]} {"filling":"apple", "temp":110} I love apple pie
#Substr operator
{"substr": ["jsonlogic", 4]} logic
{"substr": ["jsonlogic", -5]} logic
{"substr": ["jsonlogic", 1,3]} son
#log to console
{"log":"apple"} apple
{"log":{">" : [3, 1]}} true