Add solve test

This commit is contained in:
Ayaz Hafiz 2022-05-18 13:57:24 -04:00
parent 6d19f31574
commit 253cca63ea
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58

View File

@ -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",
)
}
}