aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2017-03-10 20:24:02 +0000
committerymherklotz <ymherklotz@gmail.com>2017-03-10 20:24:02 +0000
commit545ce63f17eed12c193690868ce6344e7a497c91 (patch)
treed325b9504aade9487c8d982a5e3600ac43b8be2c
parenta6fa6da5de8252a205e000dd7acc2589735aa55c (diff)
downloadCompiler-545ce63f17eed12c193690868ce6344e7a497c91.tar.gz
Compiler-545ce63f17eed12c193690868ce6344e7a497c91.zip
Adding test cases
-rw-r--r--.gitignore1
-rw-r--r--c_compiler/test/in/ComplexAssignment.c20
-rw-r--r--c_compiler/test/in/ScopeWithAdd.c11
-rw-r--r--c_compiler/test/in/SimpleAdd.c5
-rw-r--r--c_compiler/test/in/SimpleAdd_2.c9
-rw-r--r--c_compiler/test/in/SimpleAssignment.c5
-rw-r--r--c_compiler/test/in/SimpleDeclaration.c4
-rw-r--r--c_compiler/test/in/SimpleReturn.c3
-rw-r--r--c_compiler/test/in/SimpleScope.c7
-rw-r--r--c_compiler/test/in/SimpleShadowing.c8
-rw-r--r--c_compiler/test/in/SimpleSubtraction.c6
11 files changed, 78 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index bb133bc..c550c1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,5 @@ c_compiler/build/
.#*
*.log
.vagrant
-test/
*~
working/
diff --git a/c_compiler/test/in/ComplexAssignment.c b/c_compiler/test/in/ComplexAssignment.c
new file mode 100644
index 0000000..394cedb
--- /dev/null
+++ b/c_compiler/test/in/ComplexAssignment.c
@@ -0,0 +1,20 @@
+int main()
+{
+ int a = 5;
+ int b = 49;
+ int c = 239;
+ int d = 23;
+ int f = 234;
+ int g = 12;
+
+ a = d;
+ b = f;
+ g = f;
+ a = g;
+ d = g;
+ a = d;
+ g = c;
+ c = a;
+ a = f;
+ return a;
+}
diff --git a/c_compiler/test/in/ScopeWithAdd.c b/c_compiler/test/in/ScopeWithAdd.c
new file mode 100644
index 0000000..5505cbf
--- /dev/null
+++ b/c_compiler/test/in/ScopeWithAdd.c
@@ -0,0 +1,11 @@
+int main() {
+ int x = 4;
+ int y = 35;
+
+ {
+ int x = 3 + 3;
+ }
+
+ x = 4 + 5;
+ return x;
+}
diff --git a/c_compiler/test/in/SimpleAdd.c b/c_compiler/test/in/SimpleAdd.c
new file mode 100644
index 0000000..a04941d
--- /dev/null
+++ b/c_compiler/test/in/SimpleAdd.c
@@ -0,0 +1,5 @@
+int main() {
+ int a = 68;
+ int b = 38;
+ return a + b;
+}
diff --git a/c_compiler/test/in/SimpleAdd_2.c b/c_compiler/test/in/SimpleAdd_2.c
new file mode 100644
index 0000000..c03a527
--- /dev/null
+++ b/c_compiler/test/in/SimpleAdd_2.c
@@ -0,0 +1,9 @@
+int main() {
+ int x = 4;
+ int y;
+ x = x + 1;
+ x = x + 2;
+
+ y = x - 1;
+ y = x + y;
+}
diff --git a/c_compiler/test/in/SimpleAssignment.c b/c_compiler/test/in/SimpleAssignment.c
new file mode 100644
index 0000000..911f7e2
--- /dev/null
+++ b/c_compiler/test/in/SimpleAssignment.c
@@ -0,0 +1,5 @@
+int main() {
+ int x;
+ x = 15;
+ return x;
+}
diff --git a/c_compiler/test/in/SimpleDeclaration.c b/c_compiler/test/in/SimpleDeclaration.c
new file mode 100644
index 0000000..95c954c
--- /dev/null
+++ b/c_compiler/test/in/SimpleDeclaration.c
@@ -0,0 +1,4 @@
+int main() {
+ int x = 26;
+ return x;
+}
diff --git a/c_compiler/test/in/SimpleReturn.c b/c_compiler/test/in/SimpleReturn.c
new file mode 100644
index 0000000..c362948
--- /dev/null
+++ b/c_compiler/test/in/SimpleReturn.c
@@ -0,0 +1,3 @@
+int main() {
+ return 13;
+}
diff --git a/c_compiler/test/in/SimpleScope.c b/c_compiler/test/in/SimpleScope.c
new file mode 100644
index 0000000..85294a1
--- /dev/null
+++ b/c_compiler/test/in/SimpleScope.c
@@ -0,0 +1,7 @@
+int main() {
+ int x = 23;
+ {
+ x = 123;
+ }
+ return x;
+}
diff --git a/c_compiler/test/in/SimpleShadowing.c b/c_compiler/test/in/SimpleShadowing.c
new file mode 100644
index 0000000..927afce
--- /dev/null
+++ b/c_compiler/test/in/SimpleShadowing.c
@@ -0,0 +1,8 @@
+int main() {
+ int x = 12;
+ {
+ int x = 39;
+ }
+
+ return x;
+}
diff --git a/c_compiler/test/in/SimpleSubtraction.c b/c_compiler/test/in/SimpleSubtraction.c
new file mode 100644
index 0000000..4d88002
--- /dev/null
+++ b/c_compiler/test/in/SimpleSubtraction.c
@@ -0,0 +1,6 @@
+int main() {
+ int a = 23;
+ int b = 19;
+ int c = a - b;
+ return c;
+}