mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-03-15 03:00:49 +00:00
Add gas test confirming that br instructions do not end blocks.
This commit is contained in:
parent
89e13ee901
commit
863744b1fc
@ -122,4 +122,5 @@ mod gas {
|
||||
def_gas_test!(simple);
|
||||
def_gas_test!(start);
|
||||
def_gas_test!(call);
|
||||
def_gas_test!(branch);
|
||||
}
|
||||
|
29
tests/expectations/gas/branch.wat
Normal file
29
tests/expectations/gas/branch.wat
Normal file
@ -0,0 +1,29 @@
|
||||
(module
|
||||
(type (;0;) (func (result i32)))
|
||||
(type (;1;) (func (param i32)))
|
||||
(import "env" "gas" (func (;0;) (type 1)))
|
||||
(func (;1;) (type 0) (result i32)
|
||||
(local i32 i32)
|
||||
i32.const 3
|
||||
call 0
|
||||
block ;; label = @1
|
||||
i32.const 17
|
||||
call 0
|
||||
i32.const 0
|
||||
set_local 0
|
||||
i32.const 1
|
||||
set_local 1
|
||||
get_local 0
|
||||
get_local 1
|
||||
tee_local 0
|
||||
i32.add
|
||||
set_local 1
|
||||
i32.const 1
|
||||
br_if 0 (;@1;)
|
||||
get_local 0
|
||||
get_local 1
|
||||
tee_local 0
|
||||
i32.add
|
||||
set_local 1
|
||||
end
|
||||
get_local 1))
|
27
tests/fixtures/gas/branch.wat
vendored
Normal file
27
tests/fixtures/gas/branch.wat
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
(module
|
||||
(func $fibonacci_with_break (result i32)
|
||||
(local $x i32) (local $y i32)
|
||||
|
||||
(block $unrolled_loop
|
||||
(set_local $x (i32.const 0))
|
||||
(set_local $y (i32.const 1))
|
||||
|
||||
get_local $x
|
||||
get_local $y
|
||||
tee_local $x
|
||||
i32.add
|
||||
set_local $y
|
||||
|
||||
i32.const 1
|
||||
br_if $unrolled_loop
|
||||
|
||||
get_local $x
|
||||
get_local $y
|
||||
tee_local $x
|
||||
i32.add
|
||||
set_local $y
|
||||
)
|
||||
|
||||
get_local $y
|
||||
)
|
||||
)
|
1
tests/fixtures/gas/call.wat
vendored
1
tests/fixtures/gas/call.wat
vendored
@ -2,7 +2,6 @@
|
||||
(func $add_locals (param $x i32) (param $y i32) (result i32)
|
||||
(local $t i32)
|
||||
|
||||
;; This looks
|
||||
get_local $x
|
||||
get_local $y
|
||||
call $add
|
||||
|
4
tests/fixtures/gas/ifs.wat
vendored
4
tests/fixtures/gas/ifs.wat
vendored
@ -2,8 +2,8 @@
|
||||
(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))
|
||||
(then (i32.add (get_local $x) (i32.const 1)))
|
||||
(else (i32.popcnt (get_local $x)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
2
tests/fixtures/gas/simple.wat
vendored
2
tests/fixtures/gas/simple.wat
vendored
@ -1,12 +1,14 @@
|
||||
(module
|
||||
(func (export "simple")
|
||||
(if (i32.const 1)
|
||||
(then
|
||||
(loop
|
||||
i32.const 123
|
||||
drop
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func
|
||||
block
|
||||
|
Loading…
x
Reference in New Issue
Block a user