Skip to content

Commit

Permalink
Fixes testHostFunctionNumericParameter
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake committed Feb 19, 2025
1 parent 96f2052 commit a134796
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion internal/integration_test/engine/adhoc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,15 @@ func testHostFunctionNumericParameter(t *testing.T, r wazero.Runtime) {
"i32": func(ctx context.Context, p uint32) uint32 {
return p + 1
},
"i32n": func(ctx context.Context, p int32) int32 {
return p - 1
},
"i64": func(ctx context.Context, p uint64) uint64 {
return p + 1
},
"i64n": func(ctx context.Context, p int64) int64 {
return p - 1
},
"f32": func(ctx context.Context, p float32) float32 {
return p + 1
},
Expand All @@ -524,12 +530,24 @@ func testHostFunctionNumericParameter(t *testing.T, r wazero.Runtime) {
input: math.MaxUint32 - 1,
expected: math.MaxUint32,
},
{
name: "i32n",
vt: i32,
input: api.EncodeI32(math.MinInt32 + 1),
expected: api.EncodeI32(math.MinInt32),
},
{
name: "i64",
vt: i64,
input: math.MaxUint64 - 1,
expected: math.MaxUint64,
},
{
name: "i64n",
vt: i64,
input: api.EncodeI64(math.MinInt64 + 1),
expected: api.EncodeI64(math.MinInt64),
},
{
name: "f32",
vt: wasm.ValueTypeF32,
Expand Down Expand Up @@ -562,7 +580,12 @@ func testHostFunctionNumericParameter(t *testing.T, r wazero.Runtime) {

results, err := importing.ExportedFunction("call_return_input").Call(testCtx, test.input)
require.NoError(t, err)
require.Equal(t, test.expected, results[0])
switch test.vt {
case i32, f32:
require.Equal(t, uint32(test.expected), uint32(results[0]))
case i64, f64:
require.Equal(t, test.expected, results[0])
}
})
}
}
Expand Down

0 comments on commit a134796

Please sign in to comment.