flesh out api for RocResult

This commit is contained in:
Folkert 2021-12-27 20:01:19 +01:00
parent c2934a509a
commit 007d777865
2 changed files with 84 additions and 0 deletions

View file

@ -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>
);
}