shithub: riscv

Download patch

ref: 0f3953f95405ea694206f6ec41b9fd47358f03cd
parent: 04d6a2acecfe4fe44947da8b676f63bcd0f3c0fe
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Nov 17 18:09:30 EST 2023

cpp: run tests with 'mk test'

diff: cannot open b/sys/src/cmd/cpp/test//null: file does not exist: 'b/sys/src/cmd/cpp/test//null'
--- a/sys/src/cmd/cpp/test.c
+++ /dev/null
@@ -1,64 +1,0 @@
-#define NOP(x) x
-#define CAT(a, b) a ## b
-#define EOF	(-1)
-x NOP(CAT(foo, EOF)) y
-x NOP(CAT(EOF, foo)) y
-x CAT(, EOF) y
-y CAT(foo,) x
-x CAT(,foo) y
-X NOP(CAT(,)) y
-
-#define NCAT(a)	foo ## a
-NCAT(bar)
-
-#define XCAT(a)	## a
-foo XCAT(bar)
-
-#define CAT3(foo)	a##foo##b
-CAT3(blah)
-
-#define BAR	3
-#define FOO	CAT(BAR, 3)
-FOO
-
-/* Expected: a bc d */
-CAT(a b, c d)
-
-/*
- * CURRENTLY BROKEN:
- *     __VA_ARGS__ requires at least one item.
- *     It should accept an empty list.
-#define xprint(a, ...)	print(a, __VA_ARGS__)
-xprint("hi", "there")
-xprint("hi")
-*/
-
-#define C	a,b
-#define X(a)	a
-#define Y	X(C)
-Y
-
-#define    x          3
-#define    f(a)       f(x * (a))
-#undef     x
-#define    x          2
-#define    g          f
-#define    z          z[0]
-#define    h          g(~
-#define    m(a)       a(w)
-#define    w          0,1
-#define    t(a)       a
-#define    p()        int
-#define    q(x)       x
-#define    r(x,y)     x ## y
-#define    str(x)     # x
-f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);
-g(x+(3,4)-w) | h 5) & m
-(f)^m(m);
-/*
- * CURRENTLY BROKEN:
- *     mac() needs at least one argument.
- *     It should treat no args as a single empty arg list.
-p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
-char c[2][6] = { str(hello), str() };
-*/
--- a/sys/src/cmd/cpp/test.expected
+++ /dev/null
@@ -1,49 +1,0 @@
-#line 1 "/usr/ori/src/cpp/test.c"
-
-
-
-x fooEOF y
-x EOFfoo y
-x(-1) y
-y foo x
-x foo y
-X y
-
-
- foobar
-
-
-foo ## bar
-
-
- ablahb
-
-
-
- 33
-
-
-#line 32 "/usr/ori/src/cpp/test.c"
-
-
-
-
- a,b
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
- f(2 * (2+(3,4)- 0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^ m(0,1);
-#line 55 "/usr/ori/src/cpp/test.c"
--- /dev/null
+++ b/sys/src/cmd/cpp/test/edges.expected
@@ -1,0 +1,55 @@
+#line 1 "/sys/src/cmd/cpp/test/edges.in"
+
+
+
+x fooEOF y
+x EOFfoo y
+x(-1) y
+y foo x
+x foo y
+X y
+
+
+ foobar
+
+
+foo ## bar
+
+
+ ablahb
+
+
+
+ 33
+
+
+ a bc d
+WUT
+
+
+#line 36 "/sys/src/cmd/cpp/test/edges.in"
+
+
+
+
+ a,b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
+ f(2 * (2 +(3,4)- 0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^ m(0,1);
+#line 59 "/sys/src/cmd/cpp/test/edges.in"
+
+#line 66 "/sys/src/cmd/cpp/test/edges.in"
--- /dev/null
+++ b/sys/src/cmd/cpp/test/edges.in
@@ -1,0 +1,65 @@
+#define NOP(x) x
+#define CAT(a, b) a ## b
+#define EOF	(-1)
+x NOP(CAT(foo, EOF)) y
+x NOP(CAT(EOF, foo)) y
+x CAT(, EOF) y
+y CAT(foo,) x
+x CAT(,foo) y
+X NOP(CAT(,)) y
+
+#define NCAT(a)	foo ## a
+NCAT(bar)
+
+#define XCAT(a)	## a
+foo XCAT(bar)
+
+#define CAT3(foo)	a##foo##b
+CAT3(blah)
+
+#define BAR	3
+#define FOO	CAT(BAR, 3)
+FOO
+
+/* Expected: a bc d */
+CAT(a b, c d)
+WUT
+
+/*
+ * CURRENTLY BROKEN:
+ *     __VA_ARGS__ requires at least one item.
+ *     It should accept an empty list.
+#define xprint(a, ...)	print(a, __VA_ARGS__)
+xprint("hi", "there")
+xprint("hi")
+*/
+
+#define C	a,b
+#define X(a)	a
+#define Y	X(C)
+Y
+
+#define    x          3
+#define    f(a)       f(x * (a))
+#undef     x
+#define    x          2
+#define    g          f
+#define    z          z[0]
+#define    h          g(~
+#define    m(a)       a(w)
+#define    w          0,1
+#define    t(a)       a
+#define    p()        int
+#define    q(x)       x
+#define    r(x,y)     x ## y
+#define    str(x)     # x
+f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);
+g(x+(3,4)-w) | h 5) & m
+(f)^m(m);
+/*
+ * CURRENTLY BROKEN:
+ *     mac() needs at least one argument.
+ *     It should treat no args as a single empty arg list.
+p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
+char c[2][6] = { str(hello), str() };
+*/
--- /dev/null
+++ b/sys/src/cmd/cpp/test/edges.rc
@@ -1,0 +1,3 @@
+#!/bin/rc
+
+../6.out edges.in > edges.out && cmp edges.out edges.expected
--- /dev/null
+++ b/sys/src/cmd/cpp/test/mkfile
@@ -1,0 +1,6 @@
+</$objtype/mkfile
+
+TEST=\
+	edges
+
+</sys/src/cmd/mktest