mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Merge pull request #5178 from roc-lang/i5089
Ranged number abilities are derived and compiled correctly
This commit is contained in:
commit
ffaa4a1c1d
4 changed files with 52 additions and 2 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue