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

Function TestOptimize_count_threshold_gte

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

Source from the content-addressed store, hash-verified

32}
33
34func TestOptimize_count_threshold_gte(t *testing.T) {
35 tree, err := parser.Parse(`count(items, .active) >= 50`)
36 require.NoError(t, err)
37
38 err = optimizer.Optimize(&tree.Node, nil)
39 require.NoError(t, err)
40
41 // Operator should remain >=, but count should have threshold set
42 binary, ok := tree.Node.(*BinaryNode)
43 require.True(t, ok, "expected BinaryNode, got %T", tree.Node)
44 assert.Equal(t, ">=", binary.Operator)
45
46 count, ok := binary.Left.(*BuiltinNode)
47 require.True(t, ok, "expected BuiltinNode, got %T", binary.Left)
48 assert.Equal(t, "count", count.Name)
49 require.NotNil(t, count.Threshold)
50 assert.Equal(t, 50, *count.Threshold) // threshold = N for >= operator
51}
52
53func TestOptimize_count_threshold_lt(t *testing.T) {
54 tree, err := parser.Parse(`count(items, .active) < 100`)

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…