MCPcopy Create free account
hub / github.com/expr-lang/expr / TestExpr_readme_example

Function TestExpr_readme_example

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

Source from the content-addressed store, hash-verified

695}
696
697func TestExpr_readme_example(t *testing.T) {
698 env := map[string]any{
699 "greet": "Hello, %v!",
700 "names": []string{"world", "you"},
701 "sprintf": fmt.Sprintf,
702 }
703
704 code := `sprintf(greet, names[0])`
705
706 program, err := expr.Compile(code, expr.Env(env))
707 require.NoError(t, err)
708
709 output, err := expr.Run(program, env)
710 require.NoError(t, err)
711
712 require.Equal(t, "Hello, world!", output)
713}
714
715func TestExpr(t *testing.T) {
716 date := time.Date(2017, time.October, 23, 18, 30, 0, 0, time.UTC)

Callers

nothing calls this directly

Calls 5

CompileFunction · 0.92
EnvStruct · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…