diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-15 20:32:22 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-15 20:33:07 -0700 |
| commit | 3ffeaf1f5dbf3e225dc536066d0fedda3f38ac70 (patch) | |
| tree | ffd23e911254ad22593a9574b5c255d9bdf578ff /tests/control_flow.nom | |
| parent | 0a95a264e5829153eb19bde54882e5c135d6bdad (diff) | |
Removed "for all"-style iteration and changed "for % from 1 to 10"-style
to "for % in 1 to 10" for consistency.
Diffstat (limited to 'tests/control_flow.nom')
| -rw-r--r-- | tests/control_flow.nom | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/tests/control_flow.nom b/tests/control_flow.nom index 899da22..40b344f 100644 --- a/tests/control_flow.nom +++ b/tests/control_flow.nom @@ -1,4 +1,4 @@ -#.. +# Tests for the stuff defined in lib/control_flow.nom use "core" @@ -40,11 +40,6 @@ for %x in [1,2,3] %tot +<- %x assume (%tot = 6) or barf "for-loop failed" -%tot <- 0 -for all [1,2,3] - %tot +<- % -assume (%tot = 6) or barf "for-all-loop failed" - %x <- 0 repeat %x +<- 1 @@ -58,7 +53,7 @@ repeat 5 times assume (%x = 5) or barf "Failed to repeat 5 times" <- {%x:0,%y:0} -for all [1,2,3] +for % in [1,2,3] repeat 5 times do next repeat %x +<- 1 @@ -66,7 +61,7 @@ for all [1,2,3] assume ([%x,%y] = [0,3]) or barf "Failed to continue repeat" <- {%x:0,%y:0} -for all [1,2,3] +for % in [1,2,3] repeat 5 times do next % %x +<- 1 @@ -74,7 +69,7 @@ for all [1,2,3] assume ([%x,%y] = [0,0]) or barf "Failed to continue for" <- {%x:0,%y:0} -for all [1,2,3] +for % in [1,2,3] repeat 5 times stop repeating %x +<- 1 @@ -82,7 +77,7 @@ for all [1,2,3] assume ([%x,%y] = [0,3]) or barf "Failed to stop repeat" <- {%x:0,%y:0} -for all [1,2,3] +for % in [1,2,3] repeat 5 times stop % %x +<- 1 @@ -100,17 +95,13 @@ repeat until: %x = 10 assume (%x = 10) or barf "repeat-until failed" %x <- 0 -for %i from 1 to 3: %x +<- %i +for %i in 1 to 3: %x +<- %i assume (%x = 6) or barf "Numeric for range failed" %x <- 0 -for %i from 3 to 1 via -1: %x +<- %i +for %i in 3 to 1 via -1: %x +<- %i assume (%x = 6) or barf "backwards numeric for range failed" -%x <- 0 -for all 1 to 3: %x +<- % -assume (%x = 6) or barf "terse numeric for range failed" - %result <- {} for %key = %value in {x:1,y:2} (%result's ("\%key\%key")) <- (%value * 11) @@ -197,12 +188,12 @@ assume (..) result of %n <- 0 - for all [1,2,3]: %n +<- % + for % in [1,2,3]: %n +<- % return %n ..= 6 %nums <- [] -for all +for % in values -> 4 -> 5 |
