revert some debug things

This commit is contained in:
Folkert 2020-11-10 14:12:01 +01:00
parent 3f658c4b98
commit be5c748b7f
3 changed files with 112 additions and 8 deletions

View file

@ -1111,4 +1111,96 @@ mod gen_primitives {
|_| 1 |_| 1
); );
} }
#[test]
fn linked_list_len() {
assert_non_opt_evals_to!(
indoc!(
r#"
app Test provides [ main, len ] imports []
ConsList a : [ Cons a (ConsList a), Nil ]
len : ConsList a -> Int
len = \list ->
when list is
Cons _ rest -> 1 + len rest
Nil ->
0
main : ConsList Int -> Int
main = len
"#
),
1,
i64,
|_| 1
);
}
#[test]
fn linked_list_is_empty_1() {
assert_non_opt_evals_to!(
indoc!(
r#"
app Test provides [ main ] imports []
ConsList a : [ Cons a (ConsList a), Nil ]
empty : ConsList a
empty = Nil
isEmpty : ConsList a -> Bool
isEmpty = \list ->
when list is
Cons _ _ ->
False
Nil ->
True
main : Bool
main =
myList : ConsList Int
myList = empty
isEmpty myList
"#
),
true,
bool
);
}
#[test]
fn linked_list_is_empty_2() {
assert_non_opt_evals_to!(
indoc!(
r#"
app Test provides [ main ] imports []
ConsList a : [ Cons a (ConsList a), Nil ]
# isEmpty : ConsList a -> Bool
isEmpty = \list ->
when list is
Cons _ _ ->
False
Nil ->
True
main : Bool
main =
myList : ConsList Int
myList = Cons 0x1 Nil
isEmpty myList
"#
),
false,
bool
);
}
} }

View file

@ -1690,6 +1690,9 @@ fn update<'a>(
if state.dependencies.solved_all() && state.goal_phase == Phase::MakeSpecializations { if state.dependencies.solved_all() && state.goal_phase == Phase::MakeSpecializations {
debug_assert!(work.is_empty()); debug_assert!(work.is_empty());
Proc::insert_refcount_operations(arena, &mut state.procedures);
// display the mono IR of the module, for debug purposes // display the mono IR of the module, for debug purposes
if roc_mono::ir::PRETTY_PRINT_IR_SYMBOLS { if roc_mono::ir::PRETTY_PRINT_IR_SYMBOLS {
let procs_string = state let procs_string = state
@ -1703,8 +1706,6 @@ fn update<'a>(
println!("{}", result); println!("{}", result);
} }
Proc::insert_refcount_operations(arena, &mut state.procedures);
msg_tx msg_tx
.send(Msg::FinishedAllSpecialization { .send(Msg::FinishedAllSpecialization {
subs, subs,

View file

@ -1,9 +1,20 @@
app Main provides [ main ] imports [ Effect ] app Main provides [ main ] imports [ Effect, ConsList ]
empty : ConsList.ConsList Int
empty = ConsList.empty
main : Effect.Effect {} as Fx main : Effect.Effect {} as Fx
main = main =
Effect.always "Write a thing" if ConsList.isEmpty empty then
|> Effect.map (\line -> Str.concat line "!") Effect.putLine "Yay"
|> Effect.after (\line -> Effect.putLine line) |> Effect.after (\{} -> Effect.getLine)
|> Effect.after (\{} -> Effect.getLine) |> Effect.after (\line -> Effect.putLine line)
|> Effect.after (\line -> Effect.putLine line) else
Effect.putLine "Nay"
# Effect.always "Write a thing"
# |> Effect.map (\line -> Str.concat line "!")
# |> Effect.after (\line -> Effect.putLine line)
# |> Effect.after (\{} -> Effect.getLine)
# |> Effect.after (\line -> Effect.putLine line)