chore: workaround for #230 (#231)

* Workaround for debug panic

* Use Rust exception handler 💀
This commit is contained in:
Ahmad Afuni 2025-05-14 00:22:11 +10:00 committed by GitHub
parent cd40219ba6
commit f5a1aa7523
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1362,7 +1362,19 @@ mod tests {
]
.into_iter()
.for_each(|(op, st)| {
assert!(operation_verify(st, op, prev_statements.to_vec(), vec![]).is_err())
let check = std::panic::catch_unwind(|| {
operation_verify(st, op, prev_statements.to_vec(), vec![])
});
match check {
Err(e) => {
let err_string = e.downcast_ref::<String>().unwrap();
if !err_string.contains("Integer too large to fit") {
panic!("Test failed with an unexpected error: {}", err_string);
}
}
Ok(Err(_)) => {}
_ => panic!("Test passed, yet it should have failed!"),
}
});
}
@ -1877,8 +1889,21 @@ mod tests {
],
OperationAux::None,
);
let prev_statements = vec![st1, st2, st3];
assert!(operation_verify(st, op, prev_statements, vec![]).is_err())
let prev_statements = [st1, st2, st3];
let check = std::panic::catch_unwind(|| {
operation_verify(st, op, prev_statements.to_vec(), vec![])
});
match check {
Err(e) => {
let err_string = e.downcast_ref::<String>().unwrap();
if !err_string.contains("Integer too large to fit") {
panic!("Test failed with an unexpected error: {}", err_string);
}
}
Ok(Err(_)) => {}
_ => panic!("Test passed, yet it should have failed!"),
}
})
}