mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-03-15 19:20:48 +00:00
Merge pull request #116 from paritytech/small-tests
A couple of small tests.
This commit is contained in:
commit
bbcc495ccc
@ -117,6 +117,9 @@ mod gas {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def_gas_test!(ifs);
|
||||||
def_gas_test!(simple);
|
def_gas_test!(simple);
|
||||||
def_gas_test!(start);
|
def_gas_test!(start);
|
||||||
|
def_gas_test!(call);
|
||||||
}
|
}
|
||||||
|
19
tests/expectations/gas/call.wat
Normal file
19
tests/expectations/gas/call.wat
Normal file
@ -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))
|
20
tests/expectations/gas/ifs.wat
Normal file
20
tests/expectations/gas/ifs.wat
Normal file
@ -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))
|
20
tests/fixtures/gas/call.wat
vendored
Normal file
20
tests/fixtures/gas/call.wat
vendored
Normal file
@ -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)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
9
tests/fixtures/gas/ifs.wat
vendored
Normal file
9
tests/fixtures/gas/ifs.wat
vendored
Normal file
@ -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))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user