Test comparison operators
This commit is contained in:
@@ -949,7 +949,7 @@ macro_rules! cmp {
|
|||||||
cmp!(i32_eq, sete, |a, b| a == b);
|
cmp!(i32_eq, sete, |a, b| a == b);
|
||||||
cmp!(i32_neq, setne, |a, b| a != b);
|
cmp!(i32_neq, setne, |a, b| a != b);
|
||||||
// TODO: `dynasm-rs` inexplicably doesn't support setb
|
// TODO: `dynasm-rs` inexplicably doesn't support setb
|
||||||
// cmp!(i32_lt_u, setb, |a, b| (a as u32) < (b as u32));
|
cmp!(i32_lt_u, setnae, |a, b| (a as u32) < (b as u32));
|
||||||
cmp!(i32_le_u, setbe, |a, b| (a as u32) <= (b as u32));
|
cmp!(i32_le_u, setbe, |a, b| (a as u32) <= (b as u32));
|
||||||
cmp!(i32_gt_u, seta, |a, b| (a as u32) > (b as u32));
|
cmp!(i32_gt_u, seta, |a, b| (a as u32) > (b as u32));
|
||||||
cmp!(i32_ge_u, setae, |a, b| (a as u32) >= (b as u32));
|
cmp!(i32_ge_u, setae, |a, b| (a as u32) >= (b as u32));
|
||||||
|
|||||||
@@ -286,8 +286,7 @@ pub fn translate(
|
|||||||
Operator::I32LeS => i32_le_s(ctx),
|
Operator::I32LeS => i32_le_s(ctx),
|
||||||
Operator::I32GtS => i32_gt_s(ctx),
|
Operator::I32GtS => i32_gt_s(ctx),
|
||||||
Operator::I32GeS => i32_ge_s(ctx),
|
Operator::I32GeS => i32_ge_s(ctx),
|
||||||
// TODO: `dynasm-rs` inexplicably doesn't support setb
|
Operator::I32LtU => i32_lt_u(ctx),
|
||||||
// Operator::I32LtU => i32_lt_u(ctx),
|
|
||||||
Operator::I32LeU => i32_le_u(ctx),
|
Operator::I32LeU => i32_le_u(ctx),
|
||||||
Operator::I32GtU => i32_gt_u(ctx),
|
Operator::I32GtU => i32_gt_u(ctx),
|
||||||
Operator::I32GeU => i32_ge_u(ctx),
|
Operator::I32GeU => i32_ge_u(ctx),
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ binop_test!(and, std::ops::BitAnd::bitand);
|
|||||||
binop_test!(or, std::ops::BitOr::bitor);
|
binop_test!(or, std::ops::BitOr::bitor);
|
||||||
binop_test!(xor, std::ops::BitXor::bitxor);
|
binop_test!(xor, std::ops::BitXor::bitxor);
|
||||||
binop_test!(mul, u32::wrapping_mul);
|
binop_test!(mul, u32::wrapping_mul);
|
||||||
|
binop_test!(lt_u, |a, b| if a < b { 1 } else { 0 });
|
||||||
|
binop_test!(le_u, |a, b| if a <= b { 1 } else { 0 });
|
||||||
|
binop_test!(gt_u, |a, b| if a > b { 1 } else { 0 });
|
||||||
|
binop_test!(ge_u, |a, b| if a >= b { 1 } else { 0 });
|
||||||
|
binop_test!(lt_s, |a, b| if (a as i32) < (b as i32) { 1 } else { 0 });
|
||||||
|
binop_test!(le_s, |a, b| if (a as i32) <= (b as i32) { 1 } else { 0 });
|
||||||
|
binop_test!(gt_s, |a, b| if (a as i32) > (b as i32) { 1 } else { 0 });
|
||||||
|
binop_test!(ge_s, |a, b| if (a as i32) >= (b as i32) { 1 } else { 0 });
|
||||||
|
|
||||||
quickcheck! {
|
quickcheck! {
|
||||||
fn relop_eq(a: u32, b: u32) -> bool{
|
fn relop_eq(a: u32, b: u32) -> bool{
|
||||||
|
|||||||
Reference in New Issue
Block a user