mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
add tests
This commit is contained in:
parent
006b1f8696
commit
9745d86efb
2 changed files with 42 additions and 21 deletions
|
@ -614,22 +614,21 @@ mod test_gen {
|
|||
);
|
||||
}
|
||||
|
||||
// doesn't work yet. The condition must be cast to an integer to use a jump table
|
||||
// #[test]
|
||||
// fn branch_third_float() {
|
||||
// assert_evals_to!(
|
||||
// indoc!(
|
||||
// r#"
|
||||
// when 10.0 is
|
||||
// 1.0 -> 63
|
||||
// 2 -> 48
|
||||
// _ -> 112
|
||||
// "#
|
||||
// ),
|
||||
// 112.0,
|
||||
// f64
|
||||
// );
|
||||
// }
|
||||
#[test]
|
||||
fn branch_third_float() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when 10.0 is
|
||||
1.0 -> 63
|
||||
2.0 -> 48
|
||||
_ -> 112
|
||||
"#
|
||||
),
|
||||
112,
|
||||
i64
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn branch_first_int() {
|
||||
|
@ -1297,11 +1296,14 @@ mod test_gen {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
x : [ This Int, These Int Int ]
|
||||
These a b : [ This a, That b, These a b ]
|
||||
|
||||
x : These Int Int
|
||||
x = These 0x3 0x2
|
||||
|
||||
when x is
|
||||
These a b -> a + b
|
||||
That v -> 8
|
||||
This v -> v
|
||||
"#
|
||||
),
|
||||
|
@ -1331,6 +1333,26 @@ mod test_gen {
|
|||
);
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn when_on_just_just() {
|
||||
// assert_evals_to!(
|
||||
// indoc!(
|
||||
// r#"
|
||||
// Maybe a : [ Nothing, Just a ]
|
||||
//
|
||||
// x : Maybe (Maybe a)
|
||||
// x = Just (Just 41)
|
||||
//
|
||||
// when x is
|
||||
// Just (Just v) -> v + 0x1
|
||||
// _ -> 0x1
|
||||
// "#
|
||||
// ),
|
||||
// 42,
|
||||
// i64
|
||||
// );
|
||||
// }
|
||||
|
||||
// #[test]
|
||||
// fn linked_list_empty() {
|
||||
// assert_evals_to!(
|
||||
|
|
|
@ -156,7 +156,7 @@ fn flatten<'a>(path_pattern: (Path, Pattern<'a>), path_patterns: &mut Vec<(Path,
|
|||
// dearg (Can.PatternCtorArg _ _ pattern) =
|
||||
// pattern
|
||||
|
||||
todo!()
|
||||
todo!("alternatives: {:?}", union.alternatives)
|
||||
} else {
|
||||
path_patterns.push(path_pattern);
|
||||
}
|
||||
|
@ -911,7 +911,8 @@ fn decide_to_branching<'a>(
|
|||
Test::IsFloat(v) => v as u64,
|
||||
Test::IsBit(v) => v as u64,
|
||||
Test::IsByte { tag_id, .. } => tag_id as u64,
|
||||
_ => todo!(),
|
||||
Test::IsCtor { tag_id, .. } => tag_id as u64,
|
||||
other => todo!("other {:?}", other),
|
||||
};
|
||||
|
||||
branches.push((tag, branch));
|
||||
|
@ -921,9 +922,7 @@ fn decide_to_branching<'a>(
|
|||
Expr::Switch {
|
||||
cond,
|
||||
cond_layout,
|
||||
// branches: &'a [(u64, Expr<'a>)],
|
||||
branches: branches.into_bump_slice(),
|
||||
// default_branch: &'a Expr<'a>,
|
||||
default_branch,
|
||||
ret_layout,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue