MCPcopy Create free account
hub / github.com/expr-lang/expr / TestOptimize_count_any

Function TestOptimize_count_any

optimizer/count_any_test.go:15–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestOptimize_count_any(t *testing.T) {
16 tree, err := parser.Parse(`count(items, .active) > 0`)
17 require.NoError(t, err)
18
19 err = optimizer.Optimize(&tree.Node, nil)
20 require.NoError(t, err)
21
22 expected := &BuiltinNode{
23 Name: "any",
24 Arguments: []Node{
25 &IdentifierNode{Value: "items"},
26 &PredicateNode{
27 Node: &MemberNode{
28 Node: &PointerNode{},
29 Property: &StringNode{Value: "active"},
30 },
31 },
32 },
33 }
34
35 assert.Equal(t, Dump(expected), Dump(tree.Node))
36}
37
38func TestOptimize_count_any_gte_one(t *testing.T) {
39 tree, err := parser.Parse(`count(items, .valid) >= 1`)

Callers

nothing calls this directly

Calls 5

ParseFunction · 0.92
NoErrorFunction · 0.92
OptimizeFunction · 0.92
EqualFunction · 0.92
DumpFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…