Skip to content

Commit

Permalink
Add test for select instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Jan 9, 2021
1 parent cfdd4e3 commit 6a5941f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions test/test.expected
Expand Up @@ -3,7 +3,11 @@
(func $adder (param $0 i32) (param $1 i32) (result i32)
(block $add (result i32)
(i32.add
(local.get $0)
(select
(local.get $0)
(local.get $1)
(i32.const 1)
)
(local.get $1)
)
)
Expand All @@ -13,7 +17,11 @@
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(func $0 (param $0 i32) (param $1 i32) (result i32)
(i32.add
(local.get $0)
(select
(local.get $0)
(local.get $1)
(i32.const 1)
)
(local.get $1)
)
)
Expand Down
4 changes: 3 additions & 1 deletion test/test.ml
Expand Up @@ -12,7 +12,9 @@ let x = Expression.local_get wasm_mod 0 Type.int32

let y = Expression.local_get wasm_mod 1 Type.int32

let add = Expression.block wasm_mod ~return_type:Type.int32 "add" [Expression.binary wasm_mod Op.add_int32 x y]
let select = Expression.select wasm_mod (Expression.const wasm_mod (Literal.int32 1l)) x y

let add = Expression.block wasm_mod ~return_type:Type.int32 "add" [Expression.binary wasm_mod Op.add_int32 select y]

(* Create the add function *)
let adder = Function.add_function wasm_mod "adder" params results [||] add
Expand Down

0 comments on commit 6a5941f

Please sign in to comment.