add load tests from ingested files

This commit is contained in:
Brendan Hansknecht 2023-04-04 18:48:46 -07:00
parent ff414610ca
commit 21d063da26
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
4 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,5 @@
interface IngestedFile
exposes [str]
imports ["IngestedFile.roc" as foo : Str]
str = foo

View file

@ -0,0 +1,5 @@
interface IngestedFileBytes
exposes [str]
imports ["IngestedFileBytes.roc" as foo : List U8]
str = Str.fromUtf8 foo |> Result.withDefault ""

View file

@ -0,0 +1,8 @@
interface MissingIngestedFile
exposes [unit]
imports ["ThisFileIsMissing" as data: List U8]
Unit : [Unit]
unit : Unit
unit = Unit

View file

@ -572,6 +572,34 @@ fn imported_dep_regression() {
);
}
#[test]
fn ingested_file() {
let subs_by_module = Default::default();
let loaded_module = load_fixture("interface_with_deps", "IngestedFile", subs_by_module);
expect_types(
loaded_module,
hashmap! {
"foo" => "Str",
"str" => "Str",
},
);
}
#[test]
fn ingested_file_bytes() {
let subs_by_module = Default::default();
let loaded_module = load_fixture("interface_with_deps", "IngestedFileBytes", subs_by_module);
expect_types(
loaded_module,
hashmap! {
"foo" => "List U8",
"str" => "Str",
},
);
}
#[test]
fn parse_problem() {
let modules = vec![(
@ -639,6 +667,20 @@ fn imported_file_not_found() {
);
}
#[test]
#[should_panic(expected = "FILE NOT FOUND")]
fn ingested_file_not_found() {
let subs_by_module = Default::default();
let loaded_module = load_fixture("no_deps", "MissingIngestedFile", subs_by_module);
expect_types(
loaded_module,
hashmap! {
"str" => "Str",
},
);
}
#[test]
fn platform_does_not_exist() {
let modules = vec![(