Skip to content

Commit

Permalink
Add tests for nested Begins
Browse files Browse the repository at this point in the history
  • Loading branch information
hedyhli committed Aug 27, 2024
1 parent 6e160aa commit b517bc1
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/begin.cog
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,59 @@ Print If And reached Unbox ReachableCode and Not reached Unbox UnreachableCode
"PASS: Begin"
else
"FAIL: Begin";


Let UnreachableList be Map (Box) over List (False False False);
Let ReachableList be Map (Box) over List (False False False);

Begin (
Def Level1;
Set Index 0 ReachableList to True;
Begin (
Def Level2;
Set Index 1 ReachableList to True;
Begin (
Def Level3;
Set Index 2 ReachableList to True;
exit from Level1;
Set First UnreachableList to True;
)
Set Index 1 UnreachableList to True;
)
Set Index 2 UnreachableList to True;
);

Print If And All are (Not reached from Unbox) in UnreachableList and
All are reached from (Unbox) in ReachableList then
"PASS: Exit from nested Begin 1"
else
"PASS: Exit from nested Begin 1";


For item in UnreachableList (Let I; Set I Not Unbox I);
For item in ReachableList (Let I; Set I Not Unbox I);

Begin (
Def Level1;
Set Index 0 ReachableList to True;
Begin (
Def Level2;
Set Index 1 ReachableList to True;
Begin (
Def Level3;
Set Index 2 ReachableList to True;
Do (
exit Level1;
);
Set First UnreachableList to True;
)
Set Index 1 UnreachableList to True;
)
Set Index 2 UnreachableList to True;
);

Print If And All are (Not reached from Unbox) in UnreachableList and
All are reached from (Unbox) in ReachableList then
"PASS: Exit from nested Begin 2"
else
"PASS: Exit from nested Begin 2";

0 comments on commit b517bc1

Please sign in to comment.