shithub: scc

Download patch

ref: 5398bfe4e68b7926f301beb47299a92ff0540c10
parent: 920983fdb25153367658a04fa9e858e66793d98f
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Jun 28 06:08:19 EDT 2016

[tests] Import new tests for qc

--- /dev/null
+++ b/tests/0070-cppif.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0071-cppelif.c
@@ -1,0 +1,14 @@
+
+#if 0
+X
+#elif 1
+int x = 0;
+#else
+X
+#endif
+
+int
+main()
+{
+	return x;
+}
--- /dev/null
+++ b/tests/0072-cppelif.c
@@ -1,0 +1,14 @@
+
+#if 0
+X
+#elif 0
+X
+#elif 1
+int x = 0;
+#endif
+
+int
+main()
+{
+	return x;
+}
--- /dev/null
+++ b/tests/0073-ifndef.c
@@ -1,0 +1,17 @@
+
+
+#ifndef DEF
+int x = 0;
+#endif
+
+#define DEF
+
+#ifndef DEF
+X
+#endif
+
+int
+main()
+{
+	return x;
+}
--- /dev/null
+++ b/tests/0074-undef.c
@@ -1,0 +1,13 @@
+
+#define X 1
+#undef X
+
+#ifdef X
+FAIL
+#endif
+
+int
+main()
+{
+	return 0;
+}
--- /dev/null
+++ b/tests/0075-ptraddasn.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0076-ptrsubasn.c
@@ -1,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;
+}
--- /dev/null
+++ b/tests/0077-defined.c
@@ -1,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
--- /dev/null
+++ b/tests/0078-dirifexpr.c
@@ -1,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;
+}
+
--- /dev/null
+++ b/tests/0079-cond.c
@@ -1,0 +1,10 @@
+
+int
+main()
+{
+	if(0 ? 1 : 0)
+		return 1;
+	if(1 ? 0 : 1)
+		return 2;
+	return 0;
+}
--- /dev/null
+++ b/tests/0080-arrays.c
@@ -1,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);
+}