Fix test compile errors, and simply load_internal tests

This commit is contained in:
Ayaz Hafiz 2022-04-12 16:42:51 -04:00
parent cbbbb8c855
commit 865c1f15d7
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
7 changed files with 41 additions and 15 deletions

2
Cargo.lock generated
View file

@ -3737,7 +3737,6 @@ dependencies = [
"roc_target",
"roc_types",
"roc_unify",
"strip-ansi-escapes",
"tempfile",
"ven_pretty",
]
@ -4526,6 +4525,7 @@ dependencies = [
"roc_load",
"roc_module",
"roc_mono",
"roc_reporting",
"roc_target",
"test_mono_macros",
]

View file

@ -33,4 +33,3 @@ tempfile = "3.2.0"
pretty_assertions = "1.0.0"
maplit = "1.0.2"
indoc = "1.0.3"
strip-ansi-escapes = "0.1.1"

View file

@ -25,6 +25,7 @@ mod test_load {
use roc_problem::can::Problem;
use roc_region::all::LineInfo;
use roc_reporting::report::can_problem;
use roc_reporting::report::RenderTarget;
use roc_reporting::report::RocDocAllocator;
use roc_target::TargetInfo;
use roc_types::pretty_print::{content_to_string, name_all_type_vars};
@ -41,7 +42,7 @@ mod test_load {
) -> Result<LoadedModule, LoadingProblem<'a>> {
use LoadResult::*;
let load_start = LoadStart::from_path(arena, filename)?;
let load_start = LoadStart::from_path(arena, filename, RenderTarget::Generic)?;
match roc_load_internal::file::load(
arena,
@ -51,6 +52,7 @@ mod test_load {
Phase::SolveTypes,
target_info,
Default::default(), // these tests will re-compile the builtins
RenderTarget::Generic,
)? {
Monomorphized(_) => unreachable!(""),
TypeChecked(module) => Ok(module),
@ -88,8 +90,6 @@ mod test_load {
}
fn multiple_modules(files: Vec<(&str, &str)>) -> Result<LoadedModule, String> {
use roc_load_internal::file::LoadingProblem;
let arena = Bump::new();
let arena = &arena;
@ -589,18 +589,18 @@ mod test_load {
report,
indoc!(
"
\u{1b}[36m UNFINISHED LIST \u{1b}[0m
UNFINISHED LIST
I cannot find the end of this list:
I cannot find the end of this list:
\u{1b}[36m3\u{1b}[0m\u{1b}[36m\u{1b}[0m \u{1b}[37mmain = [\u{1b}[0m
\u{1b}[31m^\u{1b}[0m
3 main = [
^
You could change it to something like \u{1b}[33m[ 1, 2, 3 ]\u{1b}[0m or even just \u{1b}[33m[]\u{1b}[0m.
Anything where there is an open and a close square bracket, and where
the elements of the list are separated by commas.
You could change it to something like [ 1, 2, 3 ] or even just [].
Anything where there is an open and a close square bracket, and where
the elements of the list are separated by commas.
\u{1b}[4mNote\u{1b}[0m: I may be confused by indentation"
Note: I may be confused by indentation"
)
),
Ok(_) => unreachable!("we expect failure here"),
@ -769,8 +769,6 @@ mod test_load {
];
let err = multiple_modules(modules).unwrap_err();
let err = strip_ansi_escapes::strip(err).unwrap();
let err = String::from_utf8(err).unwrap();
assert_eq!(
err,
indoc!(

View file

@ -7,6 +7,7 @@ use roc_collections::all::MutSet;
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
use roc_mono::ir::OptLevel;
use roc_region::all::LineInfo;
use roc_reporting::report::RenderTarget;
use target_lexicon::Triple;
fn promote_expr_to_module(src: &str) -> String {
@ -57,6 +58,7 @@ fn create_llvm_module<'a>(
src_dir,
Default::default(),
target_info,
RenderTarget::ColorTerminal,
);
let mut loaded = match loaded {

View file

@ -17,6 +17,7 @@ roc_load = { path = "../load" }
roc_can = { path = "../can" }
roc_mono = { path = "../mono" }
roc_target = { path = "../roc_target" }
roc_reporting = { path = "../../reporting" }
test_mono_macros = { path = "../test_mono_macros" }
pretty_assertions = "1.0.0"
bumpalo = { version = "3.8.0", features = ["collections"] }

View file

@ -101,6 +101,7 @@ fn compiles_to_ir(test_name: &str, src: &str) {
src_dir,
Default::default(),
TARGET_INFO,
roc_reporting::report::RenderTarget::Generic,
);
let mut loaded = match loaded {

View file

@ -9462,4 +9462,29 @@ I need all branches in an `if` to have the same type!
),
)
}
#[test]
fn ability_specialization_is_incomplete() {
new_report_problem_as(
indoc!(
r#"
app "test" provides [ eq, le ] to "./platform"
Eq has
eq : a, a -> Bool | a has Eq
le : a, a -> Bool | a has Eq
Id := U64
eq = \$Id m, $Id n -> m == n
le = \$Id m, $Id n -> m < n
"#
),
indoc!(
r#"
"#
),
)
}
}