[hackers] [scc] [tests] Import new tests for qc || Roberto E. Vargas Caballero
commit 43dd1d697192c9831ef353f9932884f88c0e6f4c
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Jun 28 10:08:19 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Jun 28 10:08:19 2016 +0200
[tests] Import new tests for qc
diff --git a/tests/0070-cppif.c b/tests/0070-cppif.c
new file mode 100644
index 0000000..e4eef1f
--- /dev/null
+++ b/tests/0070-cppif.c
_AT_@ -0,0 +1,19 @@
+
+#if 1
+int x = 0;
+#endif
+
+#if 0
+int x = 1;
+#if 1
+ X
+#endif
+#ifndef AAA
+ X
+#endif
+#endif
+
+int main()
+{
+ return x;
+}
diff --git a/tests/0071-cppelif.c b/tests/0071-cppelif.c
new file mode 100644
index 0000000..6355f47
--- /dev/null
+++ b/tests/0071-cppelif.c
_AT_@ -0,0 +1,14 @@
+
+#if 0
+X
+#elif 1
+int x = 0;
+#else
+X
+#endif
+
+int
+main()
+{
+ return x;
+}
diff --git a/tests/0072-cppelif.c b/tests/0072-cppelif.c
new file mode 100644
index 0000000..71b351b
--- /dev/null
+++ b/tests/0072-cppelif.c
_AT_@ -0,0 +1,14 @@
+
+#if 0
+X
+#elif 0
+X
+#elif 1
+int x = 0;
+#endif
+
+int
+main()
+{
+ return x;
+}
diff --git a/tests/0073-ifndef.c b/tests/0073-ifndef.c
new file mode 100644
index 0000000..5636dcd
--- /dev/null
+++ b/tests/0073-ifndef.c
_AT_@ -0,0 +1,17 @@
+
+
+#ifndef DEF
+int x = 0;
+#endif
+
+#define DEF
+
+#ifndef DEF
+X
+#endif
+
+int
+main()
+{
+ return x;
+}
diff --git a/tests/0074-undef.c b/tests/0074-undef.c
new file mode 100644
index 0000000..ac870e8
--- /dev/null
+++ b/tests/0074-undef.c
_AT_@ -0,0 +1,13 @@
+
+#define X 1
+#undef X
+
+#ifdef X
+FAIL
+#endif
+
+int
+main()
+{
+ return 0;
+}
diff --git a/tests/0075-ptraddasn.c b/tests/0075-ptraddasn.c
new file mode 100644
index 0000000..d3ec201
--- /dev/null
+++ b/tests/0075-ptraddasn.c
_AT_@ -0,0 +1,15 @@
+
+int
+main()
+{
+ int arr[2];
+ int *p;
+
+ p = &arr[0];
+ p += 1;
+ *p = 123;
+
+ if(arr[1] != 123)
+ return 1;
+ return 0;
+}
diff --git a/tests/0076-ptrsubasn.c b/tests/0076-ptrsubasn.c
new file mode 100644
index 0000000..45cb5da
--- /dev/null
+++ b/tests/0076-ptrsubasn.c
_AT_@ -0,0 +1,15 @@
+
+int
+main()
+{
+ int arr[2];
+ int *p;
+
+ p = &arr[1];
+ p -= 1;
+ *p = 123;
+
+ if(arr[0] != 123)
+ return 1;
+ return 0;
+}
diff --git a/tests/0077-defined.c b/tests/0077-defined.c
new file mode 100644
index 0000000..88fb17c
--- /dev/null
+++ b/tests/0077-defined.c
_AT_@ -0,0 +1,33 @@
+
+#if defined X
+X
+#endif
+
+#if defined(X)
+X
+#endif
+
+#if X
+X
+#endif
+
+#define X 0
+
+#if X
+X
+#endif
+
+#if defined(X)
+int x = 0;
+#endif
+
+#undef X
+#define X 1
+
+#if X
+int
+main()
+{
+ return 0;
+}
+#endif
diff --git a/tests/0078-dirifexpr.c b/tests/0078-dirifexpr.c
new file mode 100644
index 0000000..2d17e92
--- /dev/null
+++ b/tests/0078-dirifexpr.c
_AT_@ -0,0 +1,171 @@
+
+#if (-2) != -2
+#error fail
+#endif
+
+#if (0 || 0) != 0
+#error fail
+#endif
+
+#if (1 || 0) != 1
+#error fail
+#endif
+
+#if (1 || 1) != 1
+#error fail
+#endif
+
+#if (0 && 0) != 0
+#error fail
+#endif
+
+#if (1 && 0) != 0
+#error fail
+#endif
+
+#if (0 && 1) != 0
+#error fail
+#endif
+
+#if (1 && 1) != 1
+#error fail
+#endif
+
+#if (0xf0 | 1) != 0xf1
+#error fail
+#endif
+
+#if (0xf0 & 1) != 0
+#error fail
+#endif
+
+#if (0xf0 & 0x1f) != 0x10
+#error fail
+#endif
+
+#if (1 ^ 1) != 0
+#error fail
+#endif
+
+#if (1 == 1) != 1
+#error fail
+#endif
+
+#if (1 == 0) != 0
+#error fail
+#endif
+
+#if (1 != 1) != 0
+#error fail
+#endif
+
+#if (0 != 1) != 1
+#error fail
+#endif
+
+#if (0 > 1) != 0
+#error fail
+#endif
+
+#if (0 < 1) != 1
+#error fail
+#endif
+
+#if (0 > -1) != 1
+#error fail
+#endif
+
+#if (0 < -1) != 0
+#error fail
+#endif
+
+#if (0 >= 1) != 0
+#error fail
+#endif
+
+#if (0 <= 1) != 1
+#error fail
+#endif
+
+#if (0 >= -1) != 1
+#error fail
+#endif
+
+#if (0 <= -1) != 0
+#error fail
+#endif
+
+#if (0 < 0) != 0
+#error fail
+#endif
+
+#if (0 <= 0) != 1
+#error fail
+#endif
+
+#if (0 > 0) != 0
+#error fail
+#endif
+
+#if (0 >= 0) != 1
+#error fail
+#endif
+
+#if (1 << 1) != 2
+#error fail
+#endif
+
+#if (2 >> 1) != 1
+#error fail
+#endif
+
+#if (2 + 1) != 3
+#error fail
+#endif
+
+#if (2 - 3) != -1
+#error fail
+#endif
+
+#if (2 * 3) != 6
+#error fail
+#endif
+
+#if (6 / 3) != 2
+#error fail
+#endif
+
+#if (7 % 3) != 1
+#error fail
+#endif
+
+#if (2+2*3+2) != 10
+#error fail
+#endif
+
+#if ((2+2)*(3+2)) != 20
+#error fail
+#endif
+
+#if (2 + 2 + 2 + 2 == 2 + 2 * 3) != 1
+#error fail
+#endif
+
+#if (1,2,3) != 3
+#error fail
+#endif
+
+#if (0 ? 1 : 3) != 3
+#error fail
+#endif
+
+#if (1 ? 3 : 1) != 3
+#error fail
+#endif
+
+int
+main()
+{
+ return 0;
+}
+
diff --git a/tests/0079-cond.c b/tests/0079-cond.c
new file mode 100644
index 0000000..1b1a329
--- /dev/null
+++ b/tests/0079-cond.c
_AT_@ -0,0 +1,10 @@
+
+int
+main()
+{
+ if(0 ? 1 : 0)
+ return 1;
+ if(1 ? 0 : 1)
+ return 2;
+ return 0;
+}
diff --git a/tests/0080-arrays.c b/tests/0080-arrays.c
new file mode 100644
index 0000000..6d11cd3
--- /dev/null
+++ b/tests/0080-arrays.c
_AT_@ -0,0 +1,49 @@
+
+int
+foo(int x[100])
+{
+ int y[100];
+ int *p;
+
+ y[0] = 2000;
+
+ if(x[0] != 1000)
+ {
+ return 1;
+ }
+
+ p = x;
+
+ if(p[0] != 1000)
+ {
+ return 2;
+ }
+
+ p = y;
+
+ if(p[0] != 2000)
+ {
+ return 3;
+ }
+
+ if(sizeof(x) != sizeof(void*))
+ {
+ return 4;
+ }
+
+ if(sizeof(y) <= sizeof(x))
+ {
+ return 5;
+ }
+
+ return 0;
+}
+
+int
+main()
+{
+ int x[100];
+ x[0] = 1000;
+
+ return foo(x);
+}
Received on Mon Jul 18 2016 - 18:06:42 CEST
This archive was generated by hypermail 2.3.0
: Mon Jul 18 2016 - 18:12:34 CEST