make exceptions work on linux again

This commit is contained in:
Folkert 2020-12-21 02:12:30 +01:00
parent afd3991bc9
commit 725d52f7c6
4 changed files with 65 additions and 33 deletions

View file

@ -253,6 +253,7 @@ fn link_linux(
.collect::<HashMap<String, String>>(), .collect::<HashMap<String, String>>(),
) )
.args(&[ .args(&[
"--eh-frame-hdr",
"-arch", "-arch",
arch_str(target), arch_str(target),
libcrt_path.join("crti.o").to_str().unwrap(), libcrt_path.join("crti.o").to_str().unwrap(),

View file

@ -613,19 +613,19 @@ mod gen_num {
assert_evals_to!("Num.atan 10", 1.4711276743037347, f64); assert_evals_to!("Num.atan 10", 1.4711276743037347, f64);
} }
// #[test] #[test]
// #[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)] #[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)]
// fn int_overflow() { fn int_overflow() {
// assert_evals_to!( assert_evals_to!(
// indoc!( indoc!(
// r#" r#"
// 9_223_372_036_854_775_807 + 1 9_223_372_036_854_775_807 + 1
// "# "#
// ), ),
// 0, 0,
// i64 i64
// ); );
// } }
#[test] #[test]
fn int_add_checked() { fn int_add_checked() {

View file

@ -885,22 +885,39 @@ mod gen_primitives {
); );
} }
// #[test] #[test]
// #[should_panic(expected = "Roc failed with message: ")] #[should_panic(expected = "Roc failed with message: ")]
// fn exception() { fn undefined_variable() {
// assert_evals_to!( assert_evals_to!(
// indoc!( indoc!(
// r#" r#"
// if True then if True then
// x + z x + z
// else else
// y + z y + z
// "# "#
// ), ),
// 3, 3,
// i64 i64
// ); );
// } }
#[test]
#[should_panic(expected = "Roc failed with message: ")]
fn annotation_without_body() {
assert_evals_to!(
indoc!(
r#"
foo : I64
foo
"#
),
3,
i64
);
}
#[test] #[test]
fn closure() { fn closure() {

View file

@ -102,9 +102,19 @@ pub fn helper<'a>(
for problem in can_problems.into_iter() { for problem in can_problems.into_iter() {
// Ignore "unused" problems // Ignore "unused" problems
match problem { match problem {
UnusedDef(_, _) | UnusedArgument(_, _, _) | UnusedImport(_, _) => { UnusedDef(_, _)
delayed_errors.push(problem); | UnusedArgument(_, _, _)
continue; | UnusedImport(_, _)
| RuntimeError(_)
| ExposedButNotDefined(_) => {
delayed_errors.push(problem.clone());
let report = can_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette);
lines.push(buf);
} }
_ => { _ => {
let report = can_problem(&alloc, module_path.clone(), problem); let report = can_problem(&alloc, module_path.clone(), problem);
@ -138,7 +148,11 @@ pub fn helper<'a>(
if !lines.is_empty() { if !lines.is_empty() {
println!("{}", lines.join("\n")); println!("{}", lines.join("\n"));
assert_eq!(0, 1, "Mistakes were made");
// only crash at this point if there were no delayed_errors
if delayed_errors.is_empty() {
assert_eq!(0, 1, "Mistakes were made");
}
} }
let module = roc_gen::llvm::build::module_from_builtins(context, "app"); let module = roc_gen::llvm::build::module_from_builtins(context, "app");