summaryrefslogtreecommitdiffstats
path: root/tests/common.tl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common.tl')
-rw-r--r--tests/common.tl13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/common.tl b/tests/common.tl
new file mode 100644
index 00000000..f4ad7351
--- /dev/null
+++ b/tests/common.tl
@@ -0,0 +1,13 @@
+(defmacro error-to-sym (expr)
+ ^(catch ,expr
+ (error (cond) :error)))
+
+(defmacro test (:env env expr expected)
+ (catch
+ (let ((expr-expn (macroexpand expr env)))
+ ^(ifa (not (equal (error-to-sym ,expr-expn) ',expected))
+ (error "test case ~s failed: produced ~s; expected ~s"
+ ',expr it ',expected)))
+ (error (exc)
+ (unless (eq expected :error)
+ (error "test case ~s failed to expand: expected is ~s" expr expected)))))