Skip to content

Commit

Permalink
refactor: less verbose syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
nerodesu017 committed Jul 3, 2024
1 parent 153a0c8 commit 3b97d1a
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/arithmetic/division.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use wasm::Error::RuntimeError;
use wasm::RuntimeError::{DivideBy0, UnrepresentableResult};

/// A simple function to test signed division
#[test_log::test]
pub fn division_signed_simple() {
Expand Down Expand Up @@ -47,10 +50,7 @@ pub fn division_signed_panic_dividend_0() {

let result = instance.invoke_func::<(i32, i32), i32>(0, (222, 0));

assert_eq!(
result.unwrap_err(),
wasm::Error::RuntimeError(wasm::RuntimeError::DivideBy0)
);
assert_eq!(result.unwrap_err(), RuntimeError(DivideBy0));
}

/// A simple function to test signed division's RuntimeError when we are dividing the i32 minimum by -1 (which gives an unrepresentable result - overflow)
Expand All @@ -75,10 +75,7 @@ pub fn division_signed_panic_result_unrepresentable() {

let result = instance.invoke_func::<(i32, i32), i32>(0, (i32::MIN, -1));

assert_eq!(
result.unwrap_err(),
wasm::Error::RuntimeError(wasm::RuntimeError::UnrepresentableResult)
);
assert_eq!(result.unwrap_err(), RuntimeError(UnrepresentableResult));
}

/// A simple function to test unsigned division
Expand Down Expand Up @@ -134,8 +131,5 @@ pub fn division_unsigned_panic_dividend_0() {

let result = instance.invoke_func::<(i32, i32), i32>(0, (222, 0));

assert_eq!(
result.unwrap_err(),
wasm::Error::RuntimeError(wasm::RuntimeError::DivideBy0)
);
assert_eq!(result.unwrap_err(), RuntimeError(DivideBy0));
}

0 comments on commit 3b97d1a

Please sign in to comment.