MCPcopy
hub / github.com/expr-lang/expr / TestExpr

Function TestExpr

expr_test.go:715–1465  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

713}
714
715func TestExpr(t *testing.T) {
716 date := time.Date(2017, time.October, 23, 18, 30, 0, 0, time.UTC)
717 oneDay, _ := time.ParseDuration("24h")
718 timeNowPlusOneDay := date.Add(oneDay)
719
720 env := mock.Env{
721 Embed: mock.Embed{},
722 Ambiguous: "",
723 Any: nil,
724 Bool: true,
725 Float: 0,
726 Int64: 0,
727 Int32: 0,
728 Int: 0,
729 One: 1,
730 Two: 2,
731 Uint32: 0,
732 String: "string",
733 BoolPtr: nil,
734 FloatPtr: nil,
735 IntPtr: nil,
736 IntPtrPtr: nil,
737 StringPtr: nil,
738 Foo: mock.Foo{
739 Value: "foo",
740 Bar: mock.Bar{
741 Baz: "baz",
742 },
743 },
744 Abstract: nil,
745 ArrayOfAny: nil,
746 ArrayOfInt: []int{1, 2, 3, 4, 5},
747 ArrayOfFoo: []*mock.Foo{{Value: "foo"}, {Value: "bar"}, {Value: "baz"}},
748 MapOfFoo: nil,
749 MapOfAny: nil,
750 FuncParam: nil,
751 FuncParamAny: nil,
752 FuncTooManyReturns: nil,
753 FuncNamed: nil,
754 NilAny: nil,
755 NilFn: nil,
756 NilStruct: nil,
757 Variadic: func(head int, xs ...int) bool {
758 sum := 0
759 for _, x := range xs {
760 sum += x
761 }
762 return head == sum
763 },
764 Fast: nil,
765 Time: date,
766 TimePlusDay: timeNowPlusOneDay,
767 Duration: oneDay,
768 }
769
770 tests := []struct {
771 code string
772 want any

Callers

nothing calls this directly

Calls 11

CompileFunction · 0.92
EnvStruct · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92
OptimizeFunction · 0.92
EvalFunction · 0.92
RunMethod · 0.80
NodeMethod · 0.80
AddMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…