Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 75 additions & 4 deletions tests/integration/src/end_to_end/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ fn overflowing_add_u64() {
test_overflowing_arith(u64::overflowing_add, "overflowing_add", NumericStrategy::full_range());
}

#[test]
fn overflowing_add_u128() {
test_overflowing_arith(u128::overflowing_add, "overflowing_add", NumericStrategy::full_range());
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1091"]
fn overflowing_add_i8() {
Expand All @@ -324,6 +329,11 @@ fn overflowing_add_i64() {
test_overflowing_arith(i64::overflowing_add, "overflowing_add", NumericStrategy::full_range());
}

#[test]
fn overflowing_add_i128() {
test_overflowing_arith(i128::overflowing_add, "overflowing_add", NumericStrategy::full_range());
}

#[test]
fn overflowing_sub_u8() {
test_overflowing_arith(u8::overflowing_sub, "overflowing_sub", NumericStrategy::full_range());
Expand All @@ -344,6 +354,11 @@ fn overflowing_sub_u64() {
test_overflowing_arith(u64::overflowing_sub, "overflowing_sub", NumericStrategy::full_range());
}

#[test]
fn overflowing_sub_u128() {
test_overflowing_arith(u128::overflowing_sub, "overflowing_sub", NumericStrategy::full_range());
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1091"]
fn overflowing_sub_i8() {
Expand All @@ -366,6 +381,11 @@ fn overflowing_sub_i64() {
test_overflowing_arith(i64::overflowing_sub, "overflowing_sub", NumericStrategy::full_range());
}

#[test]
fn overflowing_sub_i128() {
test_overflowing_arith(i128::overflowing_sub, "overflowing_sub", NumericStrategy::full_range());
}

#[test]
fn overflowing_mul_u8() {
test_overflowing_arith(u8::overflowing_mul, "overflowing_mul", NumericStrategy::full_range());
Expand All @@ -386,6 +406,12 @@ fn overflowing_mul_u64() {
test_overflowing_arith(u64::overflowing_mul, "overflowing_mul", NumericStrategy::full_range());
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1108"]
fn overflowing_mul_u128() {
test_overflowing_arith(u128::overflowing_mul, "overflowing_mul", NumericStrategy::full_range());
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1091"]
fn overflowing_mul_i8() {
Expand All @@ -408,6 +434,12 @@ fn overflowing_mul_i64() {
test_overflowing_arith(i64::overflowing_mul, "overflowing_mul", NumericStrategy::full_range());
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1108"]
fn overflowing_mul_i128() {
test_overflowing_arith(i128::overflowing_mul, "overflowing_mul", NumericStrategy::full_range());
}

#[test]
fn overflowing_div_u8() {
test_overflowing_arith(
Expand Down Expand Up @@ -444,6 +476,16 @@ fn overflowing_div_u64() {
);
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1110"]
fn overflowing_div_u128() {
test_overflowing_arith(
u128::overflowing_div,
"overflowing_div",
NumericStrategy::non_zero_rhs_unsigned(),
);
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/966"]
fn overflowing_div_i8() {
Expand Down Expand Up @@ -482,6 +524,16 @@ fn overflowing_div_i64() {
);
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1109"]
fn overflowing_div_i128() {
test_overflowing_arith(
i128::overflowing_div,
"overflowing_div",
NumericStrategy::non_zero_rhs_signed(),
);
}

#[test]
fn overflowing_rem_u8() {
test_overflowing_arith(
Expand Down Expand Up @@ -518,6 +570,16 @@ fn overflowing_rem_u64() {
);
}

#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1110"]
fn overflowing_rem_u128() {
test_overflowing_arith(
u128::overflowing_rem,
"overflowing_rem",
NumericStrategy::non_zero_rhs_unsigned(),
);
}

#[test]
#[ignore = "Mod is not supported for signed int"]
fn overflowing_rem_i8() {
Expand Down Expand Up @@ -558,7 +620,15 @@ fn overflowing_rem_i64() {
);
}

// TODO handle overflowing ops for wide types
#[test]
#[ignore = "https://github.com/0xMiden/compiler/issues/1111"]
fn overflowing_rem_i128() {
test_overflowing_arith(
i128::overflowing_rem,
"overflowing_rem",
NumericStrategy::non_zero_rhs_signed(),
);
}

#[test]
fn checked_add_u8() {
Expand Down Expand Up @@ -838,9 +908,10 @@ fn test_overflowing_arith<T>(

eval_package::<Felt, _, _>(&package, None, &args, &test.session, |trace| {
let ty_byte_size = std::mem::size_of::<T>();
assert!(ty_byte_size <= 8, "cannot handle types larger than 8 bytes");
// At most 9 bytes are written to memory: ty_byte_size <= 8 and 1 byte for the bool.
let x: [u8; 9] = trace.read_from_rust_memory(out_addr).expect("output was not written");
assert!(ty_byte_size <= 16, "cannot handle types larger than 16 bytes");
// At most 17 bytes are written to memory: ty_byte_size <= 16 and 1 byte for the bool.
let x: [u8; 17] =
trace.read_from_rust_memory(out_addr).expect("output was not written");
let vm_out_bytes = x[..ty_byte_size + 1].to_vec(); // only take what's actually written

let rs_out_bytes =
Expand Down