Implement #if, #else, #elif, and #endif with tests.
So far the only expression implemented is a single integer literal,
but obviously that's easy to extend. Various things including nesting
are tested here.
diff --git a/tests/040-token-pasting.c b/tests/040-token-pasting.c
new file mode 100644
index 0000000..caab3ba
--- /dev/null
+++ b/tests/040-token-pasting.c
@@ -0,0 +1,2 @@
+#define paste(a,b) a ## b
+paste(one , token)
diff --git a/tests/041-if-0.c b/tests/041-if-0.c
new file mode 100644
index 0000000..2cab677
--- /dev/null
+++ b/tests/041-if-0.c
@@ -0,0 +1,5 @@
+success_1
+#if 0
+failure
+#endif
+success_2
diff --git a/tests/042-if-1.c b/tests/042-if-1.c
new file mode 100644
index 0000000..874a25c
--- /dev/null
+++ b/tests/042-if-1.c
@@ -0,0 +1,5 @@
+success_1
+#if 1
+success_2
+#endif
+success_3
diff --git a/tests/043-if-0-else.c b/tests/043-if-0-else.c
new file mode 100644
index 0000000..323351f
--- /dev/null
+++ b/tests/043-if-0-else.c
@@ -0,0 +1,7 @@
+success_1
+#if 0
+failure
+#else
+success_2
+#endif
+success_3
diff --git a/tests/044-if-1-else.c b/tests/044-if-1-else.c
new file mode 100644
index 0000000..28dfc25
--- /dev/null
+++ b/tests/044-if-1-else.c
@@ -0,0 +1,7 @@
+success_1
+#if 1
+success_2
+#else
+failure
+#endif
+success_3
diff --git a/tests/045-if-0-elif.c b/tests/045-if-0-elif.c
new file mode 100644
index 0000000..e50f686
--- /dev/null
+++ b/tests/045-if-0-elif.c
@@ -0,0 +1,11 @@
+success_1
+#if 0
+failure_1
+#elif 0
+failure_2
+#elif 1
+success_3
+#elif 1
+failure_3
+#endif
+success_4
diff --git a/tests/046-if-1-elsif.c b/tests/046-if-1-elsif.c
new file mode 100644
index 0000000..130515a
--- /dev/null
+++ b/tests/046-if-1-elsif.c
@@ -0,0 +1,11 @@
+success_1
+#if 1
+success_2
+#elif 0
+failure_1
+#elif 1
+failure_2
+#elif 0
+failure_3
+#endif
+success_3
diff --git a/tests/047-if-elif-else.c b/tests/047-if-elif-else.c
new file mode 100644
index 0000000..e8f0838
--- /dev/null
+++ b/tests/047-if-elif-else.c
@@ -0,0 +1,11 @@
+success_1
+#if 0
+failure_1
+#elif 0
+failure_2
+#elif 0
+failure_3
+#else
+success_2
+#endif
+success_3
diff --git a/tests/048-if-nested.c b/tests/048-if-nested.c
new file mode 100644
index 0000000..fc4679c
--- /dev/null
+++ b/tests/048-if-nested.c
@@ -0,0 +1,11 @@
+success_1
+#if 0
+failure_1
+#if 1
+failure_2
+#else
+failure_3
+#endif
+failure_4
+#endif
+success_2
diff --git a/tests/glcpp-test b/tests/glcpp-test
index 25685ee..022a236 100755
--- a/tests/glcpp-test
+++ b/tests/glcpp-test
@@ -5,5 +5,5 @@
../glcpp < $test > $test.out
gcc -E $test -o $test.gcc
grep -v '^#' < $test.gcc > $test.expected
- diff -u $test.expected $test.out
+ diff -B -u $test.expected $test.out
done