aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-18 14:50:45 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-18 14:50:45 +0000
commit1e68e77f3119c2558aceb2837eb1e25111eedab9 (patch)
tree047a2eeaa92b626279e7f1cb5eb24788c0db0b3c /c_compiler
parent835458c3b1f055c2d2548c002120f73bb46877cc (diff)
downloadCompiler-1e68e77f3119c2558aceb2837eb1e25111eedab9.tar.gz
Compiler-1e68e77f3119c2558aceb2837eb1e25111eedab9.zip
Made test cases a bit better
Diffstat (limited to 'c_compiler')
-rw-r--r--c_compiler/test/in/Add.c9
-rw-r--r--c_compiler/test/in/AddMult.c11
-rw-r--r--c_compiler/test/in/add.c11
-rw-r--r--c_compiler/test/in/for.c11
-rw-r--r--c_compiler/test/in/function_call.c (renamed from c_compiler/test/in/FunctionCall.c)2
-rw-r--r--c_compiler/test/in/if_else.c (renamed from c_compiler/test/in/IfElse.c)0
-rw-r--r--c_compiler/test/in/mult.c (renamed from c_compiler/test/in/Mult.c)4
-rw-r--r--c_compiler/test/in/while.c6
8 files changed, 26 insertions, 28 deletions
diff --git a/c_compiler/test/in/Add.c b/c_compiler/test/in/Add.c
deleted file mode 100644
index b3b1f05..0000000
--- a/c_compiler/test/in/Add.c
+++ /dev/null
@@ -1,9 +0,0 @@
-int main() {
- int x = 8;
- int y = 29;
- int z = 84;
-
- z = (9 + 2 + 3) / 2 + 3 / (2 + 1);
-
- return z;
-}
diff --git a/c_compiler/test/in/AddMult.c b/c_compiler/test/in/AddMult.c
deleted file mode 100644
index 92403bc..0000000
--- a/c_compiler/test/in/AddMult.c
+++ /dev/null
@@ -1,11 +0,0 @@
-int main() {
- int x;
- int a = 8;
- int b = 5;
- int c = 7;
- int d = 3;
- x = a * b + c * d - d / 3 + 2;
- x = c - 2 * b + 3 / d - 5 * d;
-
- return x;
-}
diff --git a/c_compiler/test/in/add.c b/c_compiler/test/in/add.c
new file mode 100644
index 0000000..94116d5
--- /dev/null
+++ b/c_compiler/test/in/add.c
@@ -0,0 +1,11 @@
+int main()
+{
+ int x = 8;
+ int y = 29;
+ int z = 84;
+
+ z = z + y + (3 - y) + x;
+ z = z - 3;
+
+ return z;
+}
diff --git a/c_compiler/test/in/for.c b/c_compiler/test/in/for.c
index 0af6158..5163ba5 100644
--- a/c_compiler/test/in/for.c
+++ b/c_compiler/test/in/for.c
@@ -2,11 +2,12 @@ int main()
{
int x, y, z;
- x = 2 * 3;
- y = 1 * 3;
- z = 9;
+ y = 0;
+ for(x = 0; x < 50; x = x+1) {
+ y = y + 1;
+ }
- y = x + y + z;
+ z = y + x - 5;
- return y;
+ return z;
}
diff --git a/c_compiler/test/in/FunctionCall.c b/c_compiler/test/in/function_call.c
index 75715fc..8defdaf 100644
--- a/c_compiler/test/in/FunctionCall.c
+++ b/c_compiler/test/in/function_call.c
@@ -1,6 +1,6 @@
int f(int a, int b, int c, int d, int f)
{
- return a + b + c+d+f;
+ return a + b + c + d + f;
}
int main()
diff --git a/c_compiler/test/in/IfElse.c b/c_compiler/test/in/if_else.c
index 8c87ce7..8c87ce7 100644
--- a/c_compiler/test/in/IfElse.c
+++ b/c_compiler/test/in/if_else.c
diff --git a/c_compiler/test/in/Mult.c b/c_compiler/test/in/mult.c
index 4855b54..9f19107 100644
--- a/c_compiler/test/in/Mult.c
+++ b/c_compiler/test/in/mult.c
@@ -1,9 +1,11 @@
-int main() {
+int main()
+{
int x = 4*2;
int y = 7;
int z = 14 % 8;
z = x * y * z / z * x;
+ z = z / 1;
return z;
}
diff --git a/c_compiler/test/in/while.c b/c_compiler/test/in/while.c
index 00ad19d..caa38b2 100644
--- a/c_compiler/test/in/while.c
+++ b/c_compiler/test/in/while.c
@@ -1,11 +1,15 @@
int main()
{
int x = 0;
+ int y;
+ y = 0;
while(x < 10)
{
+ y = y + 1;
+
x = x + 1;
}
- return x;
+ return y;
}