mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
flesh out api for RocResult
This commit is contained in:
parent
c2934a509a
commit
007d777865
2 changed files with 84 additions and 0 deletions
|
@ -11,6 +11,9 @@ use crate::helpers::llvm::assert_evals_to;
|
|||
|
||||
use indoc::indoc;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use roc_std::{RocResult, RocStr};
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn with_default() {
|
||||
|
@ -219,3 +222,37 @@ fn is_err() {
|
|||
bool
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn roc_result_ok() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
result : Result I64 {}
|
||||
result = Ok 42
|
||||
|
||||
result
|
||||
"#
|
||||
),
|
||||
RocResult::ok(42),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn roc_result_err() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
result : Result I64 Str
|
||||
result = Err "foo"
|
||||
|
||||
result
|
||||
"#
|
||||
),
|
||||
RocResult::err(RocStr::from_slice(b"foo")),
|
||||
RocResult<i64, RocStr>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue