aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile5
-rw-r--r--tests/xok/Makefile15
-rw-r--r--tests/xok/supertmpl.c24
-rw-r--r--tests/xok/tmpl.c17
4 files changed, 61 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..bcc91d3
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,5 @@
+all:
+ $(MAKE) -C xok
+
+clean:
+ $(MAKE) -C xok clean
diff --git a/tests/xok/Makefile b/tests/xok/Makefile
new file mode 100644
index 0000000..210982c
--- /dev/null
+++ b/tests/xok/Makefile
@@ -0,0 +1,15 @@
+FILES != echo *.c
+TARGETS := $(FILES:%.c=build/%)
+
+all: $(TARGETS)
+
+build/%: %.c ../../ngc1
+ @mkdir -p build
+ @gcc -E $< -o $@.i
+ @../../ngc1 $@.i > $@.c
+ @gcc $@.c -o $@
+ @./$@ | (grep -c 'OK' >/dev/null && echo "OK $@" || echo "FAIL $@")
+
+.PHONY: clean
+clean:
+ $(RM) -rf build
diff --git a/tests/xok/supertmpl.c b/tests/xok/supertmpl.c
new file mode 100644
index 0000000..bc946fb
--- /dev/null
+++ b/tests/xok/supertmpl.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+typedef tmpl[](){
+ int <>_ok()
+ {
+ return 20;
+ }
+};
+
+typedef supertmpl[]() = tmpl[]() {
+ int <>_superok()
+ {
+ return <>_ok();
+ }
+};
+
+typedef inst = supertmpl[]();
+
+int main()
+{
+ int ok = inst_superok();
+ if (ok == 20)
+ puts("OK");
+}
diff --git a/tests/xok/tmpl.c b/tests/xok/tmpl.c
new file mode 100644
index 0000000..7b514dd
--- /dev/null
+++ b/tests/xok/tmpl.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+typedef tmpl[](){
+ int <>_ok()
+ {
+ return 20;
+ }
+};
+
+typedef inst = tmpl[]();
+
+int main()
+{
+ int ok = inst_ok();
+ if (ok == 20)
+ puts("OK");
+}