MCPcopy Create free account
hub / github.com/goadesign/goa / TestToExpressionSet

Function TestToExpressionSet

eval/expression_test.go:11–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9func (Expr) EvalName() string { return "test expression" }
10
11func TestToExpressionSet(t *testing.T) {
12 cases := []struct {
13 Name string
14 Slice []any
15 ExpectPanic bool
16 }{
17 {"simple", []any{Expr(42)}, false},
18 {"nil", nil, false},
19 {"invalid", []any{42}, true},
20 }
21 for _, c := range cases {
22 t.Run(c.Name, func(t *testing.T) {
23 defer func() {
24 if r := recover(); r == nil && c.ExpectPanic {
25 t.Errorf("test did not panic")
26 }
27 }()
28 set := ToExpressionSet(c.Slice)
29 if len(set) != len(c.Slice) {
30 t.Errorf("got set of length %d, expected %d.", len(set), len(c.Slice))
31 } else {
32 for i, e := range set {
33 if e != c.Slice[i] {
34 t.Errorf("got value %v at index %d, expected %v", e, i, c.Slice[i])
35 }
36 }
37 }
38 })
39 }
40}

Callers

nothing calls this directly

Calls 3

ExprTypeAlias · 0.85
ToExpressionSetFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected