Merge pull request #116 from paritytech/small-tests

A couple of small tests.
This commit is contained in:
Sergei Pepyakin 2019-04-03 14:43:29 +02:00 committed by GitHub
commit bbcc495ccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 71 additions and 0 deletions

View File

@ -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);
} }

View 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))

View 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
View 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
View 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))
)
)
)