You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: evaluate_test.go
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -329,6 +329,26 @@ var evaluateTests map[string]expressionTest = map[string]expressionTest{
329
329
{expression: "Nested.Notfound is not empty", result: false, err: `error finding value in datum: /Nested/Notfound at part 1: couldn't find key: struct field with name "Notfound"`},
330
330
{expression: `Nested.Notfound matches ".*"`, result: false, err: `error finding value in datum: /Nested/Notfound at part 1: couldn't find key: struct field with name "Notfound"`},
331
331
{expression: `Nested.Notfound not matches ".*"`, result: false, err: `error finding value in datum: /Nested/Notfound at part 1: couldn't find key: struct field with name "Notfound"`},
332
+
// all
333
+
{expression: `all Nested.SliceOfInts as i { i != 42 }`, result: true},
334
+
{expression: `all Nested.SliceOfInts as i { i == 1 }`, result: false},
335
+
{expression: `all Nested.Map as v { v == "bar" }`, result: false},
336
+
{expression: `all Nested.Map as v { v != "hello" }`, result: true},
337
+
{expression: `all Nested.Map as k, k { TopInt == 5 }`, err: `"k" cannot be used as a placeholder for both the index and the value`},
338
+
{expression: `all Nested.Map as k, _ { k != "foo" }`, result: false},
339
+
{expression: `all Nested.Map as k, _ { k != "hello" }`, result: true},
340
+
{expression: `all Nested.Map as k, v { k != "foo" or v != "baz" }`, result: true},
341
+
{expression: `all TopInt as k, v { k != "foo" or v != "baz" }`, err: "TopInt is not a list or a map"},
342
+
// any
343
+
{expression: `any Nested.SliceOfInts as i { i == 1 }`, result: true},
344
+
{expression: `any Nested.SliceOfInts as i { i == 42 }`, result: false},
345
+
{expression: `any Nested.SliceOfStructs as i { "/i/X" == 1 }`, result: true},
346
+
{expression: `any Nested.Map as k { k != "bar" }`, result: true},
347
+
{expression: `any Nested.Map as k { k == "bar" }`, result: true},
348
+
{expression: `any Nested.Map as k { k == "hello" }`, result: false},
349
+
{expression: `any Nested.Map as k, v { k == "foo" and v == "bar" }`, result: true},
350
+
{expression: `any Nested.Map as k { k.Color == "red" }`, err: "/k references a string so /k/Color is invalid"},
351
+
{expression: `any Nested.SliceOfInts as i, _ { i.Color == "red" }`, err: "/i references a int so /i/Color is invalid"},
0 commit comments