Skip to content

Commit

Permalink
chore: run clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
nerodesu017 committed Jul 3, 2024
1 parent 6126897 commit a07c2a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl<'b> RuntimeInstance<'b> {
}

let res = divisor.checked_rem(dividend);
let res = if res.is_none() { 0 } else { res.unwrap() };
let res = if let Some(value) = res { value } else { 0 };

trace!("Instruction: i32.rem_s [{divisor} {dividend}] -> [{res}]");
stack.push_value(res.into());
Expand All @@ -286,7 +286,7 @@ impl<'b> RuntimeInstance<'b> {
}

let res = divisor.checked_rem(dividend);
let res = if res.is_none() { 0 } else { res.unwrap() } as i32;
let res = if let Some(value) = res { value } else { 0 } as i32;

trace!("Instruction: i32.rem_u [{divisor} {dividend}] -> [{res}]");
stack.push_value(res.into());
Expand Down
6 changes: 3 additions & 3 deletions src/validation/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ fn read_instructions(
}
// i32.rem_u: [i32 i32] -> [i32]
0x70 => {
assert_pop_value_stack(value_stack, ValType::NumType(NumType::I32))?;
assert_pop_value_stack(value_stack, ValType::NumType(NumType::I32))?;
assert_pop_value_stack(value_stack, ValType::NumType(NumType::I32))?;
assert_pop_value_stack(value_stack, ValType::NumType(NumType::I32))?;

value_stack.push_back(ValType::NumType(NumType::I32));
value_stack.push_back(ValType::NumType(NumType::I32));
}
// i32.const: [] -> [i32]
0x41 => {
Expand Down
12 changes: 8 additions & 4 deletions tests/arithmetic/remainder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub fn remainder_signed_panic_dividend_0() {
);
}


/// A simple function to test unsigned remainder
#[test_log::test]
pub fn remainder_unsigned_simple() {
Expand All @@ -67,10 +66,15 @@ pub fn remainder_unsigned_simple() {

assert_eq!(0, instance.invoke_func(0, (i32::MIN, 2)).unwrap());
assert_eq!(i32::MIN, instance.invoke_func(0, (i32::MIN, -2)).unwrap());
assert_eq!((i32::MIN + 2)*(-1), instance.invoke_func(0, (-2, i32::MIN)).unwrap());
assert_eq!(
(i32::MIN + 2) * (-1),
instance.invoke_func(0, (-2, i32::MIN)).unwrap()
);
assert_eq!(2, instance.invoke_func(0, (2, i32::MIN)).unwrap());
assert_eq!(i32::MAX, instance.invoke_func(0, (i32::MAX, i32::MIN)).unwrap());

assert_eq!(
i32::MAX,
instance.invoke_func(0, (i32::MAX, i32::MIN)).unwrap()
);

assert_eq!(0, instance.invoke_func(0, (20, 2)).unwrap());
assert_eq!(999, instance.invoke_func(0, (10_000, 9_001)).unwrap());
Expand Down

0 comments on commit a07c2a3

Please sign in to comment.