MCPcopy
hub / github.com/adonovan/gopl.io / Example_expr

Function Example_expr

ch12/display/display_test.go:22–34  ·  view source on GitHub ↗

NOTE: we can't use !+..!- comments to excerpt these tests into the book because it defeats the Example mechanism, which requires the // Output comment to be at the end of the function.

()

Source from the content-addressed store, hash-verified

20// of the function.
21
22func Example_expr() {
23 e, _ := eval.Parse("sqrt(A / pi)")
24 Display("e", e)
25 // Output:
26 // Display e (eval.call):
27 // e.fn = "sqrt"
28 // e.args[0].type = eval.binary
29 // e.args[0].value.op = 47
30 // e.args[0].value.x.type = eval.Var
31 // e.args[0].value.x.value = "A"
32 // e.args[0].value.y.type = eval.Var
33 // e.args[0].value.y.value = "pi"
34}
35
36func Example_slice() {
37 Display("slice", []*int{new(int), nil})

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.92
DisplayFunction · 0.85

Tested by

no test coverage detected