(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func 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 | } |
nothing calls this directly
no test coverage detected