diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index ff5691383c..64137bece2 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -228,10 +228,10 @@ mod solve_expr { infer_eq_without_problem( indoc!( r#" - Str.fromInt + Num.toStr "# ), - "Int * -> Str", + "Num * -> Str", ); } @@ -4543,8 +4543,8 @@ mod solve_expr { |> Str.concat ") (" |> Str.concat (printExpr b) |> Str.concat ")" - Val v -> Str.fromInt v - Var v -> "Var " |> Str.concat (Str.fromInt v) + Val v -> Num.toStr v + Var v -> "Var " |> Str.concat (Num.toStr v) main : Str main = printExpr (Var 3) diff --git a/compiler/test_gen/src/gen_num.rs b/compiler/test_gen/src/gen_num.rs index 359ea08f08..7c4ad96442 100644 --- a/compiler/test_gen/src/gen_num.rs +++ b/compiler/test_gen/src/gen_num.rs @@ -1990,3 +1990,35 @@ fn when_on_i16() { i16 ); } + +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn num_to_str() { + use roc_std::RocStr; + + assert_evals_to!( + r#"Num.toStr 1234"#, + RocStr::from_slice("1234".as_bytes()), + RocStr + ); + assert_evals_to!(r#"Num.toStr 0"#, RocStr::from_slice("0".as_bytes()), RocStr); + assert_evals_to!( + r#"Num.toStr -1"#, + RocStr::from_slice("-1".as_bytes()), + RocStr + ); + + let max = format!("{}", i64::MAX); + assert_evals_to!( + r#"Num.toStr Num.maxInt"#, + RocStr::from_slice(max.as_bytes()), + RocStr + ); + + let min = format!("{}", i64::MIN); + assert_evals_to!( + r#"Num.toStr Num.minInt"#, + RocStr::from_slice(min.as_bytes()), + RocStr + ); +} diff --git a/compiler/test_gen/src/gen_str.rs b/compiler/test_gen/src/gen_str.rs index 691ae32971..1b77aa9a64 100644 --- a/compiler/test_gen/src/gen_str.rs +++ b/compiler/test_gen/src/gen_str.rs @@ -527,40 +527,6 @@ fn str_starts_with_false_small_str() { assert_evals_to!(r#"Str.startsWith "1234" "23""#, false, bool); } -#[test] -#[cfg(any(feature = "gen-llvm"))] -fn str_from_int() { - assert_evals_to!( - r#"Str.fromInt 1234"#, - roc_std::RocStr::from_slice("1234".as_bytes()), - roc_std::RocStr - ); - assert_evals_to!( - r#"Str.fromInt 0"#, - roc_std::RocStr::from_slice("0".as_bytes()), - roc_std::RocStr - ); - assert_evals_to!( - r#"Str.fromInt -1"#, - roc_std::RocStr::from_slice("-1".as_bytes()), - roc_std::RocStr - ); - - let max = format!("{}", i64::MAX); - assert_evals_to!( - r#"Str.fromInt Num.maxInt"#, - RocStr::from_slice(max.as_bytes()), - RocStr - ); - - let min = format!("{}", i64::MIN); - assert_evals_to!( - r#"Str.fromInt Num.minInt"#, - RocStr::from_slice(min.as_bytes()), - RocStr - ); -} - #[test] #[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_pass_single_ascii() { @@ -838,8 +804,8 @@ fn nested_recursive_literal() { |> Str.concat ") (" |> Str.concat (printExpr b) |> Str.concat ")" - Val v -> "Val " |> Str.concat (Str.fromInt v) - Var v -> "Var " |> Str.concat (Str.fromInt v) + Val v -> "Val " |> Str.concat (Num.toStr v) + Var v -> "Var " |> Str.concat (Num.toStr v) printExpr expr "# @@ -875,12 +841,6 @@ fn str_join_comma_single() { assert_evals_to!(r#"Str.joinWith ["1"] ", " "#, RocStr::from("1"), RocStr); } -#[test] -#[cfg(any(feature = "gen-llvm"))] -fn str_from_float() { - assert_evals_to!(r#"Str.fromFloat 3.14"#, RocStr::from("3.14"), RocStr); -} - #[test] #[cfg(any(feature = "gen-llvm"))] fn str_to_utf8() { diff --git a/compiler/test_gen/src/wasm_str.rs b/compiler/test_gen/src/wasm_str.rs index 7dafb39a5f..7ee7a6a13c 100644 --- a/compiler/test_gen/src/wasm_str.rs +++ b/compiler/test_gen/src/wasm_str.rs @@ -446,39 +446,6 @@ fn str_starts_with_false_small_str() { assert_evals_to!(r#"Str.startsWith "1234" "23""#, false, bool); } -// #[test] -// fn str_from_int() { -// assert_evals_to!( -// r#"Str.fromInt 1234"#, -// roc_std::RocStr::from_slice("1234".as_bytes()), -// roc_std::RocStr -// ); -// assert_evals_to!( -// r#"Str.fromInt 0"#, -// roc_std::RocStr::from_slice("0".as_bytes()), -// roc_std::RocStr -// ); -// assert_evals_to!( -// r#"Str.fromInt -1"#, -// roc_std::RocStr::from_slice("-1".as_bytes()), -// roc_std::RocStr -// ); - -// let max = format!("{}", i64::MAX); -// assert_evals_to!( -// r#"Str.fromInt Num.maxInt"#, -// RocStr::from_slice(max.as_bytes()), -// RocStr -// ); - -// let min = format!("{}", i64::MIN); -// assert_evals_to!( -// r#"Str.fromInt Num.minInt"#, -// RocStr::from_slice(min.as_bytes()), -// RocStr -// ); -// } - // #[test] // fn str_from_utf8_pass_single_ascii() { // assert_evals_to!( @@ -729,8 +696,8 @@ fn str_starts_with_false_small_str() { // |> Str.concat ") (" // |> Str.concat (printExpr b) // |> Str.concat ")" -// Val v -> "Val " |> Str.concat (Str.fromInt v) -// Var v -> "Var " |> Str.concat (Str.fromInt v) +// Val v -> "Val " |> Str.concat (Num.toStr v) +// Var v -> "Var " |> Str.concat (Num.toStr v) // printExpr expr // "# @@ -763,11 +730,6 @@ fn str_starts_with_false_small_str() { // assert_evals_to!(r#"Str.joinWith ["1"] ", " "#, RocStr::from("1"), RocStr); // } -// #[test] -// fn str_from_float() { -// assert_evals_to!(r#"Str.fromFloat 3.14"#, RocStr::from("3.14"), RocStr); -// } - // #[test] // fn str_to_utf8() { // assert_evals_to!( diff --git a/docs/tests/insert_syntax_highlighting.rs b/docs/tests/insert_syntax_highlighting.rs index e211786673..ad75f0a64a 100644 --- a/docs/tests/insert_syntax_highlighting.rs +++ b/docs/tests/insert_syntax_highlighting.rs @@ -175,8 +175,8 @@ main = "Hello, world!" #[test] fn call_builtin() { expect_html_def( - r#"myVal = Str.fromInt 1234"#, - "myVal = Str.fromInt 1234\n\n", + r#"myVal = Num.toStr 1234"#, + "myVal = Num.toStr 1234\n\n", ); }