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{
3939 map [string ]interface {}{"foo" : false , "bar" : true },
4040 true ,
4141 },
42+ {
43+ "true || false" ,
44+ nil ,
45+ true ,
46+ },
47+ {
48+ "false && true" ,
49+ nil ,
50+ false ,
51+ },
4252 {
4353 "2+2==4" ,
4454 nil ,
@@ -205,6 +215,11 @@ var evalTests = []evalTest{
205215 nil ,
206216 true ,
207217 },
218+ {
219+ `0 in nil` ,
220+ nil ,
221+ false ,
222+ },
208223 {
209224 `A == nil` ,
210225 struct { A interface {} }{nil },
@@ -217,7 +232,7 @@ var evalTests = []evalTest{
217232 },
218233 {
219234 "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 }}},
221236 true ,
222237 },
223238 {
@@ -245,6 +260,11 @@ var evalTests = []evalTest{
245260 nil ,
246261 "a" ,
247262 },
263+ {
264+ `false ? "a" : "b"` ,
265+ nil ,
266+ "b" ,
267+ },
248268 {
249269 `foo.bar("world")` ,
250270 map [string ]interface {}{"foo" : map [string ]interface {}{"bar" : func (in string ) string { return "hello " + in }}},
@@ -309,6 +329,36 @@ var evalErrorTests = []evalErrorTest{
309329 nil ,
310330 "range 1..1000001 exceeded max size of 1e6" ,
311331 },
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+ },
312362}
313363
314364func TestEval (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments