mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Swap out expect_runtime_error_panic for assert_evals_to
This commit is contained in:
parent
eef51c9d87
commit
e6cd64f161
1 changed files with 35 additions and 19 deletions
|
@ -1,45 +1,55 @@
|
|||
use indoc::indoc;
|
||||
use roc_std::RocList;
|
||||
|
||||
#[cfg(feature = "gen-llvm")]
|
||||
use crate::helpers::llvm::expect_runtime_error_panic;
|
||||
use crate::helpers::llvm::assert_evals_to;
|
||||
|
||||
#[cfg(feature = "gen-wasm")]
|
||||
use crate::helpers::wasm::expect_runtime_error_panic;
|
||||
use crate::helpers::wasm::assert_evals_to;
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[should_panic = r#"User crash with message: "hello crash""#]
|
||||
fn crash_literal() {
|
||||
expect_runtime_error_panic!(indoc!(
|
||||
r#"
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main = if Bool.true then crash "hello crash" else 1u8
|
||||
"#
|
||||
));
|
||||
),
|
||||
1u8,
|
||||
u8
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[should_panic = r#"User crash with message: "hello crash""#]
|
||||
fn crash_variable() {
|
||||
expect_runtime_error_panic!(indoc!(
|
||||
r#"
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
msg = "hello crash"
|
||||
if Bool.true then crash msg else 1u8
|
||||
"#
|
||||
));
|
||||
),
|
||||
1u8,
|
||||
u8
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[should_panic = r#"User crash with message: "turns out this was fallible""#]
|
||||
fn crash_in_call() {
|
||||
expect_runtime_error_panic!(indoc!(
|
||||
r#"
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
getInfallible = \result -> when result is
|
||||
|
@ -51,19 +61,25 @@ fn crash_in_call() {
|
|||
x = Err ""
|
||||
getInfallible x
|
||||
"#
|
||||
));
|
||||
),
|
||||
1u64,
|
||||
u64
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
// wasm: blocked on "compiling function underran the stack" in wasm3
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[should_panic = r#"User crash with message: "no new even primes""#]
|
||||
fn crash_in_passed_closure() {
|
||||
expect_runtime_error_panic!(indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main = List.map [1, 2, 3] \n -> if n == 2 then crash "no new even primes" else ""
|
||||
"#
|
||||
));
|
||||
main = List.map [1, 2, 3] \n -> if n == 2 then crash "no new even primes" else ""
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[1u8]),
|
||||
RocList<u8>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue