fix(repl) and fix(pretty_print): update pretty_print output for Num FloatingPoint * to be Float * instead of F64

This commit is contained in:
Sean Hagstrom 2022-04-15 13:36:27 +01:00
parent 34813eeae1
commit c67a1bb8d4
3 changed files with 18 additions and 7 deletions

View file

@ -2397,7 +2397,7 @@ mod solve_expr {
{ numIdentity, x : numIdentity 42, y } { numIdentity, x : numIdentity 42, y }
"# "#
), ),
"{ numIdentity : Num a -> Num a, x : Num a, y : F64 }", "{ numIdentity : Num a -> Num a, x : Num a, y : Float * }",
); );
} }
@ -3820,7 +3820,7 @@ mod solve_expr {
negatePoint { x: 1, y: 2.1, z: 0x3 } negatePoint { x: 1, y: 2.1, z: 0x3 }
"# "#
), ),
"{ x : Num a, y : F64, z : Int * }", "{ x : Num a, y : Float *, z : Int * }",
); );
} }
@ -3837,7 +3837,7 @@ mod solve_expr {
{ a, b } { a, b }
"# "#
), ),
"{ a : { x : Num a, y : F64, z : c }, b : { blah : Str, x : Num a, y : F64, z : c } }", "{ a : { x : Num a, y : Float *, z : c }, b : { blah : Str, x : Num a, y : Float *, z : c } }",
); );
} }

View file

@ -387,7 +387,18 @@ fn write_content<'a>(
false, false,
); );
} }
Symbol::NUM_FLOATINGPOINT => buf.push_str("F64"), Symbol::NUM_FLOATINGPOINT => {
let content = get_single_arg(subs, &args);
match content {
Alias(Symbol::NUM_BINARY32, _, _, _) => buf.push_str("F32"),
Alias(Symbol::NUM_BINARY64, _, _, _) => buf.push_str("F64"),
Alias(Symbol::NUM_DECIMAL, _, _, _) => buf.push_str("Dec"),
_ => write_parens!(write_parens, buf, {
buf.push_str("Float ");
write_content(env, ctx, content, subs, buf, parens);
}),
}
}
_ => write_parens!(write_parens, buf, { _ => write_parens!(write_parens, buf, {
buf.push_str("Num "); buf.push_str("Num ");

View file

@ -50,7 +50,7 @@ fn int_addition() {
#[test] #[test]
fn float_addition() { fn float_addition() {
expect_success("1.1 + 2", "3.1 : F64"); expect_success("1.1 + 2", "3.1 : Float *");
} }
#[cfg(not(feature = "wasm"))] #[cfg(not(feature = "wasm"))]
@ -309,7 +309,7 @@ fn nested_int_list() {
fn nested_float_list() { fn nested_float_list() {
expect_success( expect_success(
r#"[ [ [ 4, 3, 2 ], [ 1, 0.0 ] ], [ [] ], [] ]"#, r#"[ [ [ 4, 3, 2 ], [ 1, 0.0 ] ], [ [] ], [] ]"#,
r#"[ [ [ 4, 3, 2 ], [ 1, 0 ] ], [ [] ], [] ] : List (List (List F64))"#, r#"[ [ [ 4, 3, 2 ], [ 1, 0 ] ], [ [] ], [] ] : List (List (List (Float *)))"#,
); );
} }
@ -403,7 +403,7 @@ fn list_contains() {
fn list_sum() { fn list_sum() {
expect_success("List.sum []", "0 : Num *"); expect_success("List.sum []", "0 : Num *");
expect_success("List.sum [ 1, 2, 3 ]", "6 : Num *"); expect_success("List.sum [ 1, 2, 3 ]", "6 : Num *");
expect_success("List.sum [ 1.1, 2.2, 3.3 ]", "6.6 : F64"); expect_success("List.sum [ 1.1, 2.2, 3.3 ]", "6.6 : Float *");
} }
#[cfg(not(feature = "wasm"))] #[cfg(not(feature = "wasm"))]