diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-18 14:50:45 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-18 14:50:45 +0000 |
commit | 1e68e77f3119c2558aceb2837eb1e25111eedab9 (patch) | |
tree | 047a2eeaa92b626279e7f1cb5eb24788c0db0b3c | |
parent | 835458c3b1f055c2d2548c002120f73bb46877cc (diff) | |
download | Compiler-1e68e77f3119c2558aceb2837eb1e25111eedab9.tar.gz Compiler-1e68e77f3119c2558aceb2837eb1e25111eedab9.zip |
Made test cases a bit better
-rw-r--r-- | c_compiler/test/in/Add.c | 9 | ||||
-rw-r--r-- | c_compiler/test/in/AddMult.c | 11 | ||||
-rw-r--r-- | c_compiler/test/in/add.c | 11 | ||||
-rw-r--r-- | c_compiler/test/in/for.c | 11 | ||||
-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.c | 6 | ||||
-rwxr-xr-x | test_compiler.sh | 1 |
9 files changed, 27 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; } diff --git a/test_compiler.sh b/test_compiler.sh index 65fb311..23e2749 100755 --- a/test_compiler.sh +++ b/test_compiler.sh @@ -5,6 +5,7 @@ echo "========================================" echo " Cleaning the temporaries and outputs" make clean +rm -rf ./c_compiler/test/{out,ref} echo " Force building lexer" make -B bin/c_compiler |