mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
Add solve test
This commit is contained in:
parent
6d19f31574
commit
253cca63ea
@ -154,7 +154,8 @@ mod solve_expr {
|
||||
mut type_problems,
|
||||
interns,
|
||||
mut solved,
|
||||
exposed_to_host,
|
||||
mut exposed_to_host,
|
||||
abilities_store,
|
||||
..
|
||||
},
|
||||
src,
|
||||
@ -172,6 +173,8 @@ mod solve_expr {
|
||||
|
||||
let subs = solved.inner_mut();
|
||||
|
||||
exposed_to_host.retain(|s, _| !abilities_store.is_specialization_name(*s));
|
||||
|
||||
debug_assert!(exposed_to_host.len() == 1);
|
||||
let (_symbol, variable) = exposed_to_host.into_iter().next().unwrap();
|
||||
let actual_str = name_and_print_var(variable, subs, home, &interns);
|
||||
@ -6426,4 +6429,30 @@ mod solve_expr {
|
||||
&["A#default : {} -> A"],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stdlib_encode_json() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test"
|
||||
imports [ Encode.{ toEncoder }, Json ]
|
||||
provides [ main ] to "./platform"
|
||||
|
||||
HelloWorld := {}
|
||||
|
||||
toEncoder = \@HelloWorld {} ->
|
||||
Encode.custom \bytes, fmt ->
|
||||
bytes
|
||||
|> Encode.appendWith (Encode.string "Hello, World!\n") fmt
|
||||
|
||||
main =
|
||||
when Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) Json.format) is
|
||||
Ok s -> s
|
||||
_ -> "<bad>"
|
||||
"#
|
||||
),
|
||||
"Str",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user