diff --git a/tests/diff.rs b/tests/diff.rs index 3c889d7..0a9392e 100644 --- a/tests/diff.rs +++ b/tests/diff.rs @@ -117,6 +117,9 @@ mod gas { }; } + + def_gas_test!(ifs); def_gas_test!(simple); def_gas_test!(start); + def_gas_test!(call); } diff --git a/tests/expectations/gas/call.wat b/tests/expectations/gas/call.wat new file mode 100644 index 0000000..878022a --- /dev/null +++ b/tests/expectations/gas/call.wat @@ -0,0 +1,19 @@ +(module + (type (;0;) (func (param i32 i32) (result i32))) + (type (;1;) (func (param i32))) + (import "env" "gas" (func (;0;) (type 1))) + (func (;1;) (type 0) (param i32 i32) (result i32) + (local i32) + i32.const 6 + call 0 + get_local 0 + get_local 1 + call 2 + set_local 2 + get_local 2) + (func (;2;) (type 0) (param i32 i32) (result i32) + i32.const 4 + call 0 + get_local 0 + get_local 1 + i32.add)) diff --git a/tests/expectations/gas/ifs.wat b/tests/expectations/gas/ifs.wat new file mode 100644 index 0000000..89c72e7 --- /dev/null +++ b/tests/expectations/gas/ifs.wat @@ -0,0 +1,20 @@ +(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32))) + (import "env" "gas" (func (;0;) (type 1))) + (func (;1;) (type 0) (param i32) (result i32) + i32.const 3 + call 0 + i32.const 1 + if (result i32) ;; label = @1 + i32.const 4 + call 0 + get_local 0 + i32.const 1 + i32.add + else + i32.const 3 + call 0 + get_local 0 + i32.popcnt + end)) diff --git a/tests/fixtures/gas/call.wat b/tests/fixtures/gas/call.wat new file mode 100644 index 0000000..a1ca8fb --- /dev/null +++ b/tests/fixtures/gas/call.wat @@ -0,0 +1,20 @@ +(module + (func $add_locals (param $x i32) (param $y i32) (result i32) + (local $t i32) + + ;; This looks + get_local $x + get_local $y + call $add + set_local $t + + get_local $t + ) + + (func $add (param $x i32) (param $y i32) (result i32) + (i32.add + (get_local $x) + (get_local $y) + ) + ) +) diff --git a/tests/fixtures/gas/ifs.wat b/tests/fixtures/gas/ifs.wat new file mode 100644 index 0000000..4e74f50 --- /dev/null +++ b/tests/fixtures/gas/ifs.wat @@ -0,0 +1,9 @@ +(module + (func (param $x i32) (result i32) + (if (result i32) + (i32.const 1) + (i32.add (get_local $x) (i32.const 1)) + (i32.popcnt (get_local $x)) + ) + ) +)