aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-18 01:27:56 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-18 01:28:17 -0700
commitd5cfaa37be9e278c44a25ef448a071390597306e (patch)
tree7fbe78b5153bb9c761c283533943ab80da3a1844 /tests
parentc7c657d38f999901225b33482ef3a15994526feb (diff)
Upgrading to version 2.3 (main change: "=" instead of "<-" for
assignment)
Diffstat (limited to 'tests')
-rw-r--r--tests/collections.nom61
-rw-r--r--tests/colors.nom4
-rw-r--r--tests/control_flow.nom255
-rw-r--r--tests/coroutines.nom21
-rw-r--r--tests/errors.nom29
-rw-r--r--tests/math.nom26
-rw-r--r--tests/metaprogramming.nom89
-rw-r--r--tests/object.nom105
-rw-r--r--tests/operators.nom92
-rw-r--r--tests/os.nom16
-rw-r--r--tests/scopes.nom22
-rw-r--r--tests/text.nom99
12 files changed, 360 insertions, 459 deletions
diff --git a/tests/collections.nom b/tests/collections.nom
index 9df9eba..cf60ebe 100644
--- a/tests/collections.nom
+++ b/tests/collections.nom
@@ -1,40 +1,37 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#..
Tests for the stuff defined in core/control_flow.nom
-
use "core"
-
-assume ((2nd to last in [1,2,3,4,5]) = 4)
-assume (3 is in [1,2,3,4,5])
-assume (99 isn't in [1,2,3])
-assume ({x:no} has key "x")
-assume ({x:no} doesn't have key "y")
-assume (not ({x:no} doesn't have key "x"))
-assume ((length of [1,2,3]) = 3)
-%list <- [1,2,3,4,5]
+assume ((2 nd to last in [1, 2, 3, 4, 5]) == 4)
+assume (3 is in [1, 2, 3, 4, 5])
+assume (99 isn't in [1, 2, 3])
+assume ({x: no} has key "x")
+assume ({x: no} doesn't have key "y")
+assume (not ({x: no} doesn't have key "x"))
+assume ((length of [1, 2, 3]) == 3)
+%list = [1, 2, 3, 4, 5]
append 6 to %list
-assume ((last in %list) = 6)
+assume ((last in %list) == 6)
pop from %list
-assume ((last in %list) = 5)
+assume ((last in %list) == 5)
remove index 1 from %list
-assume ((first in %list) = 2)
-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 % 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"])
-assume ((values in {x:1}) = [1])
-assume ((sorted [3,1,2]) = [1,2,3])
-%x <- [3,1,2]
+assume ((first in %list) == 2)
+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 % 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"])
+assume ((values in {x: 1}) == [1])
+assume ((sorted [3, 1, 2]) == [1, 2, 3])
+%x = [3, 1, 2]
sort %x
-assume (%x = [1,2,3])
-sort %x by % = (-%)
-assume (%x = [3,2,1])
-%keys <- {1:999,2:0,3:50}
+assume (%x == [1, 2, 3])
+sort %x by % = (- %)
+assume (%x == [3, 2, 1])
+%keys = {1: 999, 2: 0, 3: 50}
sort %x by % = %keys.%
-assume (%x = [2,3,1])
-assume ((unique [1,2,1,3,2,3]) = [1,2,3])
-
-say "Collections test passed."
+assume (%x == [2, 3, 1])
+assume ((unique [1, 2, 1, 3, 2, 3]) == [1, 2, 3])
+say "Collections test passed." \ No newline at end of file
diff --git a/tests/colors.nom b/tests/colors.nom
index 16610f4..d4d5ac5 100644
--- a/tests/colors.nom
+++ b/tests/colors.nom
@@ -1,3 +1,3 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
use "lib/consolecolor.nom"
-say: bright: green "Color test passed."
+say (bright (green "Color test passed.")) \ No newline at end of file
diff --git a/tests/control_flow.nom b/tests/control_flow.nom
index 62b59fa..1d223a4 100644
--- a/tests/control_flow.nom
+++ b/tests/control_flow.nom
@@ -1,192 +1,161 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#
Tests for the stuff defined in core/control_flow.nom
use "core"
-
do nothing
-
-action [test conditionals]
- if: yes
- %loc1 <- (yes)
- if: no
- barf "entered if 'no' conditional"
-
- unless: yes
- barf "entered unless 'yes' conditional"
-
- if: yes
- %loc2 <- (yes)
- ..else
- barf "entered if 'yes' else conditional"
-
- unless: no
- %loc3 <- (yes)
- ..else
- barf "entered unless 'no' else conditional"
-
-assume (all of [%loc1 = (nil), %loc2 = (nil), %loc3 = (nil)]) or barf "conditionals leaking locals"
-
-assume ((5 if (yes) else 1) = 5)
-assume ((5 if (no) else 1) = 1)
-action [return nil]: return (nil)
-assume (((return nil) if (yes) else 99) = (nil))
-
+action [test conditionals]:
+ if (yes): %loc1 = (yes)
+ if (no): barf "entered if 'no' conditional"
+ unless (yes): barf "entered unless 'yes' conditional"
+ if (yes): %loc2 = (yes)
+ ..else: barf "entered if 'yes' else conditional"
+
+ unless (no) (%loc3 = (yes)) else (barf "entered unless 'no' else conditional")
+
+assume (all of [%loc1 == (nil), %loc2 == (nil), %loc3 == (nil)]) or barf "conditionals leaking locals"
+assume ((5 if (yes) else 1) == 5)
+assume ((5 if (no) else 1) == 1)
+action [return nil] (return (nil))
+assume (((return nil) if (yes) else 99) == (nil))
go to %skip
barf "go-to failed."
--- %skip ---
-
-%tot <- 0
-for %x in [1,2,3]
- %tot +<- %x
-assume (%tot = 6) or barf "for-loop failed"
-
-%x <- 0
-repeat
- %x +<- 1
- if (%x = 3): stop repeating
+%tot = 0
+for %x in [1, 2, 3]: %tot += %x
+assume (%tot == 6) or barf "for-loop failed"
+%x = 0
+repeat:
+ %x += 1
+ if (%x == 3): stop repeating
if (%x > 3): barf "Failed to stop repeat loop"
-assume (%x = 3) or barf "Failed to repeat"
-
-%x <- 0
-repeat 5 times
- %x +<- 1
-assume (%x = 5) or barf "Failed to repeat 5 times"
-<- {%x:0,%y:0}
-for % in [1,2,3]
- repeat 5 times
+assume (%x == 3) or barf "Failed to repeat"
+%x = 0
+repeat 5 times: %x += 1
+assume (%x == 5) or barf "Failed to repeat 5 times"
+set {%x: 0, %y: 0}
+for % in [1, 2, 3]:
+ repeat 5 times:
do next repeat
- %x +<- 1
- %y +<- 1
-assume ([%x,%y] = [0,3]) or barf "Failed to continue repeat"
-
-<- {%x:0,%y:0}
-for % in [1,2,3]
- repeat 5 times
+ %x += 1
+
+ %y += 1
+
+assume ([%x, %y] == [0, 3]) or barf "Failed to continue repeat"
+set {%x: 0, %y: 0}
+for % in [1, 2, 3]:
+ repeat 5 times:
do next %
- %x +<- 1
- %y +<- 1
-assume ([%x,%y] = [0,0]) or barf "Failed to continue for"
-
-<- {%x:0,%y:0}
-for % in [1,2,3]
- repeat 5 times
+ %x += 1
+
+ %y += 1
+
+assume ([%x, %y] == [0, 0]) or barf "Failed to continue for"
+set {%x: 0, %y: 0}
+for % in [1, 2, 3]:
+ repeat 5 times:
stop repeating
- %x +<- 1
- %y +<- 1
-assume ([%x,%y] = [0,3]) or barf "Failed to stop repeat"
-
-<- {%x:0,%y:0}
-for % in [1,2,3]
- repeat 5 times
+ %x += 1
+
+ %y += 1
+
+assume ([%x, %y] == [0, 3]) or barf "Failed to stop repeat"
+set {%x: 0, %y: 0}
+for % in [1, 2, 3]:
+ repeat 5 times:
stop %
- %x +<- 1
- %y +<- 1
-assume ([%x,%y] = [0,0]) or barf "Failed to stop for"
-
-%x <- 0
-repeat while: %x < 10
- %x +<- 1
-assume (%x = 10) or barf "repeat-while failed"
-
-%x <- 0
-repeat until: %x = 10
- %x +<- 1
-assume (%x = 10) or barf "repeat-until failed"
-
-%x <- 0
-for %i in 1 to 3: %x +<- %i
-assume (%x = 6) or barf "Numeric for range failed"
-
-%x <- 0
-for %i in 3 to 1 via -1: %x +<- %i
-assume (%x = 6) or barf "backwards numeric for range failed"
-
-%result <- {}
-for %key = %value in {x:1,y:2}
- %result.("\%key\%key") <- (%value * 11)
-assume (%result = {xx:11,yy:22}) or barf "key/value iteration failed"
-
-for %key = %value in {x:1,y:2}
+ %x += 1
+
+ %y += 1
+
+assume ([%x, %y] == [0, 0]) or barf "Failed to stop for"
+%x = 0
+repeat while (%x < 10): %x += 1
+assume (%x == 10) or barf "repeat-while failed"
+%x = 0
+repeat until (%x == 10): %x += 1
+assume (%x == 10) or barf "repeat-until failed"
+%x = 0
+for %i in 1 to 3: %x += %i
+assume (%x == 6) or barf "Numeric for range failed"
+%x = 0
+for %i in 3 to 1 via -1: %x += %i
+assume (%x == 6) or barf "backwards numeric for range failed"
+%result = {}
+for %key = %value in {x: 1, y: 2}: %result."\%key\%key" = (%value * 11)
+assume (%result == {xx: 11, yy: 22}) or barf "key/value iteration failed"
+for %key = %value in {x: 1, y: 2}:
stop %key
barf "stopping key failed"
-for %key = %value in {x:1,y:2}
+for %key = %value in {x: 1, y: 2}:
stop %value
barf "stopping value failed"
-for %key = %value in {x:1}
+for %key = %value in {x: 1}:
stop %key
stop %value
do next %key
do next %value
-for %key = %value in {x:1,y:2}
+for %key = %value in {x: 1, y: 2}:
do next %key
barf "skipping key failed"
-for %key = %value in {x:1,y:2}
+for %key = %value in {x: 1, y: 2}:
do next %value
barf "skipping value failed"
-action [barfer]: barf "this should never be reached"
-when
- * (no): barf "'when' fail"
+action [barfer] (barf "this should never be reached")
+when:
+ * (no) (barf "'when' fail")
* (no)
- * (3 > 4): barf "'when' fail 2"
+ * (3 > 4) (barf "'when' fail 2")
* (yes)
- * (barfer): do nothing
- * (99 > 1): barf "Fell through incorrectly"
+ * (barfer) (do nothing)
+ * (99 > 1) (barf "Fell through incorrectly")
-%else_worked <- (no)
-when
- * (no): barf
- * else: %else_worked <- (yes)
-assume %else_worked or barf "when..else failed"
+%else_worked = (no)
+when:
+ * (no) (barf)
+ *else (%else_worked = (yes))
-action [test when scope]
- when
- * (yes): %leaked <- (yes)
+assume %else_worked or barf "when..else failed"
+action [test when scope] (when (* (yes) (%leaked = (yes))))
test when scope
assume (not %leaked) or barf "'when' is leaking locals"
-
-%when_worked <- (no)
-when 4 = ?
+%when_worked = (no)
+when 4 = ?:
* 1
- * 2: barf "'when = ?' fail"
+ * 2 (barf "'when = ?' fail")
* 3
* 4
- * (barfer): %when_worked <- (yes)
-assume %when_worked
+ * (barfer) (%when_worked = (yes))
-%when_worked <- (no)
-when 5 = ?
- * 6: barf
- * else: %when_worked <- (yes)
assume %when_worked
+%when_worked = (no)
+when 5 = ?:
+ * 6 (barf)
+ *else (%when_worked = (yes))
-%x <- 1
-do
- %x <- 2
-assume (%x = 2) or barf "'do' is redefining locals"
-
-assume
+assume %when_worked
+%x = 1
+do: %x = 2
+assume (%x == 2) or barf "'do' is redefining locals"
+assume (..)
(..)
- result of
- %n <- 0
- for % in [1,2,3]: %n +<- %
+ result of:
+ %n = 0
+ for % in [1, 2, 3]: %n += %
return %n
- ..= 6
-..or barf "'result of %' failed"
-
+ ..== 6
-%t <- [1,[2,[[3],4],5,[[[6]]]]]
-%flat <- []
-for % in recursive %t
- if: (type of %) is "table"
- for %2 in %: recurse % on %2
+%t = [1, [2, [[3], 4], 5, [[[6]]]]]
+%flat = []
+for % in recursive %t:
+ if ((type of %) is "table"): for %2 in %: recurse % on %2
..else: add % to %flat
-assume: (sorted %flat) = [1,2,3,4,5,6]
+assume ((sorted %flat) == [1, 2, 3, 4, 5, 6])
say "Control flow test passed."
diff --git a/tests/coroutines.nom b/tests/coroutines.nom
index 16ef100..54b233e 100644
--- a/tests/coroutines.nom
+++ b/tests/coroutines.nom
@@ -1,19 +1,10 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#
Tests for the stuff defined in core/control_flow.nom
use "core"
-
-%nums <- []
-%co <-
- coroutine
- -> 4
- -> 5
- repeat 3 times
- -> 6
-for % in coroutine %co
- add % to %nums
-
-assume (%nums = [4,5,6,6,6]) or barf "Coroutine iteration failed"
-
-say "Coroutines test passed."
+%nums = []
+%co = (coroutine (: -> 4; -> 5; repeat 3 times: -> 6))
+for % in coroutine %co (add % to %nums)
+assume (%nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed"
+say "Coroutines test passed." \ No newline at end of file
diff --git a/tests/errors.nom b/tests/errors.nom
index 7f52532..7f91c88 100644
--- a/tests/errors.nom
+++ b/tests/errors.nom
@@ -1,23 +1,16 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#
Tests for the stuff defined in core/errors.nom
-try: barf
-..and if it succeeds: barf "try failed."
-
-%worked <- (no)
-try: barf
-..and if it barfs: %worked <- (yes)
+try (barf) and if it succeeds (barf "try failed.")
+%worked = (no)
+try (barf) and if it barfs (%worked = (yes))
assume %worked or barf "try/catch failed"
+%x = 1
+try:
+ %x = 2
+ do (barf) then always (%x = 3)
+..and if it barfs (do nothing)
-%x <- 1
-try
- %x <- 2
- do
- barf
- ..then always
- %x <- 3
-..and if it barfs: do nothing
-assume (%x = 3) or barf "do/then always failed"
-
-say "Error handling test passed."
+assume (%x == 3) or barf "do/then always failed"
+say "Error handling test passed." \ No newline at end of file
diff --git a/tests/math.nom b/tests/math.nom
index 3764dee..7ddefba 100644
--- a/tests/math.nom
+++ b/tests/math.nom
@@ -1,22 +1,20 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#..
Tests for the stuff defined in core/control_flow.nom
-
use "core"
-
assume (all of [inf, pi, tau, golden ratio, e]) or barf "math constants failed"
-%nan <- (NaN)
+%nan = (NaN)
assume (%nan != %nan) or barf "NaN failed"
-assume (("5" as a number) = 5)
-assume
+assume (("5" as a number) == 5)
+assume (..)
all of [..]
- abs 5, |5|, sqrt 5, √(5), sine 5, cosine 5, tangent 5, arc sine 5, arc cosine 5,
- arc tangent 5, arc tangent 5/10, hyperbolic sine 5, hyperbolic cosine 5,
- hyperbolic tangent 5, e^5, ln 5, log base 2 of 5, floor 5, ceiling 5, round 5,
+ abs 5, | 5 |, sqrt 5, √ 5, sine 5, cosine 5, tangent 5, arc sine 5, arc cosine 5
+ arc tangent 5, arc tangent 5 / 10, hyperbolic sine 5, hyperbolic cosine 5
+ hyperbolic tangent 5, e^ 5, ln 5, log base 2 of 5, floor 5, ceiling 5, round 5
..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"
+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" \ No newline at end of file
diff --git a/tests/metaprogramming.nom b/tests/metaprogramming.nom
index 083ddc7..d74542c 100644
--- a/tests/metaprogramming.nom
+++ b/tests/metaprogramming.nom
@@ -1,76 +1,71 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#
Tests for the stuff defined in core/metaprogramming.nom
use "core"
+compile [five] to (Lua value "5")
-compile [five] to: Lua value "5"
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-assume ((five) = 5) or barf "Compile to expression failed."
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+assume ((five) == 5) or barf "Compile to expression failed."
+compile [loc x] to (Lua "local _x = 99;")
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-compile [loc x] to: Lua "local _x = 99;"
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lua> "do"
loc x
assume (%x is 99) or barf "Compile to statements with locals failed."
lua> "end"
assume (%x is (nil)) or barf "Failed to properly localize a variable."
+compile [asdf] to:
+ %tmp = ""
+ return (Lua %tmp)
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-compile [asdf] to
- %tmp <- ""
- return: Lua %tmp
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asdf
assume (%tmp is (nil)) or barf "compile to is leaking variables"
-
-action [foo %x]
- %y <- (%x + 1)
+action [foo %x]:
+ %y = (%x + 1)
return %y
-assume ((foo 10) = 11) or barf "Action didn't work."
+
+assume ((foo 10) == 11) or barf "Action didn't work."
assume (%y is (nil)) or barf "Action leaked a local into globals."
+parse [baz %] as (foo %)
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+assume ((baz 10) == 11) or barf "Parse as action failed."
+parse [V] as (five)
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+assume ((V) == 5) or barf "Parse as compile action failed."
+parse [swap %x and %y] as (do (: %tmp = %x; %x = %y; %y = %tmp))
-parse [baz %] as: foo %
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-assume ((baz 10) = 11) or barf "Parse as action failed."
-
-parse [V] as: five
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-assume ((V) = 5) or barf "Parse as compile action failed."
-
-parse [swap %x and %y] as
- do
- %tmp <- %x
- %x <- %y
- %y <- %tmp
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-<- {%1:1, %2:2}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+set {%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}
+assume ((%1 == 2) and (%2 == 1)) or barf "'parse % as %' failed on 'swap % and %'"
+set {%tmp: 1, %tmp2: 2}
swap %tmp and %tmp2
-assume ((%tmp = 2) and (%tmp2 = 1)) or barf "'parse % as %' variable mangling failed."
+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"
-assume ((\(5 + 5) as value) = 10) or barf "%tree as value failed."
-
-assume ("\(\(foo %x) as nomsu)" = "foo %x") or barf "action source code failed."
-
-assume ("\(\%x as nomsu)" = "%x") or barf "var source code failed."
-
-assume ((type of {}) = "table") or barf "type of failed."
-
-assume ("\(\%x as lua identifier)" = "_x") or barf "converting to identifier failed."
-
-assume ((run "return 99") = 99) or barf "run % failed."
-
-%code <-: Lua "global_x = true;"
+assume ((\(5 + 5) as value) == 10) or barf "%tree as value failed."
+assume ("\(\(foo %x) as nomsu)" == "foo %x") or barf "action source code failed."
+assume ("\(\(%x) as nomsu)" == "%x") or barf "var source code failed."
+assume ((type of {}) == "table") or barf "type of failed."
+assume ("\(\(%x) as lua identifier)" == "_x") or barf "converting to identifier failed."
+assume ((run "return 99") == 99) or barf "run % failed."
+%code = (Lua "global_x = true;")
lua> %code
assume (=lua "global_x") or barf "Running lua from a variable failed."
-%code <-: Lua value "global_x"
+%code = (Lua value "global_x")
assume (=lua %code) or barf "Running lua from a variable failed."
-
say "Metaprogramming test passed."
diff --git a/tests/object.nom b/tests/object.nom
index 795d85e..30cf748 100644
--- a/tests/object.nom
+++ b/tests/object.nom
@@ -1,71 +1,46 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#
Tests for the object model defined in lib/object.nom
use "core"
use "lib/object.nom"
-
-object "Dog"
- (class Dog).genus <- "Canus"
- method [initialize %]
- %.barks or<- 0
-
- method [bark, woof]
- %barks <- ("Bark!" for % in 1 to ((me).barks))
- return: %barks joined with " "
-
- method [get pissed off]
- ((me).barks) +<- 1
-
-%d <-: new Dog {barks:2}
-as %d
- assume: (me) = %d
- assume: ((me).barks) = 2
- assume: (bark) = "Bark! Bark!"
- assume: (woof) = "Bark! Bark!"
+object "Dog":
+ (class Dog).genus = "Canus"
+ method [initialize %] (%.barks or= 0)
+ method [bark, woof]:
+ %barks = ("Bark!" for % in 1 to (me).barks)
+ return (%barks joined with " ")
+
+ method [get pissed off] ((me).barks += 1)
+
+%d = (new Dog {barks: 2})
+as %d:
+ assume ((me) == %d)
+ assume ((me).barks == 2)
+ assume ((bark) == "Bark! Bark!")
+ assume ((woof) == "Bark! Bark!")
get pissed off
- assume: ((me).barks) = 3
- assume: (bark) = "Bark! Bark! Bark!"
- assume: (me).genus = "Canus"
-assume: "\(%d.class)" = "Dog"
-assume: %d.genus = "Canus"
-assume: %d.barks = 3
-
-as: new Dog
- assume: ((me).barks) = 0
- ..or barf "Default initializer failed"
-
-as: new Dog {barks:1}
- assume: (bark) = "Bark!"
-
-action [foo]
- as: new Dog {barks:23}
- return: (me).barks
-
-assume: (foo) = 23
-..or barf: "Oops, \(foo) != 23"
-
-as: new Dog {barks:101}
- try: as (new Dog {barks:8}) (barf)
- ..and if it succeeds: barf
-
- assume: (me).barks = 101
- ..or barf "Error in nested 'as % %' failed to properly reset 'self'"
-
-
-object "Corgi" extends: class Dog
- method [sploot]
- "splooted"
-
-%corg <- (new Corgi)
-assume: %corg.barks = 0
-as: new Corgi {barks:1}
- assume: (sploot) = "splooted"
- ..or barf "subclass method failed"
-
- assume: (bark) = "Bark!"
- ..or barf "inheritance failed"
-
- assume: (woof) = "Bark!"
-
-say "Object test passed."
+ assume ((me).barks == 3)
+ assume ((bark) == "Bark! Bark! Bark!")
+ assume ((me).genus == "Canus")
+
+assume ("\(%d.class)" == "Dog")
+assume (%d.genus == "Canus")
+assume (%d.barks == 3)
+as (new Dog) (assume ((me).barks == 0) or barf "Default initializer failed")
+as (new Dog {barks: 1}) (assume ((bark) == "Bark!"))
+action [foo] (as (new Dog {barks: 23}) (return (me).barks))
+assume ((foo) == 23) or barf "Oops, \(foo) != 23"
+as (new Dog {barks: 101}):
+ try (as (new Dog {barks: 8}) (barf)) and if it succeeds (barf)
+ assume ((me).barks == 101) or barf "Error in nested 'as % %' failed to properly reset 'self'"
+
+object "Corgi" extends (class Dog) (method [sploot] "splooted")
+%corg = (new Corgi)
+assume (%corg.barks == 0)
+as (new Corgi {barks: 1}):
+ assume ((sploot) == "splooted") or barf "subclass method failed"
+ assume ((bark) == "Bark!") or barf "inheritance failed"
+ assume ((woof) == "Bark!")
+
+say "Object test passed." \ No newline at end of file
diff --git a/tests/operators.nom b/tests/operators.nom
index 375a80a..0ab44c1 100644
--- a/tests/operators.nom
+++ b/tests/operators.nom
@@ -1,54 +1,52 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#..
Tests for the stuff defined in core/operators.nom
-
use "core"
-
-<-{%x:10,%y:20}
-assume ((%x = 10) and (%y = 20)) or barf "mutli-assignment failed."
-<-{%x:%y, %y:%x}
-assume ((%y = 10) and (%x = 20)) or barf "swapping vars failed."
-
-% <- [%x < %y, %x <= %y, %x > %y, %x >= %y, %x = %y, %x is %y, %x != %y, %x isn't %y, %x is not %y]
+set {%x: 10, %y: 20}
+assume ((%x == 10) and (%y == 20)) or barf "mutli-assignment failed."
+set {%x: %y, %y: %x}
+assume ((%y == 10) and (%x == 20)) or barf "swapping vars failed."
+% = [..]
+ %x < %y, %x <= %y, %x > %y, %x >= %y, %x == %y, %x is %y, %x != %y, %x isn't %y
+ %x is not %y
assume ({} is {}) or barf "Equality check failed."
-assume (({}'s id) is not ({}'s id)) or barf "Identity check failed."
+assume (({} 's id) is not ({} 's id)) or barf "Identity check failed."
+set {%foozle: "outer", %y: "outer"}
+action [set global x local y]:
+ external %foozle = "inner"
+ %y = "inner"
-<-{%foozle:"outer",%y:"outer"}
-action [set global x local y]
- external %foozle <- "inner"
- %y <- "inner"
set global x local y
-assume ((%foozle = "inner") and (%y = "outer")) or barf "external failed."
+assume ((%foozle == "inner") and (%y == "outer")) or barf "external failed."
+set {%foozle: "outer", %y: "outer"}
+action [set global x local y] (..)
+ with external [%foozle]:
+ %foozle = "inner"
+ %y = "inner"
-<-{%foozle:"outer",%y:"outer"}
-action [set global x local y]
- with external [%foozle]
- %foozle <- "inner"
- %y <- "inner"
set global x local y
-assume ((%foozle = "inner") and (%y = "outer")) or barf "'with external' failed."
-
-<-{%x:1,%y:2}
-with {%z:nil, %x:999}
- %z <- 999
- assume (%z = 999) or barf "'with' failed."
- assume (%x = 999) or barf "'with' assignment failed."
-assume (%x = 1) or barf "'with' scoping failed"
-assume (%z = (nil)) or barf "'with' scoping failed"
+assume ((%foozle == "inner") and (%y == "outer")) or barf "'with external' failed."
+set {%x: 1, %y: 2}
+with {%z: nil, %x: 999}:
+ %z = 999
+ assume (%z == 999) or barf "'with' failed."
+ assume (%x == 999) or barf "'with' assignment failed."
-assume ((1 + 2*3 - 4/2^2) = 6) or barf "math expressions not working properly"
-assume ((5 wrapped around 2) = 1) or barf "mod not working"
+assume (%x == 1) or barf "'with' scoping failed"
+assume (%z == (nil)) or barf "'with' scoping failed"
+assume ((1 + 2 * 3 - 4 / 2 ^ 2) == 6) or barf "math expressions not working properly"
+assume ((5 wrapped around 2) == 1) or barf "mod not working"
assume (1 <= 2 < 3) or barf "chained operator fail."
-%value <- -999
-action [flipflop]
- external %value <- (-%value)
+%value = -999
+action [flipflop]:
+ external %value = (- %value)
return %value
+
assume (not (1 < (flipflop) < 1)) or barf "3-way inequality evaluated middle term twice"
-assume (((yes) and (yes)) = (yes))
-action [barfer]
- barf "short circuiting failed"
-assume (((no) and (barfer)) = (no))
+assume (((yes) and (yes)) == (yes))
+action [barfer] (barf "short circuiting failed")
+assume (((no) and (barfer)) == (no))
assume ((no) or (yes))
assume ((yes) or (barfer))
@@ -62,15 +60,13 @@ assume ((yes) or (barfer))
assume ((2>>>1) = 1)
#.. Ugh, Lua is stupid when it comes to bitwise arithmetic on negative numbers, so I'm
skipping the tests for those.
-
-assume ((-(5)) = -5)
-assume ((not (yes)) = (no))
-%x <- 1
-%x +<- 1
-assume (%x = 2) or barf "+<- failed"
-%x *<- 2
-assume (%x = 4) or barf "*<- failed"
+assume ((- 5) == -5)
+assume ((not (yes)) == (no))
+%x = 1
+%x += 1
+assume (%x == 2) or barf "+<- failed"
+%x *= 2
+assume (%x == 4) or barf "*<- failed"
wrap %x around 3
-assume (%x = 1) or barf "wrap around failed"
-
+assume (%x == 1) or barf "wrap around failed"
say "Operator test passed."
diff --git a/tests/os.nom b/tests/os.nom
index efc6e56..cbda5b3 100644
--- a/tests/os.nom
+++ b/tests/os.nom
@@ -1,16 +1,12 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#
Tests for the stuff defined in lib/os.nom
use "core"
use "lib/os.nom"
-
-%lines <-: lines in: read file "tests/os.nom"
-assume: %lines.3 = " Tests for the stuff defined in lib/os.nom"
-
-%n <- 0
-for file %f in "core"
- %n +<- 1
+%lines = (lines in (read file "tests/os.nom"))
+assume (%lines.3 == " Tests for the stuff defined in lib/os.nom")
+%n = 0
+for file %f in "core" (%n += 1)
assume (%n > 0) or barf "Failed to walk the 'core' directory"
-
-say "OS test passed."
+say "OS test passed." \ No newline at end of file
diff --git a/tests/scopes.nom b/tests/scopes.nom
index ffda7f6..a882dcb 100644
--- a/tests/scopes.nom
+++ b/tests/scopes.nom
@@ -1,17 +1,15 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
use "core"
+%x = "outer"
+with local %x:
+ %x = "inner"
+ assume (%x == "inner")
-%x <- "outer"
-with local %x
- %x <- "inner"
- assume: %x = "inner"
-assume: %x = "outer"
-
+assume (%x == "outer")
action [foo] "outer foo"
-with local [action: foo]
+with local [action (foo)]:
action [foo] "inner foo"
- assume: (foo) = "inner foo"
-assume: (foo) = "outer foo"
-
+ assume ((foo) == "inner foo")
-say "Scopes test passed."
+assume ((foo) == "outer foo")
+say "Scopes test passed." \ No newline at end of file
diff --git a/tests/text.nom b/tests/text.nom
index 57480d8..316b343 100644
--- a/tests/text.nom
+++ b/tests/text.nom
@@ -1,56 +1,49 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.3.4.3
#..
Tests for the stuff defined in core/text.nom
-
use "core"
-
-assume ((["x","y"] joined with ",") = "x,y") or barf "joined with failed"
-assume ((["x","y"] joined) = "xy") or barf "joined failed"
-assume (("asdf" capitalized) = "Asdf") or barf "capitalized failed"
-assume (("asdf" with "X" instead of "s") = "aXdf") or barf "substitution failed"
-assume ("\n" = (newline)) or barf "Text literals failed."
-assume (("x" + "y") = "xy")
-assume ((lines in "one\ntwo") = ["one", "two"])
-
-parse [アクション %spec %body] as: action %spec %body
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-%こんにちは <- "こんにちは"
-アクション [% と言う]
- "\(%)世界"
-
-assume ((%こんにちは と言う) = "こんにちは世界") or barf "Unicode doesn't work"
-
-%s <- ".."
- one two\nthree\
- ..four
-assume (%s = "one two\\nthreefour") or barf "%s = \(quote %s), not \(quote "one two\\nthreefour")"
-%s <- ".."
- list:\[..]
- 1,2,3
- ..
-assume (%s = "list:[1, 2, 3]")
-
-assume
- ".."
- foo = \
- 1 + 2
- ..!
- ..= "foo = 3!"
-
-assume
- ".."
- one\"\n"two
- ..= "one\ntwo"
-
-assume
- ".."
- no\
- #comment
- #
- block comment
- ..gap
- ..= "nogap"
-
-say "Text test passed."
+assume ((["x", "y"] joined with ",") == "x,y") or barf "joined with failed"
+assume ((["x", "y"] joined) == "xy") or barf "joined failed"
+assume (("asdf" capitalized) == "Asdf") or barf "capitalized failed"
+assume (("asdf" with "X" instead of "s") == "aXdf") or barf "substitution failed"
+assume (..)
+ "\n" == (newline)
+..or barf "Text literals failed."
+
+assume (("x" + "y") == "xy")
+assume (..)
+ (..)
+ lines in "one\ntwo"
+ ..== ["one", "two"]
+
+parse [アクション %spec %body] as (action %spec %body)
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+%こんにちは = "\227\129\147\227\130\147\227\129\171\227\129\161\227\129\175"
+アクション [% と言う] "\(%)\228\184\150\231\149\140"
+assume (..)
+ (%こんにちは と言う) == ".."
+ こんにちは世界
+..or barf "Unicode doesn't work"
+
+%s = "one two\\nthreefour"
+assume (..)
+ %s == "one two\\nthreefour"
+..or barf "%s = \(quote %s), not \(quote "one two\\nthreefour")"
+
+%s = "list:\[1, 2, 3]"
+assume (%s == "list:[1, 2, 3]")
+assume ("foo = \(1 + 2)!" == "foo = 3!")
+assume (..)
+ "one\ntwo"
+ ..== "one\ntwo"
+
+assume ("nogap" == "nogap")
+#comment
+#
+ block comment
+
+
+
+say "Text test passed." \ No newline at end of file