diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/metaprogramming.nom | 36 | ||||
| -rw-r--r-- | tests/operators.nom | 15 | ||||
| -rw-r--r-- | tests/text.nom | 5 |
3 files changed, 29 insertions, 27 deletions
diff --git a/tests/metaprogramming.nom b/tests/metaprogramming.nom index af43269..e7e22c5 100644 --- a/tests/metaprogramming.nom +++ b/tests/metaprogramming.nom @@ -3,22 +3,22 @@ use "core" -immediately - compile [five] to: Lua value "5" +compile [five] to: Lua value "5" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ assume ((five) = 5) or barf "Compile to expression failed." -immediately - 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." -immediately - 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" @@ -28,20 +28,20 @@ action [foo %x] assume ((foo 10) = 11) or barf "Action didn't work." assume (%y is (nil)) or barf "Action leaked a local into globals." -immediately - parse [baz %] as: foo % +parse [baz %] as: foo % +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ assume ((baz 10) = 11) or barf "Parse as action failed." -immediately - parse [V] as: five +parse [V] as: five +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ assume ((V) = 5) or barf "Parse as compile action failed." -immediately - parse [swap %x and %y] as - do - %tmp <- %x - %x <- %y - %y <- %tmp +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 %'" diff --git a/tests/operators.nom b/tests/operators.nom index 7cdf964..4b0d6ad 100644 --- a/tests/operators.nom +++ b/tests/operators.nom @@ -51,13 +51,14 @@ assume (((no) and (barfer)) = (no)) assume ((no) or (yes)) assume ((yes) or (barfer)) -assume ((1 OR 2) = 3) -assume ((3 XOR 2) = 1) -assume ((3 AND 2) = 2) -assume ((NOT (NOT 6)) = 6) -assume ((1<<1) = 2) -assume ((2>>1) = 1) -assume ((2>>>1) = 1) +# Disabled because luajit doesn't have bitops + assume ((1 OR 2) = 3) + assume ((3 XOR 2) = 1) + assume ((3 AND 2) = 2) + assume ((NOT (NOT 6)) = 6) + assume ((1<<1) = 2) + assume ((2>>1) = 1) + 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. diff --git a/tests/text.nom b/tests/text.nom index a74ac5b..025e793 100644 --- a/tests/text.nom +++ b/tests/text.nom @@ -12,8 +12,9 @@ assume ("\n" = (newline)) or barf "Text literals failed." assume (("x" + "y") = "xy") assume ((lines in "one\ntwo") = ["one", "two"]) -immediately - parse [アクション %spec %body] as: action %spec %body +parse [アクション %spec %body] as: action %spec %body + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %こんにちは <- "こんにちは" アクション [% と言う] |
