mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
use RocResult in addChecked test
This commit is contained in:
parent
a44afd1383
commit
b43c0ac1e3
1 changed files with 13 additions and 21 deletions
|
@ -11,7 +11,7 @@ use crate::helpers::wasm::assert_evals_to;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use roc_std::{RocDec, RocOrder};
|
use roc_std::{RocDec, RocOrder, RocResult};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||||
|
@ -1791,30 +1791,22 @@ fn int_add_overflow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn int_add_checked() {
|
fn int_add_checked_ok() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
"Num.addChecked 1 2",
|
||||||
r#"
|
RocResult::ok(3),
|
||||||
when Num.addChecked 1 2 is
|
RocResult<i64, ()>
|
||||||
Ok v -> v
|
|
||||||
_ -> -1
|
|
||||||
"#
|
|
||||||
),
|
|
||||||
3,
|
|
||||||
i64
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
|
fn int_add_checked_err() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
"Num.addChecked 9_223_372_036_854_775_807 1",
|
||||||
r#"
|
RocResult::err(()),
|
||||||
when Num.addChecked 9_223_372_036_854_775_807 1 is
|
RocResult<i64, ()>
|
||||||
Err Overflow -> -1
|
|
||||||
Ok v -> v
|
|
||||||
"#
|
|
||||||
),
|
|
||||||
-1,
|
|
||||||
i64
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue