-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from jrincayc/issue_137
Fixes Stopping with repeat
- Loading branch information
Showing
4 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; ;; | ||
;; BERKELEY LOGO ;; | ||
;; Control Unit Tests ;; | ||
;; ;; | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
||
|
||
InstallSuite [Controls] [Tests.Control.Setup] | ||
|
||
|
||
|
||
;; The list of all Control unit tests | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
||
MAKE "Tests.Control [ | ||
;list tests here | ||
Tests.Control.PlainStopInnerWorks | ||
Tests.Control.RepeatStopWorksAsExpected | ||
Tests.Control.RepeatEarlyStopWorks | ||
Tests.Control.IfStopWorksAsExpected | ||
Tests.Control.RepeatExitsCorrectly | ||
Tests.Control.StopExitsFor | ||
Tests.Control.RunAndStop | ||
Tests.Control.IfAndStop | ||
] | ||
|
||
;; Test Suite setup procedure, main entry | ||
;; point for all tests in this suite | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
||
to Tests.Control.Setup | ||
RunTests :Tests.Control | ||
end | ||
|
||
;; Test plain returning | ||
|
||
TO Tests.Control._inner1 | ||
make "ret "false | ||
stop | ||
end | ||
|
||
To Tests.Control._middle1 | ||
Tests.Control._inner1 | ||
make "ret "true | ||
end | ||
|
||
TO Tests.Control.PlainStopInnerWorks | ||
make "ret "false | ||
Tests.Control._middle1 | ||
output :ret | ||
end | ||
|
||
;; Test returning from a repeat | ||
|
||
TO Tests.Control._inner2 | ||
make "ret "false | ||
repeat 1 [stop] | ||
end | ||
|
||
TO Tests.Control._middle2 | ||
Tests.Control._inner2 | ||
make "ret "true | ||
end | ||
|
||
TO Tests.Control.RepeatStopWorksAsExpected | ||
make "ret "false | ||
Tests.Control._middle2 | ||
output :ret | ||
end | ||
|
||
;; Test early return from repeat | ||
|
||
to Tests.Control._inner3 | ||
make "ret "false | ||
repeat 3 [stop] | ||
end | ||
|
||
to Tests.Control._middle3 | ||
Tests.Control._inner3 | ||
make "ret "true | ||
end | ||
|
||
to Tests.Control.RepeatEarlyStopWorks | ||
make "ret "false | ||
Tests.Control._middle3 | ||
output :ret | ||
end | ||
|
||
to Tests.Control._inner4 | ||
make "ret "false | ||
if "true [stop] | ||
end | ||
|
||
to Tests.Control._middle4 | ||
Tests.Control._inner4 | ||
make "ret "true | ||
end | ||
|
||
to Tests.Control.IfStopWorksAsExpected | ||
make "ret "false | ||
Tests.Control._middle4 | ||
output :ret | ||
end | ||
|
||
to Tests.Control._inner5 | ||
repeat 10 [ | ||
make "Tests.Control._count :Tests.Control._count + 1 | ||
if equalp :Tests.Control._count 3 [stop] | ||
] | ||
end | ||
|
||
to Tests.Control._middle5 | ||
Tests.Control._inner5 | ||
make "ret "ignore | ||
end | ||
|
||
to Tests.Control.RepeatExitsCorrectly | ||
make "Tests.Control._count 0 | ||
Tests.Control._middle5 | ||
output (equalp :Tests.Control._count 3) | ||
end | ||
|
||
to Tests.Control._forloop | ||
for [i 1 10] [if :i=5 [stop] make "ret :i] | ||
end | ||
|
||
to Tests.Control.StopExitsFor | ||
Tests.Control._forloop | ||
output (equalp :ret 4) | ||
end | ||
|
||
to Tests.Control._rettrue | ||
make "ret "true | ||
end | ||
|
||
to Tests.Control._RunAndStopBackend | ||
run [Tests.Control._rettrue stop] | ||
make "ret "false | ||
end | ||
|
||
to Tests.Control.RunAndStop | ||
Tests.Control._RunAndStopBackend | ||
output :ret | ||
end | ||
|
||
|
||
to Tests.Control._IfAndStopBackend | ||
if "true [Tests.Control._rettrue stop] | ||
make "ret "false | ||
end | ||
|
||
to Tests.Control.IfAndStop | ||
Tests.Control._IfAndStopBackend | ||
output :ret | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,3 +92,4 @@ TO Tests.Macro.FunctionStopErrorsAsExpected | |
OUTPUT (AND [NOT EMPTY? :err] | ||
[EQUAL? FIRST :err 5]) | ||
END | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters