aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-15 00:40:36 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-15 00:40:40 -0700
commit5629b81f78c722e8001b8cee1628085a78a8ea9f (patch)
treefc3b36c3c4ac5176d8269e523109468f2ff6be77 /tests
parentc161f48838ea13a98c37d50df030ad336be97171 (diff)
Updating tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/control_flow.nom23
-rw-r--r--tests/coroutines.nom18
-rw-r--r--tests/errors.nom22
-rw-r--r--tests/os.nom10
-rw-r--r--tests/text.nom5
5 files changed, 55 insertions, 23 deletions
diff --git a/tests/control_flow.nom b/tests/control_flow.nom
index 238bcbf..56c99a0 100644
--- a/tests/control_flow.nom
+++ b/tests/control_flow.nom
@@ -159,32 +159,11 @@ when 5 = ?
* else: %when_worked <- (yes)
assume %when_worked
-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
do
%x <- 2
assume (%x = 2) or barf "'do' is redefining locals"
-%x <- 1
-try
- %x <- 2
- do
- barf
- ..then always
- %x <- 3
-..and if it barfs: do nothing
-lua> "collectgarbage()"
-assume (%x = 3) or barf "do/then always failed"
-
-say "Control flow test passed."
-
assume
(..)
result of
@@ -192,4 +171,6 @@ assume
for % in [1,2,3]: %n +<- %
return %n
..= 6
+..or barf "'result of %' failed"
+say "Control flow test passed."
diff --git a/tests/coroutines.nom b/tests/coroutines.nom
new file mode 100644
index 0000000..8d58170
--- /dev/null
+++ b/tests/coroutines.nom
@@ -0,0 +1,18 @@
+#
+ 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."
diff --git a/tests/errors.nom b/tests/errors.nom
new file mode 100644
index 0000000..1788a34
--- /dev/null
+++ b/tests/errors.nom
@@ -0,0 +1,22 @@
+#
+ 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)
+assume %worked or barf "try/catch failed"
+
+%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."
diff --git a/tests/os.nom b/tests/os.nom
new file mode 100644
index 0000000..f96009f
--- /dev/null
+++ b/tests/os.nom
@@ -0,0 +1,10 @@
+#
+ 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.2 = " Tests for the stuff defined in lib/os.nom"
+
+say "OS test passed."
diff --git a/tests/text.nom b/tests/text.nom
index 134fff2..a74ac5b 100644
--- a/tests/text.nom
+++ b/tests/text.nom
@@ -10,8 +10,7 @@ assume (("asdf" with "X" instead of "s") = "aXdf") or barf "substitution failed"
assume ("\n" = (newline)) or barf "Text literals failed."
%x <- "\(green)hello\(reset color)"
assume (("x" + "y") = "xy")
-
-say "Text test passed."
+assume ((lines in "one\ntwo") = ["one", "two"])
immediately
parse [アクション %spec %body] as: action %spec %body
@@ -52,3 +51,5 @@ assume
block comment
..gap
..= "nogap"
+
+say "Text test passed."