mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Symbol definition and tests
This commit is contained in:
parent
5632d07179
commit
699ab5c646
2 changed files with 53 additions and 0 deletions
|
@ -1297,6 +1297,7 @@ define_builtins! {
|
|||
6 RESULT_AFTER: "after"
|
||||
7 RESULT_IS_OK: "isOk"
|
||||
8 RESULT_IS_ERR: "isErr"
|
||||
9 RESULT_AFTER_ERR: "afterErr"
|
||||
}
|
||||
7 DICT: "Dict" => {
|
||||
0 DICT_DICT: "Dict" imported // the Dict.Dict type alias
|
||||
|
|
|
@ -268,3 +268,55 @@ fn issue_2583_specialize_errors_behind_unified_branches() {
|
|||
RocResult<i64, bool>
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn roc_result_after() {
|
||||
assert_evals_to!(indoc!(
|
||||
r#"
|
||||
result : Result I64 I64
|
||||
result = (Ok "1234") |> after (\numStr -> Num.toNat)
|
||||
|
||||
result
|
||||
"#),
|
||||
RocResult::ok(1234),
|
||||
RocResult<i64, RocStr>
|
||||
);
|
||||
|
||||
assert_evals_to!(indoc!(
|
||||
r#"
|
||||
result : Result I64 Str
|
||||
result = (Err "1234") |> after (\numStr -> Num.toNat)
|
||||
|
||||
result
|
||||
"#),
|
||||
RocResult::err(RocStr::from("1234")),
|
||||
RocResult<i64, RocStr>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn roc_result_after_err() {
|
||||
assert_evals_to!(indoc!(
|
||||
r#"
|
||||
result : Result I64 Str
|
||||
result = (Err "1234") |> afterErr (\numStr -> Num.toNat)
|
||||
|
||||
result
|
||||
"#),
|
||||
RocResult::err(1234),
|
||||
RocResult<i64, RocStr>
|
||||
);
|
||||
|
||||
assert_evals_to!(indoc!(
|
||||
r#"
|
||||
result : Result Str I64
|
||||
result = (Ok "1234") |> afterErr (\numStr -> Num.toNat)
|
||||
|
||||
result
|
||||
"#),
|
||||
RocResult::ok(RocStr::from("1234")),
|
||||
RocResult<RocStr, i64>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue