# HG changeset patch # User David A. Holland # Date 1373741249 14400 # Node ID 15f51ed08ecfb87bf4ea44de3e1f4878f61cc5a0 # Parent a403605d3166cfcd71f5ad6ac3f543c44bafa837 Add more tests for some degenerate cases we don't handle right. diff -r a403605d3166 -r 15f51ed08ecf TODO --- 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. diff -r a403605d3166 -r 15f51ed08ecf tests/Makefile --- 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 diff -r a403605d3166 -r 15f51ed08ecf tests/t34.c --- /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 + + diff -r a403605d3166 -r 15f51ed08ecf tests/t34.good --- /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 " diff -r a403605d3166 -r 15f51ed08ecf tests/t35.c --- /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"' + + diff -r a403605d3166 -r 15f51ed08ecf tests/t35.good --- /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"' diff -r a403605d3166 -r 15f51ed08ecf tests/t36.c --- /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) diff -r a403605d3166 -r 15f51ed08ecf tests/t36.good --- /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 */**// diff -r a403605d3166 -r 15f51ed08ecf tests/t37.c --- /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 diff -r a403605d3166 -r 15f51ed08ecf tests/t37.good --- /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