MCPcopy Create free account
hub / github.com/google/gapid / TestCodegen

Function TestCodegen

core/codegen/codegen_test.go:27–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestCodegen(t *testing.T) {
28 ctx := log.Testing(t)
29
30 hostABI := host.Instance(ctx).Configuration.ABIs[0]
31
32 m := codegen.NewModule("test", hostABI)
33 f := m.Function(m.Types.Int, "add", m.Types.Int, m.Types.Int)
34 err := f.Build(func(b *codegen.Builder) {
35 x := b.Parameter(0)
36 y := b.Parameter(1)
37 b.Return(b.Add(x, y))
38 })
39 if !assert.For(ctx, "f.Build").ThatError(err).Succeeded() {
40 return
41 }
42 e, err := m.Executor(false)
43 if !assert.For(ctx, "m.Executor(false)").ThatError(err).Succeeded() {
44 return
45 }
46 x := call.III(e.FunctionAddress(f), 2, 3)
47 assert.For(ctx, "call.III('add', 2, 3)").ThatInteger(x).Equals(5)
48}

Callers

nothing calls this directly

Calls 13

FunctionMethod · 0.95
ExecutorMethod · 0.95
SucceededMethod · 0.80
ThatErrorMethod · 0.80
ForMethod · 0.80
ThatIntegerMethod · 0.80
InstanceMethod · 0.65
BuildMethod · 0.65
AddMethod · 0.65
EqualsMethod · 0.65
ParameterMethod · 0.45
ReturnMethod · 0.45

Tested by

no test coverage detected