mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
bytesToU16 and bytesToU32 have proper types
This commit is contained in:
parent
2d65bfdb5f
commit
a4197d073c
3 changed files with 138 additions and 143 deletions
|
@ -1638,7 +1638,7 @@ mod gen_num {
|
|||
"#
|
||||
),
|
||||
40,
|
||||
usize
|
||||
u16
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1654,7 +1654,7 @@ mod gen_num {
|
|||
"#
|
||||
),
|
||||
1,
|
||||
usize
|
||||
u16
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1664,23 +1664,46 @@ mod gen_num {
|
|||
indoc!(
|
||||
r#"
|
||||
bytes = Str.toUtf8 "hello"
|
||||
when Num.bytesToU16 bytes 4 is
|
||||
when Num.bytesToU32 bytes 0 is
|
||||
Ok v -> v
|
||||
Err OutOfBounds -> 1
|
||||
"#
|
||||
),
|
||||
1,
|
||||
usize
|
||||
41,
|
||||
u32
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn potato_4() {
|
||||
assert_evals_to!("Num.bytesToU32 [] 1", 41, u32);
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
bytes = Str.toUtf8 "hello"
|
||||
when Num.bytesToU32 bytes 234 is
|
||||
Ok v -> v
|
||||
Err OutOfBounds -> 1
|
||||
"#
|
||||
),
|
||||
1,
|
||||
u32
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn potato_5() {
|
||||
assert_evals_to!("Num.bytesToU32 [] 0", 41, u32);
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
bytes = Str.toUtf8 "hello"
|
||||
when Num.bytesToU32 bytes 2 is
|
||||
Ok v -> v
|
||||
Err OutOfBounds -> 1
|
||||
"#
|
||||
),
|
||||
1,
|
||||
u32
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue