diff --git a/tests/07_function.c b/tests/07_function.c new file mode 100644 index 0000000..f2b91eb --- /dev/null +++ b/tests/07_function.c @@ -0,0 +1,8 @@ +int myfunc(int x) +{ + return x * x; +} + +printint(myfunc(3)); +printint(myfunc(4)); + diff --git a/tests/07_function.expect b/tests/07_function.expect new file mode 100644 index 0000000..a683364 --- /dev/null +++ b/tests/07_function.expect @@ -0,0 +1,2 @@ +9 +16 diff --git a/tests/08_while.c b/tests/08_while.c new file mode 100644 index 0000000..312615e --- /dev/null +++ b/tests/08_while.c @@ -0,0 +1,15 @@ +int a; +int p; +int t; + +a = 1; +p = 0; +t = 0; + +while (a < 100) +{ + printint(a); + t = a; + a = t + p; + p = t; +} diff --git a/tests/08_while.expect b/tests/08_while.expect new file mode 100644 index 0000000..702d4c0 --- /dev/null +++ b/tests/08_while.expect @@ -0,0 +1,11 @@ +1 +1 +2 +3 +5 +8 +13 +21 +34 +55 +89 diff --git a/tests/09_do_while.c b/tests/09_do_while.c new file mode 100644 index 0000000..c94984a --- /dev/null +++ b/tests/09_do_while.c @@ -0,0 +1,16 @@ +int a; +int p; +int t; + +a = 1; +p = 0; +t = 0; + +do +{ + printint(a); + t = a; + a = t + p; + p = t; +} while (a < 100); + diff --git a/tests/09_do_while.expect b/tests/09_do_while.expect new file mode 100644 index 0000000..702d4c0 --- /dev/null +++ b/tests/09_do_while.expect @@ -0,0 +1,11 @@ +1 +1 +2 +3 +5 +8 +13 +21 +34 +55 +89 diff --git a/tests/Makefile b/tests/Makefile index 72e88f8..a48d49c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,7 +4,10 @@ TESTS= 00_assignment.test \ 03_struct.test \ 04_for.test \ 05_array.test \ - 06_case.test + 06_case.test \ + 07_function.test \ + 08_while.test \ + 09_do_while.test %.test: %.expect %.c @echo Test: $*...