mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
wasm: add expect_runtime_error_panic test macro
This commit is contained in:
parent
5882ee4af0
commit
561a1d16ff
1 changed files with 18 additions and 5 deletions
|
@ -354,12 +354,9 @@ macro_rules! assert_evals_to {
|
||||||
$crate::helpers::wasm::assert_evals_to!($src, $expected, $ty, $transform, false);
|
$crate::helpers::wasm::assert_evals_to!($src, $expected, $ty, $transform, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
// LLVM tests call the last arg $ignore_problems rather than $expect_panic
|
($src:expr, $expected:expr, $ty:ty, $transform:expr, $ignore_problems: expr) => {{
|
||||||
// Either way, it's only `true` for tests that use `should_panic`.
|
|
||||||
// In Wasm, `should_panic` only works if we spawn a child process.
|
|
||||||
($src:expr, $expected:expr, $ty:ty, $transform:expr, $expect_panic: expr) => {{
|
|
||||||
let phantom = std::marker::PhantomData;
|
let phantom = std::marker::PhantomData;
|
||||||
let _ = $expect_panic; // TODO
|
let _ = $ignore_problems; // Always ignore "problems"! One backend (LLVM) is enough to cover them.
|
||||||
match $crate::helpers::wasm::assert_evals_to_help::<$ty>($src, phantom) {
|
match $crate::helpers::wasm::assert_evals_to_help::<$ty>($src, phantom) {
|
||||||
Err(msg) => panic!("{}", msg),
|
Err(msg) => panic!("{}", msg),
|
||||||
Ok(actual) => {
|
Ok(actual) => {
|
||||||
|
@ -369,6 +366,19 @@ macro_rules! assert_evals_to {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_macros)]
|
||||||
|
macro_rules! expect_runtime_error_panic {
|
||||||
|
($src:expr) => {{
|
||||||
|
$crate::helpers::wasm::assert_evals_to!(
|
||||||
|
$src,
|
||||||
|
false, // fake value/type for eval
|
||||||
|
bool,
|
||||||
|
$crate::helpers::wasm::identity,
|
||||||
|
true // ignore problems
|
||||||
|
);
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn identity<T>(value: T) -> T {
|
pub fn identity<T>(value: T) -> T {
|
||||||
value
|
value
|
||||||
|
@ -396,5 +406,8 @@ macro_rules! assert_refcounts {
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub(crate) use assert_evals_to;
|
pub(crate) use assert_evals_to;
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub(crate) use expect_runtime_error_panic;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub(crate) use assert_refcounts;
|
pub(crate) use assert_refcounts;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue