aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-15 20:32:22 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-15 20:33:07 -0700
commit3ffeaf1f5dbf3e225dc536066d0fedda3f38ac70 (patch)
treeffd23e911254ad22593a9574b5c255d9bdf578ff /tests
parent0a95a264e5829153eb19bde54882e5c135d6bdad (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')
-rw-r--r--tests/collections.nom6
-rw-r--r--tests/control_flow.nom27
2 files changed, 12 insertions, 21 deletions
diff --git a/tests/collections.nom b/tests/collections.nom
index 60b2d25..04b8a78 100644
--- a/tests/collections.nom
+++ b/tests/collections.nom
@@ -19,10 +19,10 @@ pop from %list
assume ((last in %list) = 5)
remove index 1 from %list
assume ((first in %list) = 2)
-assume (((% * %) for all [1,2,3]) = [1,4,9])
+assume (((% * %) for % in [1,2,3]) = [1,4,9])
assume ((%k = (%v * %v) for %k = %v in {x:1,y:2,z:3}) = {x:1,y:4,z:9})
assume ((%k for %k = %v in {x:1}) = ["x"])
-assume ((% = (% * %) for all [1,2,3]) = {1:1,2:4,3:9})
+assume ((% = (% * %) for % in [1,2,3]) = {1:1,2:4,3:9})
assume (([[1,2],[3,4]] flattened) = [1,2,3,4])
assume ((entries in {x:1}) = [{key:"x",value:1}])
assume ((keys in {x:1}) = ["x"])
@@ -38,7 +38,7 @@ sort %x by (% in %keys)
assume (%x = [2,3,1])
assume ((unique [1,2,1,3,2,3]) = [1,2,3])
%c <- (new counter)
-for all ["x","y","x","x","y"]
+for % in ["x","y","x","x","y"]
(% in %c) +<- 1
assume (%c = {x:3,y:2})
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