mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
Constrain and solve import params
No reporting yet
This commit is contained in:
parent
c541dd5747
commit
5ec4b042bb
18 changed files with 238 additions and 26 deletions
|
@ -1564,7 +1564,7 @@ fn cannot_use_original_name_if_imported_with_alias() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn import_module_params_no_warn() {
|
||||
fn module_params_checks() {
|
||||
let modules = vec![
|
||||
(
|
||||
"Api.roc",
|
||||
|
@ -1590,10 +1590,73 @@ fn import_module_params_no_warn() {
|
|||
),
|
||||
];
|
||||
|
||||
let result = multiple_modules("module_params_typecheck", modules);
|
||||
let result = multiple_modules("module_params_checks", modules);
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_params_optional() {
|
||||
let modules = vec![
|
||||
(
|
||||
"Api.roc",
|
||||
indoc!(
|
||||
r#"
|
||||
module { key, exp ? "default" } -> [url]
|
||||
|
||||
url = "example.com/$(key)?exp=$(exp)"
|
||||
"#
|
||||
),
|
||||
),
|
||||
(
|
||||
"Main.roc",
|
||||
indoc!(
|
||||
r#"
|
||||
module [example]
|
||||
|
||||
import Api { key: "abcdef" }
|
||||
|
||||
example = Api.url
|
||||
"#
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
let result = multiple_modules("module_params_optional", modules);
|
||||
assert!(result.is_ok())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn module_params_typecheck_fail() {
|
||||
let modules = vec![
|
||||
(
|
||||
"Api.roc",
|
||||
indoc!(
|
||||
r#"
|
||||
module { key } -> [url]
|
||||
|
||||
url = "example.com/$(key)"
|
||||
"#
|
||||
),
|
||||
),
|
||||
(
|
||||
"Main.roc",
|
||||
indoc!(
|
||||
r#"
|
||||
module [example]
|
||||
|
||||
import Api { key: 123 }
|
||||
|
||||
example = Api.url
|
||||
"#
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
multiple_modules("module_params_typecheck", modules).unwrap_err();
|
||||
// todo(agus): test reporting
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_2863_module_type_does_not_exist() {
|
||||
let modules = vec![
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue