Use unsigned LLVM intrinsic arithmetic for unsigned integers

Closes #2331
This commit is contained in:
ayazhafiz 2022-01-10 18:58:48 -05:00
parent 2f3919c870
commit abe42781d5
3 changed files with 86 additions and 25 deletions

View file

@ -2101,3 +2101,57 @@ fn num_to_str() {
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn u8_addition_greater_than_i8() {
assert_evals_to!(
indoc!(
r#"
x : U8
x = 100
y : U8
y = 100
x + y
"#
),
200,
u8
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn u8_sub_greater_than_i8() {
assert_evals_to!(
indoc!(
r#"
x : U8
x = 255
y : U8
y = 55
x - y
"#
),
200,
u8
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn u8_mul_greater_than_i8() {
assert_evals_to!(
indoc!(
r#"
x : U8
x = 40
y : U8
y = 5
x * y
"#
),
200,
u8
)
}