mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-21 07:49:17 +03:00
Merge pull request #3659 from rtfeldman/when-on-128bit-numbers
when on 128-bit numbers
This commit is contained in:
commit
fffe9ca8ee
@ -1387,8 +1387,6 @@ fn test_to_equality<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Test::IsInt(test_int, precision) => {
|
Test::IsInt(test_int, precision) => {
|
||||||
// TODO don't downcast i128 here
|
|
||||||
debug_assert!(i128::from_ne_bytes(test_int) <= i64::MAX as i128);
|
|
||||||
let lhs = Expr::Literal(Literal::Int(test_int));
|
let lhs = Expr::Literal(Literal::Int(test_int));
|
||||||
let lhs_symbol = env.unique_symbol();
|
let lhs_symbol = env.unique_symbol();
|
||||||
stores.push((lhs_symbol, Layout::int_width(precision), lhs));
|
stores.push((lhs_symbol, Layout::int_width(precision), lhs));
|
||||||
|
@ -8957,7 +8957,7 @@ impl NumLiteral {
|
|||||||
fn to_pattern(&self) -> Pattern<'static> {
|
fn to_pattern(&self) -> Pattern<'static> {
|
||||||
match *self {
|
match *self {
|
||||||
NumLiteral::Int(n, w) => Pattern::IntLiteral(n, w),
|
NumLiteral::Int(n, w) => Pattern::IntLiteral(n, w),
|
||||||
NumLiteral::U128(_) => todo!(),
|
NumLiteral::U128(n) => Pattern::IntLiteral(n, IntWidth::U128),
|
||||||
NumLiteral::Float(n, w) => Pattern::FloatLiteral(f64::to_bits(n), w),
|
NumLiteral::Float(n, w) => Pattern::FloatLiteral(f64::to_bits(n), w),
|
||||||
NumLiteral::Decimal(n) => Pattern::DecimalLiteral(n),
|
NumLiteral::Decimal(n) => Pattern::DecimalLiteral(n),
|
||||||
}
|
}
|
||||||
|
@ -3679,3 +3679,39 @@ fn when_on_decimals() {
|
|||||||
i64
|
i64
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
|
fn when_on_i128() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
when 1701411834604692317316873037158841057i128 is
|
||||||
|
1701411834604692317316873037158841057 -> 42
|
||||||
|
32 -> 1
|
||||||
|
64 -> 2
|
||||||
|
_ -> 4
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
42,
|
||||||
|
i64
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
|
fn when_on_u128() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
when 170141183460469231731687303715884105728u128 is
|
||||||
|
170141183460469231731687303715884105728u128 -> 42
|
||||||
|
32 -> 1
|
||||||
|
64 -> 2
|
||||||
|
_ -> 4
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
42,
|
||||||
|
i64
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user