MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestCustomDecorator

Function TestCustomDecorator

interpreter/interpreter_test.go:2787–2807  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2785}
2786
2787func TestCustomDecorator(t *testing.T) {
2788 decV1 := func(i Interpretable) (Interpretable, error) {
2789 return i, nil
2790 }
2791 opt := CustomDecorator(decV1)
2792 p := &planner{}
2793 p2, err := opt(p)
2794 if err != nil {
2795 t.Fatalf("CustomDecorator failed: %v", err)
2796 }
2797 if len(p2.decorators) != 1 {
2798 t.Fatalf("CustomDecorator did not add decorator")
2799 }
2800 res, err := p2.decorators[0](NewConstValue(1, types.IntOne))
2801 if err != nil {
2802 t.Fatalf("wrapped decorator failed: %v", err)
2803 }
2804 if res.ID() != 1 {
2805 t.Errorf("wrapped decorator returned node with ID %d, wanted 1", res.ID())
2806 }
2807}
2808
2809func TestCostTrackerActualCost(t *testing.T) {
2810 ct := &CostTracker{cost: 42}

Callers

nothing calls this directly

Calls 3

NewConstValueFunction · 0.85
CustomDecoratorFunction · 0.70
IDMethod · 0.65

Tested by

no test coverage detected