Updating tests.
This commit is contained in:
parent
c161f48838
commit
5629b81f78
@ -20,7 +20,7 @@ compile [%text with %sub instead of %patt, %text s/%patt/%sub] to
|
|||||||
|
|
||||||
action [lines in %text, lines of %text]
|
action [lines in %text, lines of %text]
|
||||||
lua> ".."
|
lua> ".."
|
||||||
local result = {}
|
local result = list{}
|
||||||
for line in (\%text):gmatch('[^\n]+') do
|
for line in (\%text):gmatch('[^\n]+') do
|
||||||
result[#result+1] = line
|
result[#result+1] = line
|
||||||
end
|
end
|
||||||
|
@ -159,32 +159,11 @@ when 5 = ?
|
|||||||
* else: %when_worked <- (yes)
|
* else: %when_worked <- (yes)
|
||||||
assume %when_worked
|
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
|
%x <- 1
|
||||||
do
|
do
|
||||||
%x <- 2
|
%x <- 2
|
||||||
assume (%x = 2) or barf "'do' is redefining locals"
|
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
|
assume
|
||||||
(..)
|
(..)
|
||||||
result of
|
result of
|
||||||
@ -192,4 +171,6 @@ assume
|
|||||||
for % in [1,2,3]: %n +<- %
|
for % in [1,2,3]: %n +<- %
|
||||||
return %n
|
return %n
|
||||||
..= 6
|
..= 6
|
||||||
|
..or barf "'result of %' failed"
|
||||||
|
|
||||||
|
say "Control flow test passed."
|
||||||
|
18
tests/coroutines.nom
Normal file
18
tests/coroutines.nom
Normal file
@ -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."
|
22
tests/errors.nom
Normal file
22
tests/errors.nom
Normal file
@ -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."
|
10
tests/os.nom
Normal file
10
tests/os.nom
Normal file
@ -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."
|
@ -10,8 +10,7 @@ assume (("asdf" with "X" instead of "s") = "aXdf") or barf "substitution failed"
|
|||||||
assume ("\n" = (newline)) or barf "Text literals failed."
|
assume ("\n" = (newline)) or barf "Text literals failed."
|
||||||
%x <- "\(green)hello\(reset color)"
|
%x <- "\(green)hello\(reset color)"
|
||||||
assume (("x" + "y") = "xy")
|
assume (("x" + "y") = "xy")
|
||||||
|
assume ((lines in "one\ntwo") = ["one", "two"])
|
||||||
say "Text test passed."
|
|
||||||
|
|
||||||
immediately
|
immediately
|
||||||
parse [アクション %spec %body] as: action %spec %body
|
parse [アクション %spec %body] as: action %spec %body
|
||||||
@ -52,3 +51,5 @@ assume
|
|||||||
block comment
|
block comment
|
||||||
..gap
|
..gap
|
||||||
..= "nogap"
|
..= "nogap"
|
||||||
|
|
||||||
|
say "Text test passed."
|
||||||
|
Loading…
Reference in New Issue
Block a user