diff options
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 |
