Skip to content

Fixes testHostFunctionNumericParameter #2380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 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,16 @@ 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:
require.Equal(t, api.DecodeI32(test.expected), api.DecodeI32(results[0]))
case f32:
require.Equal(t, api.DecodeF32(test.expected), api.DecodeF32(results[0]))
case i64:
require.Equal(t, test.expected, results[0])
case f64:
require.Equal(t, api.DecodeF64(test.expected), api.DecodeF64(results[0]))
}
})
}
}
Expand Down
Loading