Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbepop committed Nov 24, 2023
1 parent 7862a63 commit d6da540
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions crates/wasmi/src/engine/regmach/tests/op/cmp_br.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,53 @@ fn if_i32_eqz_fuse() {
test_for("or", Instruction::branch_i32_or);
test_for("xor", Instruction::branch_i32_xor);
}

#[test]
#[cfg_attr(miri, ignore)]
fn block_i64_eqz_fuse() {
let wasm = wat2wasm(&format!(
r"
(module
(func (param i64)
(block
(i64.eqz (local.get 0))
(br_if 0)
)
)
)",
));
TranslationTest::new(wasm)
.expect_func_instrs([
Instruction::branch_i64_eqz(
Register::from_i16(0),
BranchOffset::from(1),
),
Instruction::Return,
])
.run()
}

#[test]
#[cfg_attr(miri, ignore)]
fn if_i64_eqz_fuse() {
let wasm = wat2wasm(&format!(
r"
(module
(func (param i64)
(if
(i64.eqz (local.get 0))
(then)
)
)
)",
));
TranslationTest::new(wasm)
.expect_func_instrs([
Instruction::branch_i64_nez(
Register::from_i16(0),
BranchOffset::from(1),
),
Instruction::Return,
])
.run()
}

0 comments on commit d6da540

Please sign in to comment.