mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-13 09:49:11 +03:00
Fix load tests
This commit is contained in:
parent
ce4469de80
commit
a7eb568267
@ -1,6 +1,7 @@
|
||||
app "primary"
|
||||
provides [ blah2, blah3, str, alwaysThree, identity, z, w, succeed, withDefault, yay ]
|
||||
packages { blah: "./blah" }
|
||||
imports [ Dep1, Dep2.{ two, foo }, Dep3.Blah.{ bar }, Res ]
|
||||
provides [ blah2, blah3, str, alwaysThree, identity, z, w, succeed, withDefault, yay ] to blah
|
||||
|
||||
blah2 = Dep2.two
|
||||
blah3 = bar
|
||||
@ -12,7 +13,7 @@ alwaysThree = \_ -> "foo"
|
||||
|
||||
identity = \a -> a
|
||||
|
||||
z = identity (Primary.alwaysThree {})
|
||||
z = identity (alwaysThree {})
|
||||
|
||||
w : Dep1.Identity {}
|
||||
w = Identity {}
|
||||
|
@ -1,7 +1,6 @@
|
||||
app "quicksort"
|
||||
packages {}
|
||||
imports []
|
||||
provides [ swap, partition, partitionHelp, quicksort ] to "blah"
|
||||
packages { base: "./platform" }
|
||||
provides [ swap, partition, partitionHelp, quicksort ] to base
|
||||
|
||||
quicksort : List (Num a), Int, Int -> List (Num a)
|
||||
quicksort = \list, low, high ->
|
||||
|
@ -1,4 +1,4 @@
|
||||
app "quicksort-one-def" provides [ quicksort ] imports []
|
||||
app "quicksort" packages { base: "./platform" } provides [ quicksort ] to base
|
||||
|
||||
quicksort = \originalList ->
|
||||
quicksortHelp : List (Num a), Int, Int -> List (Num a)
|
||||
|
@ -23,6 +23,7 @@ mod test_load {
|
||||
use roc_collections::all::MutMap;
|
||||
use roc_constrain::module::SubsByModule;
|
||||
use roc_load::file::LoadedModule;
|
||||
use roc_module::ident::ModuleName;
|
||||
use roc_module::symbol::{Interns, ModuleId};
|
||||
use roc_types::pretty_print::{content_to_string, name_all_type_vars};
|
||||
use roc_types::subs::Subs;
|
||||
@ -148,7 +149,10 @@ mod test_load {
|
||||
.get_name(loaded_module.module_id)
|
||||
.expect("Test ModuleID not found in module_ids");
|
||||
|
||||
assert_eq!(expected_name, &InlinableString::from(module_name));
|
||||
// App module names are hardcoded and not based on anything user-specified
|
||||
if expected_name != ModuleName::APP {
|
||||
assert_eq!(expected_name, &InlinableString::from(module_name));
|
||||
}
|
||||
|
||||
loaded_module
|
||||
}
|
||||
@ -256,7 +260,10 @@ mod test_load {
|
||||
"Main",
|
||||
indoc!(
|
||||
r#"
|
||||
app "test-app" provides [ main ] imports [ RBTree ]
|
||||
app "test-app"
|
||||
packages { blah: "./blah" }
|
||||
imports [ RBTree ]
|
||||
provides [ main ] to blah
|
||||
|
||||
empty : RBTree.Dict Int Int
|
||||
empty = RBTree.empty
|
||||
|
@ -2271,6 +2271,42 @@ mod test_parse {
|
||||
assert_eq!(Ok(expected), actual);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_app_header() {
|
||||
let arena = Bump::new();
|
||||
let packages = Vec::new_in(&arena);
|
||||
let imports = Vec::new_in(&arena);
|
||||
let provides = Vec::new_in(&arena);
|
||||
let module_name = StrLiteral::PlainLine("test-app");
|
||||
let expected = AppHeader {
|
||||
name: Located::new(0, 0, 4, 14, module_name),
|
||||
packages,
|
||||
imports,
|
||||
provides,
|
||||
to: Located::new(0, 0, 30, 34, "blah"),
|
||||
after_app_keyword: &[],
|
||||
before_packages: &[],
|
||||
after_packages: &[],
|
||||
before_imports: &[],
|
||||
after_imports: &[],
|
||||
before_provides: &[],
|
||||
after_provides: &[],
|
||||
before_to: &[],
|
||||
after_to: &[],
|
||||
};
|
||||
|
||||
let src = indoc!(
|
||||
r#"
|
||||
app "quicksort" packages { base: "./platform" } provides [ quicksort ] to base
|
||||
"#
|
||||
);
|
||||
let actual = app_header()
|
||||
.parse(&arena, State::new(src.as_bytes(), Attempting::Module))
|
||||
.map(|tuple| tuple.0);
|
||||
|
||||
assert_eq!(Ok(expected), actual);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_interface_header() {
|
||||
let arena = Bump::new();
|
||||
|
@ -1,4 +1,4 @@
|
||||
app "quicksort" provides [ quicksort ] to "./platform"
|
||||
app "quicksort" packages { base: "./platform" } provides [ quicksort ] to base
|
||||
|
||||
quicksort = \originalList ->
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
app "quicksort" provides [ quicksort ] to "./platform"
|
||||
app "quicksort" packages { base: "./platform" } provides [ quicksort ] to base
|
||||
|
||||
quicksort : List Int -> List Int
|
||||
quicksort = \originalList -> helper originalList
|
||||
|
Loading…
Reference in New Issue
Block a user