mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
update tests
This commit is contained in:
parent
df8ab829a6
commit
7731ab38d1
6 changed files with 38 additions and 11 deletions
|
@ -178,7 +178,7 @@ mod cli_run {
|
||||||
&example_file("benchmarks", "NQueens.roc"),
|
&example_file("benchmarks", "NQueens.roc"),
|
||||||
"nqueens",
|
"nqueens",
|
||||||
&[],
|
&[],
|
||||||
"724\n",
|
"4\n",
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -219,6 +219,18 @@ mod cli_run {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial(deriv)]
|
||||||
|
fn run_rbtree_delete_not_optimized() {
|
||||||
|
check_output(
|
||||||
|
&example_file("benchmarks", "RBTreeDel.roc"),
|
||||||
|
"rbtree-del",
|
||||||
|
&[],
|
||||||
|
"30\n",
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[serial(effect)]
|
// #[serial(effect)]
|
||||||
// fn run_effect_unoptimized() {
|
// fn run_effect_unoptimized() {
|
||||||
|
|
|
@ -789,13 +789,19 @@ fn canonicalize_pending_def<'a>(
|
||||||
|
|
||||||
let arity = typ.arity();
|
let arity = typ.arity();
|
||||||
|
|
||||||
let def_symbol = match &loc_can_pattern.value {
|
let problem = match &loc_can_pattern.value {
|
||||||
Pattern::Identifier(symbol) => *symbol,
|
Pattern::Identifier(symbol) => RuntimeError::NoImplementationNamed {
|
||||||
_ => panic!("standalone annotations must be on identifiers"),
|
def_symbol: *symbol,
|
||||||
|
},
|
||||||
|
Pattern::Shadowed(region, loc_ident) => RuntimeError::Shadowing {
|
||||||
|
original_region: *region,
|
||||||
|
shadow: loc_ident.clone(),
|
||||||
|
},
|
||||||
|
_ => RuntimeError::NoImplementation,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fabricate a body for this annotation, that will error at runtime
|
// Fabricate a body for this annotation, that will error at runtime
|
||||||
let value = Expr::RuntimeError(RuntimeError::NoImplementation(def_symbol));
|
let value = Expr::RuntimeError(problem);
|
||||||
let is_closure = arity > 0;
|
let is_closure = arity > 0;
|
||||||
let loc_can_expr = if !is_closure {
|
let loc_can_expr = if !is_closure {
|
||||||
Located {
|
Located {
|
||||||
|
|
|
@ -145,7 +145,10 @@ pub enum RuntimeError {
|
||||||
InvalidUnicodeCodePoint(Region),
|
InvalidUnicodeCodePoint(Region),
|
||||||
|
|
||||||
/// When the author specifies a type annotation but no implementation
|
/// When the author specifies a type annotation but no implementation
|
||||||
NoImplementation(Symbol),
|
NoImplementationNamed {
|
||||||
|
def_symbol: Symbol,
|
||||||
|
},
|
||||||
|
NoImplementation,
|
||||||
|
|
||||||
/// cases where the `[]` value (or equivalently, `forall a. a`) pops up
|
/// cases where the `[]` value (or equivalently, `forall a. a`) pops up
|
||||||
VoidValue,
|
VoidValue,
|
||||||
|
|
|
@ -635,7 +635,7 @@ fn pretty_runtime_error<'b>(
|
||||||
region
|
region
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
RuntimeError::NoImplementation(_) => todo!("no implementation, unreachable"),
|
RuntimeError::NoImplementation | RuntimeError::NoImplementationNamed { .. } => todo!("no implementation, unreachable"),
|
||||||
RuntimeError::NonExhaustivePattern => {
|
RuntimeError::NonExhaustivePattern => {
|
||||||
unreachable!("not currently reported (but can blow up at runtime)")
|
unreachable!("not currently reported (but can blow up at runtime)")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1129,7 +1129,7 @@ mod test_reporting {
|
||||||
3│> when True is
|
3│> when True is
|
||||||
4│> _ -> 3.14
|
4│> _ -> 3.14
|
||||||
|
|
||||||
This `when`expression produces:
|
This `when` expression produces:
|
||||||
|
|
||||||
Float a
|
Float a
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,18 @@ ConsList a : [ Nil, Cons a (ConsList a) ]
|
||||||
|
|
||||||
main : Task.Task {} []
|
main : Task.Task {} []
|
||||||
main =
|
main =
|
||||||
m = makeMap 33
|
# benchmarks use 4_200_000
|
||||||
|
m = makeMap 420
|
||||||
|
|
||||||
|
val = fold (\_, v, r -> if v then r + 1 else r) m 0
|
||||||
|
|
||||||
# val = fold (\_, v, r -> if v then r + 1 else r) m 0
|
|
||||||
val = depth m
|
|
||||||
val
|
val
|
||||||
|> Str.fromInt
|
|> Str.fromInt
|
||||||
|> Task.putLine
|
|> Task.putLine
|
||||||
|
|
||||||
|
boom : Str -> a
|
||||||
|
boom = \_ -> boom ""
|
||||||
|
|
||||||
makeMap : I64 -> Map
|
makeMap : I64 -> Map
|
||||||
makeMap = \n ->
|
makeMap = \n ->
|
||||||
makeMapHelp n n Leaf
|
makeMapHelp n n Leaf
|
||||||
|
@ -154,11 +158,13 @@ rebalanceLeft = \c, l, k, v, r ->
|
||||||
when l is
|
when l is
|
||||||
Node Black _ _ _ _ -> Del (balanceLeft (setRed l) k v r) (isBlack c)
|
Node Black _ _ _ _ -> Del (balanceLeft (setRed l) k v r) (isBlack c)
|
||||||
Node Red lx kx vx rx -> Del (Node Black lx kx vx (balanceLeft (setRed rx) k v r)) False
|
Node Red lx kx vx rx -> Del (Node Black lx kx vx (balanceLeft (setRed rx) k v r)) False
|
||||||
|
_ -> boom "unreachable"
|
||||||
|
|
||||||
rebalanceRight = \c, l, k, v, r ->
|
rebalanceRight = \c, l, k, v, r ->
|
||||||
when r is
|
when r is
|
||||||
Node Black _ _ _ _ -> Del (balanceRight l k v (setRed r)) (isBlack c)
|
Node Black _ _ _ _ -> Del (balanceRight l k v (setRed r)) (isBlack c)
|
||||||
Node Red lx kx vx rx -> Del (Node Black (balanceRight l k v (setRed lx)) kx vx rx) False
|
Node Red lx kx vx rx -> Del (Node Black (balanceRight l k v (setRed lx)) kx vx rx) False
|
||||||
|
_ -> boom "unreachable"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue