(t *testing.T)
| 887 | } |
| 888 | |
| 889 | func TestDynamicBlockEval(t *testing.T) { |
| 890 | db := &dynamicBlock{ |
| 891 | expr: interpreter.NewConstValue(1, types.IntOne), |
| 892 | slotActivationPool: &sync.Pool{ |
| 893 | New: func() any { |
| 894 | return &dynamicSlotActivation{} |
| 895 | }, |
| 896 | }, |
| 897 | } |
| 898 | res := db.Eval(cel.NoVars()) |
| 899 | if res.Equal(types.IntOne) != types.True { |
| 900 | t.Errorf("db.Eval() = %v, wanted 1", res) |
| 901 | } |
| 902 | |
| 903 | slot0 := interpreter.NewConstValue(1, types.IntOne) |
| 904 | pooled := newDynamicBlock([]interpreter.InterpretableV2{slot0}, slot0).(*dynamicBlock) |
| 905 | sa := pooled.slotActivationPool.Get().(*dynamicSlotActivation) |
| 906 | if allocs := testing.AllocsPerRun(100, func() { |
| 907 | sa.reset() |
| 908 | for i := 0; i < 2; i++ { |
| 909 | if val, found := sa.ResolveName("@index0"); !found || val != types.IntOne { |
| 910 | t.Fatalf("ResolveName(@index0) = (%v, %v), wanted (1, true)", val, found) |
| 911 | } |
| 912 | } |
| 913 | }); allocs != 0 { |
| 914 | t.Errorf("ResolveName allocated %v allocs/run, wanted 0", allocs) |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | func TestConstantBlockEval(t *testing.T) { |
| 919 | cb := &constantBlock{ |
nothing calls this directly
no test coverage detected