mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
nullable wrapped tags
This commit is contained in:
parent
98e1ee1bf7
commit
546b702740
8 changed files with 361 additions and 10 deletions
|
@ -62,6 +62,14 @@ impl ReplAppMemory for ExpectMemory {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn deref_pointer_with_tag_id(&self, addr: usize) -> (u16, u64) {
|
||||
// because addr is an index/offset, we cannot use the low bits
|
||||
let tag_id = self.deref_u32(addr);
|
||||
let offset = self.deref_u32(addr + 4);
|
||||
|
||||
(tag_id as _, offset as _)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct ExpectReplApp<'a> {
|
||||
|
|
|
@ -336,7 +336,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn lookup_result() {
|
||||
fn lookup_copy_result() {
|
||||
run_expect_test(
|
||||
indoc!(
|
||||
r#"
|
||||
|
@ -375,6 +375,50 @@ mod test {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lookup_clone_result() {
|
||||
run_expect_test(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main = 0
|
||||
|
||||
expect
|
||||
a : Result Str Str
|
||||
a = Ok "foo"
|
||||
|
||||
b : Result Str Str
|
||||
b = Err "bar"
|
||||
|
||||
a == b
|
||||
"#
|
||||
),
|
||||
indoc!(
|
||||
r#"
|
||||
This expectation failed:
|
||||
|
||||
5│> expect
|
||||
6│> a : Result Str Str
|
||||
7│> a = Ok "foo"
|
||||
8│>
|
||||
9│> b : Result Str Str
|
||||
10│> b = Err "bar"
|
||||
11│>
|
||||
12│> a == b
|
||||
|
||||
When it failed, these variables had these values:
|
||||
|
||||
a : Result Str Str
|
||||
a = Ok "foo"
|
||||
|
||||
b : Result Str Str
|
||||
b = Err "bar"
|
||||
"#
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lookup_copy_record() {
|
||||
run_expect_test(
|
||||
|
@ -598,4 +642,104 @@ mod test {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linked_list() {
|
||||
run_expect_test(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main = 0
|
||||
|
||||
ConsList a : [ Nil, Cons a (ConsList a) ]
|
||||
|
||||
cons = \list, x -> Cons x list
|
||||
|
||||
expect
|
||||
a : ConsList Str
|
||||
a = Nil
|
||||
|
||||
b : ConsList Str
|
||||
b = Nil
|
||||
|> cons "Astra mortemque praestare gradatim"
|
||||
|> cons "Profundum et fundamentum"
|
||||
|
||||
a == b
|
||||
"#
|
||||
),
|
||||
indoc!(
|
||||
r#"
|
||||
This expectation failed:
|
||||
|
||||
9│> expect
|
||||
10│> a : ConsList Str
|
||||
11│> a = Nil
|
||||
12│>
|
||||
13│> b : ConsList Str
|
||||
14│> b = Nil
|
||||
15│> |> cons "Astra mortemque praestare gradatim"
|
||||
16│> |> cons "Profundum et fundamentum"
|
||||
17│>
|
||||
18│> a == b
|
||||
|
||||
When it failed, these variables had these values:
|
||||
|
||||
a : ConsList Str
|
||||
a = Nil
|
||||
|
||||
b : ConsList Str
|
||||
b = Cons "Profundum et fundamentum" (Cons "Astra mortemque praestare gradatim" Nil)
|
||||
"#
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tree() {
|
||||
run_expect_test(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
main = 0
|
||||
|
||||
Tree a : [ Empty, Leaf a, Node (Tree a) (Tree a) ]
|
||||
|
||||
cons = \list, x -> Cons x list
|
||||
|
||||
expect
|
||||
a : Tree Str
|
||||
a = Leaf "Astra mortemque praestare gradatim"
|
||||
|
||||
b : Tree Str
|
||||
b = Node Empty Empty
|
||||
|
||||
a == b
|
||||
"#
|
||||
),
|
||||
indoc!(
|
||||
r#"
|
||||
This expectation failed:
|
||||
|
||||
9│> expect
|
||||
10│> a : Tree Str
|
||||
11│> a = Leaf "Astra mortemque praestare gradatim"
|
||||
12│>
|
||||
13│> b : Tree Str
|
||||
14│> b = Node Empty Empty
|
||||
15│>
|
||||
16│> a == b
|
||||
|
||||
When it failed, these variables had these values:
|
||||
|
||||
a : Tree Str
|
||||
a = Leaf "Astra mortemque praestare gradatim"
|
||||
|
||||
b : Tree Str
|
||||
b = Node Empty Empty
|
||||
"#
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue