aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/collections.nom6
-rw-r--r--tests/math.nom2
-rw-r--r--tests/metaprogramming.nom15
3 files changed, 19 insertions, 4 deletions
diff --git a/tests/collections.nom b/tests/collections.nom
index 04b8a78..6329d00 100644
--- a/tests/collections.nom
+++ b/tests/collections.nom
@@ -31,15 +31,15 @@ assume ((values in {x:1}) = [1])
%x <- [3,1,2]
sort %x
assume (%x = [1,2,3])
-sort %x by (-%)
+sort %x by % = (-%)
assume (%x = [3,2,1])
%keys <- {1:999,2:0,3:50}
-sort %x by (% in %keys)
+sort %x by % = %keys.%
assume (%x = [2,3,1])
assume ((unique [1,2,1,3,2,3]) = [1,2,3])
%c <- (new counter)
for % in ["x","y","x","x","y"]
- (% in %c) +<- 1
+ %c.% +<- 1
assume (%c = {x:3,y:2})
say "Collections test passed."
diff --git a/tests/math.nom b/tests/math.nom
index 4232d81..8cfd0f4 100644
--- a/tests/math.nom
+++ b/tests/math.nom
@@ -15,5 +15,7 @@ assume
..or barf "math functions failed"
assume ((463 to the nearest 100) = 500) or barf "rounding failed"
assume ((2.6 to the nearest 0.25) = 2.5) or barf "rounding failed"
+assume ((min of [3,-4,1,2] by % = (%*%)) = 1)
+assume ((max of [3,-4,1,2] by % = (%*%)) = -4)
say "Math test passed"
diff --git a/tests/metaprogramming.nom b/tests/metaprogramming.nom
index 9a4c9b2..26a750a 100644
--- a/tests/metaprogramming.nom
+++ b/tests/metaprogramming.nom
@@ -36,7 +36,20 @@ immediately
parse [V] as: five
assume ((V) = 5) or barf "Parse as compile action failed."
-remove action "foo %"
+immediately
+ parse [swap %x and %y] as
+ do
+ %tmp <- %x
+ %x <- %y
+ %y <- %tmp
+<- {%1:1, %2:2}
+swap %1 and %2
+assume ((%1 = 2) and (%2 = 1)) or barf "'parse % as %' failed on 'swap % and %'"
+<- {%tmp:1, %tmp2:2}
+swap %tmp and %tmp2
+assume ((%tmp = 2) and (%tmp2 = 1)) or barf "'parse % as %' variable mangling failed."
+
+remove action (foo %)
try: foo 99
..and if it succeeds: barf "Failed to delete action"