From c5fb3251cec26b875cae92321b0d829e5d8656a1 Mon Sep 17 00:00:00 2001 From: Christopher Serr Date: Tue, 10 Sep 2024 01:54:09 +0200 Subject: [PATCH] Add Roundtrip Tests for both instructions --- crates/tests/tests/round_trip/return_call.wat | 20 +++++++++++++++++++ .../tests/round_trip/return_call_indirect.wat | 18 +++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 crates/tests/tests/round_trip/return_call.wat create mode 100644 crates/tests/tests/round_trip/return_call_indirect.wat diff --git a/crates/tests/tests/round_trip/return_call.wat b/crates/tests/tests/round_trip/return_call.wat new file mode 100644 index 00000000..3fa8baab --- /dev/null +++ b/crates/tests/tests/round_trip/return_call.wat @@ -0,0 +1,20 @@ +(module + (func $g (result i32) + i32.const 42 + return) + (func $f (result i32) + return_call $g) + (export "f" (func $f))) + +(; CHECK-ALL: + (module + (type (;0;) (func (result i32))) + (func $g (;0;) (type 0) (result i32) + i32.const 42 + return + ) + (func $f (;1;) (type 0) (result i32) + return_call $g + ) + (export "f" (func $f)) +;) diff --git a/crates/tests/tests/round_trip/return_call_indirect.wat b/crates/tests/tests/round_trip/return_call_indirect.wat new file mode 100644 index 00000000..89385323 --- /dev/null +++ b/crates/tests/tests/round_trip/return_call_indirect.wat @@ -0,0 +1,18 @@ +(module + (type (func (result i32))) + (table 1 funcref) + (func (export "a") (param i32) (result i32) + local.get 0 + return_call_indirect (type 0))) + +(; CHECK-ALL: + (module + (type (;0;) (func (result i32))) + (type (;1;) (func (param i32) (result i32))) + (func (;0;) (type 1) (param i32) (result i32) + local.get 0 + return_call_indirect (type 0) + ) + (table (;0;) 1 funcref) + (export "a" (func 0)) +;)