aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/test
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-21 17:03:38 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-21 17:03:38 +0000
commit190b7a0e5d45367230795ac0bdf6fc2f248ba9e1 (patch)
treedc9a605ced1784faf80d71f7f59e49b79d6bb2c7 /c_compiler/test
parentaf8b76d0a83813b3cebac7468db4bd64e534c235 (diff)
downloadCompiler-190b7a0e5d45367230795ac0bdf6fc2f248ba9e1.tar.gz
Compiler-190b7a0e5d45367230795ac0bdf6fc2f248ba9e1.zip
changed type layout to have all necessary information
Diffstat (limited to 'c_compiler/test')
-rw-r--r--c_compiler/test/in/fib.c20
-rw-r--r--c_compiler/test/in/fib_recusive.c24
-rw-r--r--c_compiler/test/in/for.c5
3 files changed, 46 insertions, 3 deletions
diff --git a/c_compiler/test/in/fib.c b/c_compiler/test/in/fib.c
new file mode 100644
index 0000000..17a3b41
--- /dev/null
+++ b/c_compiler/test/in/fib.c
@@ -0,0 +1,20 @@
+int main()
+{
+ int n, first = 0, second = 1, next, c;
+
+ n = 10;
+
+ for ( c = 0 ; c < n ; c++ )
+ {
+ if ( c <= 1 )
+ next = c;
+ else
+ {
+ next = first + second;
+ first = second;
+ second = next;
+ }
+ }
+
+ return next;
+}
diff --git a/c_compiler/test/in/fib_recusive.c b/c_compiler/test/in/fib_recusive.c
new file mode 100644
index 0000000..55abe06
--- /dev/null
+++ b/c_compiler/test/in/fib_recusive.c
@@ -0,0 +1,24 @@
+int Fibonacci(int n)
+{
+ if ( n == 0 )
+ return 0;
+ else if ( n == 1 )
+ return 1;
+ else
+ return ( Fibonacci(n-1) + Fibonacci(n-2) );
+}
+
+int main()
+{
+ int n, i = 0, c, res = 0;
+
+ n = 10;
+
+ for ( c = 1 ; c <= n ; c++ )
+ {
+ res = Fibonacci(i);
+ i++;
+ }
+
+ return res;
+}
diff --git a/c_compiler/test/in/for.c b/c_compiler/test/in/for.c
index 5163ba5..1f6d104 100644
--- a/c_compiler/test/in/for.c
+++ b/c_compiler/test/in/for.c
@@ -3,11 +3,10 @@ int main()
int x, y, z;
y = 0;
- for(x = 0; x < 50; x = x+1) {
+ for(x = 0; x < 50; x++) {
y = y + 1;
}
- z = y + x - 5;
-
+ z = y + x - 6;
return z;
}