From b2a47642713286c195d2e4fd27b67019a0cba411 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 23 Jul 2015 08:06:43 -0700 Subject: Split off test macros from ifa.tl into common file. * Makefile (TESTS_OUT): Don't use find to hunt down tests; but rather wildcard. This way common.tl is not mistakenly identified as an independent test file. * tests/012/ifa.tl: Removed test code, placed in new file which is loaded. * tests/common.tl: New file. --- ChangeLog | 13 +++++++++++++ Makefile | 7 +++---- tests/012/ifa.tl | 15 +-------------- tests/common.tl | 13 +++++++++++++ 4 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 tests/common.tl diff --git a/ChangeLog b/ChangeLog index d57de311..605b65c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2015-07-23 Kaz Kylheku + + Split off test macros from ifa.tl into common file. + + * Makefile (TESTS_OUT): Don't use find to hunt down tests; + but rather wildcard. This way common.tl is not mistakenly + identified as an independent test file. + + * tests/012/ifa.tl: Removed test code, placed in new file + which is loaded. + + * tests/common.tl: New file. + 2015-07-23 Kaz Kylheku Fixes for building in separate dir. diff --git a/Makefile b/Makefile index cbb1219d..ace97a2d 100644 --- a/Makefile +++ b/Makefile @@ -242,10 +242,9 @@ endif TESTS_TMP := txr.test.out TESTS_OUT := $(addprefix tst/,\ - $(patsubst %.tl,%.out,\ - $(patsubst %.txr,%.out,\ - $(shell find -H tests \ - \( -name '*.txr' -o -name '*.tl' \) | sort)))) + $(patsubst %.tl,%.out,\ + $(patsubst %.txr,%.out,\ + $(wildcard $(addprefix tests/*/*.,txr tl))))) TESTS_OK := $(TESTS_OUT:.out=.ok) .PHONY: tests diff --git a/tests/012/ifa.tl b/tests/012/ifa.tl index ae283abc..64fc6793 100644 --- a/tests/012/ifa.tl +++ b/tests/012/ifa.tl @@ -1,17 +1,4 @@ -(defmacro error-to-sym (expr) - ^(catch ,expr - (error (cond) :error))) - -;; test framework for ifa uses ifa! -(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))))) +(load "../common") ;; "it" is (+ 2 2) (test (ifa (> (+ 2 2) 0) (* it 2)) 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))))) -- cgit v1.2.3