update tests

This commit is contained in:
Folkert 2021-01-21 22:41:47 +01:00
parent df8ab829a6
commit 7731ab38d1
6 changed files with 38 additions and 11 deletions

View file

@ -178,7 +178,7 @@ mod cli_run {
&example_file("benchmarks", "NQueens.roc"),
"nqueens",
&[],
"724\n",
"4\n",
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]
// #[serial(effect)]
// fn run_effect_unoptimized() {

View file

@ -789,13 +789,19 @@ fn canonicalize_pending_def<'a>(
let arity = typ.arity();
let def_symbol = match &loc_can_pattern.value {
Pattern::Identifier(symbol) => *symbol,
_ => panic!("standalone annotations must be on identifiers"),
let problem = match &loc_can_pattern.value {
Pattern::Identifier(symbol) => RuntimeError::NoImplementationNamed {
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
let value = Expr::RuntimeError(RuntimeError::NoImplementation(def_symbol));
let value = Expr::RuntimeError(problem);
let is_closure = arity > 0;
let loc_can_expr = if !is_closure {
Located {

View file

@ -145,7 +145,10 @@ pub enum RuntimeError {
InvalidUnicodeCodePoint(Region),
/// 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
VoidValue,

View file

@ -635,7 +635,7 @@ fn pretty_runtime_error<'b>(
region
);
}
RuntimeError::NoImplementation(_) => todo!("no implementation, unreachable"),
RuntimeError::NoImplementation | RuntimeError::NoImplementationNamed { .. } => todo!("no implementation, unreachable"),
RuntimeError::NonExhaustivePattern => {
unreachable!("not currently reported (but can blow up at runtime)")
}

View file

@ -14,14 +14,18 @@ ConsList a : [ Nil, Cons a (ConsList a) ]
main : Task.Task {} []
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
|> Str.fromInt
|> Task.putLine
boom : Str -> a
boom = \_ -> boom ""
makeMap : I64 -> Map
makeMap = \n ->
makeMapHelp n n Leaf
@ -154,11 +158,13 @@ rebalanceLeft = \c, l, k, v, r ->
when l is
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
_ -> boom "unreachable"
rebalanceRight = \c, l, k, v, r ->
when r is
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
_ -> boom "unreachable"