summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2012-06-05 19:49:19 -0400
committerOri Bernstein <orib@google.com>2012-06-05 19:49:19 -0400
commit48f0c839b6ce7bec4537e48271bcbe6def469a0c (patch)
tree205329273efbd6292e9ab90ccd742dcb62544c6f
parentc849754267a367a08b373d67b06439576b87c308 (diff)
downloadmc-48f0c839b6ce7bec4537e48271bcbe6def469a0c.tar.gz
Add fibonacci sequence test.
Tests function calls, recursion, and arithmetic.
-rwxr-xr-xtest/build.sh1
-rw-r--r--test/fib.myr14
-rwxr-xr-xtest/test.sh1
3 files changed, 16 insertions, 0 deletions
diff --git a/test/build.sh b/test/build.sh
index c0e4525..f23b14a 100755
--- a/test/build.sh
+++ b/test/build.sh
@@ -15,3 +15,4 @@ build add
build struct_oneval
build struct
build array
+build fib
diff --git a/test/fib.myr b/test/fib.myr
new file mode 100644
index 0000000..6eb4b44
--- /dev/null
+++ b/test/fib.myr
@@ -0,0 +1,14 @@
+const fib = {n
+ if n == 0
+ -> 0
+ elif n == 1
+ -> 1
+ else
+ -> fib(n - 1) + fib(n - 2)
+ ;;
+}
+
+const main = {
+ -> fib(4)
+}
+
diff --git a/test/test.sh b/test/test.sh
index 1495f35..98141d7 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -23,3 +23,4 @@ returns add 53
returns struct_oneval 12
returns struct 42
returns array 7
+returns fib 8