aboutsummaryrefslogtreecommitdiff
path: root/lib/testing.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2017-09-21 00:10:26 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2017-09-21 00:10:26 -0700
commit371548150618d5b3501f388972077b5d035f7d8a (patch)
tree8a1cdf99dc25536e21a5a571e5d54607a50848f4 /lib/testing.nom
parent0750d642624b2262afdb4dd17b275a16e96971b5 (diff)
Another overhaul, this time pulling all the chunks of the core lib into
their own files.
Diffstat (limited to 'lib/testing.nom')
-rw-r--r--lib/testing.nom14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/testing.nom b/lib/testing.nom
new file mode 100644
index 0000000..48b311f
--- /dev/null
+++ b/lib/testing.nom
@@ -0,0 +1,14 @@
+require "lib/metaprogramming.nom"
+
+# For unit testing
+macro block [test %code yields %expected] =:
+ %generated =: lua expr "compiler.utils.repr(compiler:stringify_tree(vars.code.value))"
+ %expected =: %expected as lua expr
+ if (%generated != %expected):
+ say "Test failed!"
+ say "Expected:"
+ say %expected
+ say "But got:"
+ say %generated
+ error!
+ return ""