Merge pull request #5178 from roc-lang/i5089

Ranged number abilities are derived and compiled correctly
This commit is contained in:
Folkert de Vries 2023-03-22 22:21:18 +01:00 committed by GitHub
commit ffaa4a1c1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 2 deletions

View file

@ -485,6 +485,25 @@ mod encode_immediate {
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn ranged_number() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Json] provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes [1, 2, 3] Json.toUtf8) is
Ok s -> s
_ -> "<bad>"
"#
),
RocStr::from(r"[1,2,3]"),
RocStr
)
}
macro_rules! num_immediate {
($($num:expr, $typ:ident)*) => {$(
#[test]
@ -960,6 +979,28 @@ mod decode_immediate {
)
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn ranged_number() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
main =
input = Str.toUtf8 "[1,2,3]"
expected = [1,2,3]
actual = Decode.fromBytes input Json.fromUtf8 |> Result.withDefault []
actual == expected
"#
),
true,
bool
)
}
macro_rules! num_immediate {
($($num:expr, $typ:ident)*) => {$(
#[test]