MCPcopy Index your code
hub / github.com/expr-lang/expr / TestOptimize_count_threshold_lt

Function TestOptimize_count_threshold_lt

optimizer/count_threshold_test.go:53–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestOptimize_count_threshold_lt(t *testing.T) {
54 tree, err := parser.Parse(`count(items, .active) < 100`)
55 require.NoError(t, err)
56
57 err = optimizer.Optimize(&tree.Node, nil)
58 require.NoError(t, err)
59
60 // Operator should remain <, but count should have threshold set
61 binary, ok := tree.Node.(*BinaryNode)
62 require.True(t, ok, "expected BinaryNode, got %T", tree.Node)
63 assert.Equal(t, "<", binary.Operator)
64
65 count, ok := binary.Left.(*BuiltinNode)
66 require.True(t, ok, "expected BuiltinNode, got %T", binary.Left)
67 assert.Equal(t, "count", count.Name)
68 require.NotNil(t, count.Threshold)
69 assert.Equal(t, 100, *count.Threshold) // threshold = N for < operator
70}
71
72func TestOptimize_count_threshold_lte(t *testing.T) {
73 tree, err := parser.Parse(`count(items, .active) <= 50`)

Callers

nothing calls this directly

Calls 6

ParseFunction · 0.92
NoErrorFunction · 0.92
OptimizeFunction · 0.92
TrueFunction · 0.92
EqualFunction · 0.92
NotNilFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…