File tree Expand file tree Collapse file tree 1 file changed +51
-1
lines changed Expand file tree Collapse file tree 1 file changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,16 @@ var evalTests = []evalTest{
39
39
map [string ]interface {}{"foo" : false , "bar" : true },
40
40
true ,
41
41
},
42
+ {
43
+ "true || false" ,
44
+ nil ,
45
+ true ,
46
+ },
47
+ {
48
+ "false && true" ,
49
+ nil ,
50
+ false ,
51
+ },
42
52
{
43
53
"2+2==4" ,
44
54
nil ,
@@ -205,6 +215,11 @@ var evalTests = []evalTest{
205
215
nil ,
206
216
true ,
207
217
},
218
+ {
219
+ `0 in nil` ,
220
+ nil ,
221
+ false ,
222
+ },
208
223
{
209
224
`A == nil` ,
210
225
struct { A interface {} }{nil },
@@ -217,7 +232,7 @@ var evalTests = []evalTest{
217
232
},
218
233
{
219
234
"foo.Bar['baz']" ,
220
- map [string ]interface {}{"foo" : & struct { Bar map [string ]interface {}}{Bar : map [string ]interface {}{"baz" : true }}},
235
+ map [string ]interface {}{"foo" : & struct { Bar map [string ]interface {} }{Bar : map [string ]interface {}{"baz" : true }}},
221
236
true ,
222
237
},
223
238
{
@@ -245,6 +260,11 @@ var evalTests = []evalTest{
245
260
nil ,
246
261
"a" ,
247
262
},
263
+ {
264
+ `false ? "a" : "b"` ,
265
+ nil ,
266
+ "b" ,
267
+ },
248
268
{
249
269
`foo.bar("world")` ,
250
270
map [string ]interface {}{"foo" : map [string ]interface {}{"bar" : func (in string ) string { return "hello " + in }}},
@@ -309,6 +329,36 @@ var evalErrorTests = []evalErrorTest{
309
329
nil ,
310
330
"range 1..1000001 exceeded max size of 1e6" ,
311
331
},
332
+ {
333
+ "1/0" ,
334
+ nil ,
335
+ "division by zero" ,
336
+ },
337
+ {
338
+ "1%0" ,
339
+ nil ,
340
+ "division by zero" ,
341
+ },
342
+ {
343
+ "1 + 'a'" ,
344
+ nil ,
345
+ "can't cast string to float64" ,
346
+ },
347
+ {
348
+ "'a' + 1" ,
349
+ nil ,
350
+ "can't cast string to float64" ,
351
+ },
352
+ {
353
+ "[1, 2]['a']" ,
354
+ nil ,
355
+ "can't cast string to float64" ,
356
+ },
357
+ {
358
+ `1 in "a"` ,
359
+ nil ,
360
+ "operator in not defined on string" ,
361
+ },
312
362
}
313
363
314
364
func TestEval (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments