changeset 146:15f51ed08ecf

Add more tests for some degenerate cases we don't handle right.
author David A. Holland
date Sat, 13 Jul 2013 14:47:29 -0400
parents a403605d3166
children 281317d30478
files TODO tests/Makefile tests/t34.c tests/t34.good tests/t35.c tests/t35.good tests/t36.c tests/t36.good tests/t37.c tests/t37.good
diffstat 10 files changed, 63 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Sat Jul 13 14:19:59 2013 -0400
+++ b/TODO	Sat Jul 13 14:47:29 2013 -0400
@@ -21,3 +21,13 @@
 	- "#if 0 && 1/0" should not crash; fix eval method.
 	- an unterminated comment is reported as "no newline at end of file"
 	  (which isn't fatal by default)
+	- quote characters and comment delimiters that are emitted by
+	  macros are not recognized. See:
+		t34 (should produce a quote and FOO Q)
+		t35 (similarly, this test may be redundant once it's fixed)
+		t36 (C(3) should produce nothing)
+		t37 (BC foo EC should produce nothing)
+	  Joerg says comments like in t36 should be stripped exactly
+	  twice, once when the macro is defined and again when it's
+	  expanded. Note that gcc's cpp -traditional is getting t37
+	  wrong, and it gets t36 wrong with -C.
--- a/tests/Makefile	Sat Jul 13 14:19:59 2013 -0400
+++ b/tests/Makefile	Sat Jul 13 14:47:29 2013 -0400
@@ -4,7 +4,7 @@
 TESTS=\
 	t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 \
 	t17 t18 t19 t20 t21 t22 t23 t24 t25 t26 t27 t28 t29 t30 t31 t32 \
-	t33
+	t33 t34 t35 t36 t37
 
 all: run-tests .WAIT show-diffs
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t34.c	Sat Jul 13 14:47:29 2013 -0400
@@ -0,0 +1,5 @@
+#define Q "
+#define FOO foo
+Q FOO Q
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t34.good	Sat Jul 13 14:47:29 2013 -0400
@@ -0,0 +1,1 @@
+" foo "
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t35.c	Sat Jul 13 14:47:29 2013 -0400
@@ -0,0 +1,6 @@
+#define Q "
+#define FOO foo
+
+Q FOO Q 'I like "FOO" and "BAR"'
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t35.good	Sat Jul 13 14:47:29 2013 -0400
@@ -0,0 +1,1 @@
+" foo " 'I like "FOO" and "BAR"'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t36.c	Sat Jul 13 14:47:29 2013 -0400
@@ -0,0 +1,7 @@
+#define C(x) //**/* x */**//
+C(3)
+C(abc /* def */ ghi)
+
+#define D(x) ///**/**/**///**/* x */**///**/**/**///
+D(3)
+D(abc /* def */ ghi)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t36.good	Sat Jul 13 14:47:29 2013 -0400
@@ -0,0 +1,4 @@
+/* 3 */
+/* abc  ghi */
+//**/* 3 */**//
+//**/* abc  ghi */**//
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t37.c	Sat Jul 13 14:47:29 2013 -0400
@@ -0,0 +1,19 @@
+#define BC //**/*
+#define EC */**//
+
+BC
+comment?
+EC
+
+BC comment? EC
+
+#define FOO(x) x
+FOO(abc BC def EC ghi)
+
+#define BAR(x, y) x y
+BAR(abc BC def, ghi EC jkl)
+
+BC
+#define BAZ baz
+EC
+BAZ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t37.good	Sat Jul 13 14:47:29 2013 -0400
@@ -0,0 +1,9 @@
+/*
+comment?
+*/
+/* comment? */
+abc /* def */ ghi
+abc /* def  ghi */ jkl
+/*
+*/
+baz