mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
add Num.toNat
This commit is contained in:
parent
4e3c3ee045
commit
d681062c63
6 changed files with 48 additions and 2 deletions
|
@ -2179,6 +2179,12 @@ to_int_tests! {
|
|||
to_u128_same_width, "15i128", 15
|
||||
to_u128_extend, "15i8", 15
|
||||
)
|
||||
"Num.toNat", usize, (
|
||||
to_nat_same_width, "15i64", 15, ["gen-wasm"]
|
||||
to_nat_extend, "15i8", 15, ["gen-wasm"]
|
||||
to_nat_truncate, "115i128", 115
|
||||
to_nat_truncate_wraps, "10_000_000_000_000_000_000_000i128", 1864712049423024128
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! to_int_checked_tests {
|
||||
|
@ -2312,6 +2318,18 @@ to_int_checked_tests! {
|
|||
to_u128_checked_same_width_signed_fits, "15i128", 15
|
||||
to_u128_checked_same_width_signed_oob, "-1i128", None
|
||||
)
|
||||
"Num.toNatChecked", usize, (
|
||||
to_nat_checked_smaller_width_pos, "15i8", 15
|
||||
to_nat_checked_smaller_width_neg_oob, "-15i8", None
|
||||
to_nat_checked_same, "15u64", 15
|
||||
to_nat_checked_same_width_signed_fits, "15i64", 15
|
||||
to_nat_checked_same_width_signed_oob, "-1i64", None
|
||||
to_nat_checked_larger_width_signed_fits_pos, "15i128", 15
|
||||
to_nat_checked_larger_width_signed_oob_pos, "18446744073709551616i128", None
|
||||
to_nat_checked_larger_width_signed_oob_neg, "-1i128", None
|
||||
to_nat_checked_larger_width_unsigned_fits_pos, "15u128", 15
|
||||
to_nat_checked_larger_width_unsigned_oob_pos, "18446744073709551616u128", None
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue