changeset 26:ac45dcc57ff9

add some simple tests
author David A. Holland
date Mon, 20 Dec 2010 05:01:07 -0500
parents 18681e5ae6e4
children 01c3a2088ab4
files .hgignore tests/Makefile tests/t01.c tests/t01.good tests/t02.c tests/t02.good tests/t03.c tests/t03.good tests/t04.c tests/t04.good tests/t05.c tests/t05.good tests/t06.c tests/t06.good tests/t07.c tests/t07.good
diffstat 16 files changed, 57 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Dec 20 04:38:43 2010 -0500
+++ b/.hgignore	Mon Dec 20 05:01:07 2010 -0500
@@ -1,2 +1,5 @@
 ~$
 ^obj$
+
+^tests/.*\.run$
+^tests/.*\.diff$
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/Makefile	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,33 @@
+TRADCPP=../obj/tradcpp  # XXX
+
+TESTS=t01 t02 t03 t04 t05 t06 t07
+
+all: run-tests .WAIT show-diffs
+
+.for T in $(TESTS)
+run-tests: $(T).diff
+
+$(T).diff: $(T).run $(T).good $(TRADCPP)
+	-diff $(T).good $(T).run > $(T).diff
+
+$(T).run: $(TRADCPP) $(T).c
+	$(TRADCPP) $(T).c $(T).run
+.endfor
+
+show-diffs:
+	@echo '*** Test diffs ***'
+.for T in $(TESTS)
+	@cat $(T).diff
+.endfor
+
+clean:
+.for T in $(TESTS)
+	rm -f $(T).run $(T).diff
+.endfor
+
+good:
+.for T in $(TESTS)
+	cp $(T).run $(T).good
+.endfor
+
+.PHONY: all run-tests show-diffs clean good
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t01.c	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,1 @@
+glop.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t01.good	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,1 @@
+glop.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t02.c	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,2 @@
+#define glop flop
+glop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t02.good	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,1 @@
+flop
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t03.c	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,2 @@
+#define glop(x) flop x
+glop(boo)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t03.good	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,1 @@
+flop boo
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t04.c	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,2 @@
+#define string(x) "x"
+string(abc)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t04.good	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,1 @@
+"abc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t05.c	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,2 @@
+#define concat(a, b) a/**/b
+concat(abc, def)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t05.good	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,1 @@
+abcdef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t06.c	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,2 @@
+/*glop*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t06.good	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,1 @@
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t07.c	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,3 @@
+/*
+ * gloop
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t07.good	Mon Dec 20 05:01:07 2010 -0500
@@ -0,0 +1,1 @@
+