diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml index ea8904f..af39515 100644 --- a/.github/workflows/rust_test.yml +++ b/.github/workflows/rust_test.yml @@ -8,7 +8,6 @@ on: env: CARGO_TERM_COLOR: always - NO_COLOR: 1 jobs: build: diff --git a/justfile b/justfile index ea1f6ed..c099d8f 100644 --- a/justfile +++ b/justfile @@ -2,10 +2,10 @@ alias t := test test: - CARGO_TERM_COLOR=always NO_COLOR=1 cargo test + cargo test -update-expects: - CARGO_TERM_COLOR=always NO_COLOR=1 UPDATE_EXPECT=1 cargo test +u-exp: + UPDATE_EXPECT=1 cargo test publish: cargo publish -p petr-utils diff --git a/petr-typecheck/src/lib.rs b/petr-typecheck/src/lib.rs index b1e60d9..0b5baa0 100644 --- a/petr-typecheck/src/lib.rs +++ b/petr-typecheck/src/lib.rs @@ -959,7 +959,7 @@ impl TypeCheck for petr_resolve::FunctionCall { mod tests { use expect_test::{expect, Expect}; use petr_resolve::resolve_symbols; - use petr_utils::{render_error, SourceId}; + use petr_utils::render_error; use super::*; fn check( @@ -971,20 +971,17 @@ mod tests { let (ast, errs, interner, source_map) = parser.into_result(); if !errs.is_empty() { errs.into_iter().for_each(|err| eprintln!("{:?}", render_error(&source_map, err))); - panic!("fmt failed: code didn't parse"); + panic!("test failed: code didn't parse"); } let (errs, resolved) = resolve_symbols(ast, interner, Default::default()); assert!(errs.is_empty(), "can't typecheck: unresolved symbols"); let type_checker = TypeChecker::new(resolved); - let res = pretty_print_type_checker(type_checker, &source_map); + let res = pretty_print_type_checker(type_checker); expect.assert_eq(&res); } - fn pretty_print_type_checker( - type_checker: TypeChecker, - source_map: &IndexMap, - ) -> String { + fn pretty_print_type_checker(type_checker: TypeChecker) -> String { let mut s = String::new(); for (id, ty) in &type_checker.type_map { let text = match id { @@ -1023,8 +1020,7 @@ mod tests { if !type_checker.errors.is_empty() { s.push_str("\nErrors:\n"); for error in type_checker.errors { - let rendered = render_error(source_map, error); - s.push_str(&format!("{:?}\n", rendered)); + s.push_str(&format!("{:?}\n", error)); } } s @@ -1276,14 +1272,7 @@ mod tests { Errors: - × Failed to unify types: String, Boolean - ╭─[test:2:1] - 2 │ fn my_func() returns 'unit - 3 │ @puts(true) - · ──┬─ - · ╰── Failed to unify types: String, Boolean - ╰──── - + SpannedItem UnificationFailure(String, Boolean) [Span { source: SourceId(0), span: SourceSpan { offset: SourceOffset(52), length: 4 } }] "#]], ); } @@ -1320,14 +1309,7 @@ mod tests { Errors: - × Failed to unify types: String, Boolean - ╭─[test:5:1] - 5 │ fn my_func() returns 'unit - 6 │ @puts(~bool_literal) - · ───────┬────── - · ╰── Failed to unify types: String, Boolean - ╰──── - + SpannedItem UnificationFailure(String, Boolean) [Span { source: SourceId(0), span: SourceSpan { offset: SourceOffset(110), length: 14 } }] "#]], ); } @@ -1371,15 +1353,7 @@ mod tests { Errors: - × Failed to unify types: Integer, Boolean - ╭─[test:1:1] - 1 │ - 2 │ fn my_list() returns 'list [ 1, true ] - · ──┬── - · ╰── Failed to unify types: Integer, Boolean - 3 │ - ╰──── - + SpannedItem UnificationFailure(Integer, Boolean) [Span { source: SourceId(0), span: SourceSpan { offset: SourceOffset(48), length: 5 } }] "#]], ); } @@ -1401,15 +1375,7 @@ mod tests { Errors: - × Function add takes 2 arguments, but got 1 arguments. - ╭─[test:3:1] - 3 │ - 4 │ fn add_five(a in 'int) returns 'int ~add(5) - · ────┬─── - · ╰── Function add takes 2 arguments, but got 1 arguments. - 5 │ - ╰──── - + SpannedItem ArgumentCountMismatch { function: "add", expected: 2, got: 1 } [Span { source: SourceId(0), span: SourceSpan { offset: SourceOffset(113), length: 8 } }] "#]], ); } diff --git a/petr-vm/src/lib.rs b/petr-vm/src/lib.rs index 3f30fbb..9862829 100644 Binary files a/petr-vm/src/lib.rs and b/petr-vm/src/lib.rs differ