mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
Expect no longer crashes
This commit is contained in:
parent
0ed013b928
commit
8fc663b735
4 changed files with 17 additions and 2 deletions
|
@ -25,6 +25,9 @@ comptime {
|
||||||
@export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong });
|
@export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong });
|
||||||
@export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong });
|
@export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong });
|
||||||
@export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong });
|
@export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong });
|
||||||
|
@export(testing_roc_expect_failed, .{ .name = "roc_expect_failed", .linkage = .Strong });
|
||||||
|
} else {
|
||||||
|
@export(expect_failed, .{ .name = "roc_expect_failed", .linkage = .Strong });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +48,16 @@ fn testing_roc_dealloc(c_ptr: *c_void, _: u32) callconv(.C) void {
|
||||||
std.testing.allocator.destroy(ptr);
|
std.testing.allocator.destroy(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn testing_roc_expect_failed() callconv(.C) void {
|
||||||
|
const stderr = std.io.getStdErr().writer();
|
||||||
|
stderr.print("Expect failed inside test\n", .{}) catch unreachable;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expect_failed() callconv(.C) void {
|
||||||
|
const stderr = std.io.getStdErr().writer();
|
||||||
|
stderr.print("Expect failed outside test\n", .{}) catch unreachable;
|
||||||
|
}
|
||||||
|
|
||||||
fn testing_roc_panic(c_ptr: *c_void, tag_id: u32) callconv(.C) void {
|
fn testing_roc_panic(c_ptr: *c_void, tag_id: u32) callconv(.C) void {
|
||||||
_ = c_ptr;
|
_ = c_ptr;
|
||||||
_ = tag_id;
|
_ = tag_id;
|
||||||
|
|
|
@ -82,3 +82,4 @@ pub const DEC_MUL_WITH_OVERFLOW: &str = "roc_builtins.dec.mul_with_overflow";
|
||||||
pub const DEC_DIV: &str = "roc_builtins.dec.div";
|
pub const DEC_DIV: &str = "roc_builtins.dec.div";
|
||||||
|
|
||||||
pub const UTILS_TEST_PANIC: &str = "roc_builtins.utils.test_panic";
|
pub const UTILS_TEST_PANIC: &str = "roc_builtins.utils.test_panic";
|
||||||
|
pub const EXPECT_FAILED: &str = "roc_expect_failed";
|
||||||
|
|
|
@ -5175,8 +5175,9 @@ fn run_low_level<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
bd.position_at_end(throw_block);
|
bd.position_at_end(throw_block);
|
||||||
|
|
||||||
throw_exception(env, "assert failed!");
|
call_void_bitcode_fn(env, &[], bitcode::EXPECT_FAILED);
|
||||||
|
|
||||||
|
bd.build_unconditional_branch(then_block);
|
||||||
bd.position_at_end(then_block);
|
bd.position_at_end(then_block);
|
||||||
|
|
||||||
cond
|
cond
|
||||||
|
|
|
@ -2398,7 +2398,7 @@ fn call_invalid_layout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "assert failed!")]
|
// #[should_panic(expected = "assert failed!")]
|
||||||
fn expect_fail() {
|
fn expect_fail() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue