Add assert_return.get tests. (#29)

This commit is contained in:
Takeshi Yoneda
2021-10-11 12:30:22 +09:00
committed by GitHub
parent 775c865b67
commit 2e34bad267

View File

@@ -255,7 +255,33 @@ func TestSpecification(t *testing.T) {
}
}
case "get":
// TODO:
_, exps := c.getAssertReturnArgsExps(t)
require.Len(t, exps, 1)
msg = fmt.Sprintf("%s invoke %s (%s)", msg, c.Action.Field, c.Action.Args)
if c.Action.Module != "" {
msg += " in module " + c.Action.Module
}
inst, ok := vm.Store.ModuleInstances[moduleName]
require.True(t, ok, msg)
addr := inst.Exports[c.Action.Field]
if addr.Kind != wasm.ExportKindGlobal {
t.Fatal()
}
actual := vm.Store.Globals[addr.Addr]
var expType wasm.ValueType
switch c.Exps[0].ValType {
case "i32":
expType = wasm.ValueTypeI32
case "i64":
expType = wasm.ValueTypeI64
case "f32":
expType = wasm.ValueTypeF32
case "f64":
expType = wasm.ValueTypeF64
}
require.NotNil(t, actual, msg)
assert.Equal(t, expType, actual.Type.ValType, msg)
assert.Equal(t, exps[0], actual.Val, expType, msg)
default:
t.Fatalf("unsupported action type type: %v", c)
}