summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2012-06-05 02:26:53 -0400
committerOri Bernstein <ori@eigenstate.org>2012-06-05 02:26:53 -0400
commit594d18234e9f3c0591dfe2da55e6d0b9e0d97c9c (patch)
tree51d8380208a4c2f6e85b122bdfb4239b94744f5d
parent033c515dda93159968574d4d0a1f32353a2b7750 (diff)
downloadmc-594d18234e9f3c0591dfe2da55e6d0b9e0d97c9c.tar.gz
Add start of test cases.
Stub in a few compilations and such.
-rw-r--r--test/Makefile11
-rw-r--r--test/add.myr8
-rwxr-xr-xtest/build.sh13
-rw-r--r--test/main.myr3
-rw-r--r--test/struct.myr11
-rwxr-xr-xtest/test.sh23
6 files changed, 69 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..9f53dae
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,11 @@
+# don't build anything for 'all'
+all:
+
+check:
+ ./build.sh
+ ./test.sh
+.PHONY: clean
+clean:
+ rm -f $(TESTBIN) $(TESTBIN:=.o) $(TESTBIN:=.s)
+
+install:
diff --git a/test/add.myr b/test/add.myr
new file mode 100644
index 0000000..72424e3
--- /dev/null
+++ b/test/add.myr
@@ -0,0 +1,8 @@
+const main = {
+ var a
+ var b
+
+ a = 42
+ b = 11
+ -> a + b
+}
diff --git a/test/build.sh b/test/build.sh
new file mode 100755
index 0000000..026a239
--- /dev/null
+++ b/test/build.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+MC=../8/8m
+
+function build {
+ $MC $1.myr && \
+ mv a.s $1.s && \
+ cc -m32 -o $1 $1.s
+}
+
+build main
+build add
+build struct
diff --git a/test/main.myr b/test/main.myr
new file mode 100644
index 0000000..e4ecba4
--- /dev/null
+++ b/test/main.myr
@@ -0,0 +1,3 @@
+const main = {
+ -> 0
+}
diff --git a/test/struct.myr b/test/struct.myr
new file mode 100644
index 0000000..94a7c21
--- /dev/null
+++ b/test/struct.myr
@@ -0,0 +1,11 @@
+type pair = struct
+ a : int
+ b : int
+;;
+
+const main = {
+ var s : pair
+ s.a = 12
+ s.b = 30
+ -> s.a + s.b
+}
diff --git a/test/test.sh b/test/test.sh
new file mode 100755
index 0000000..ae8e71a
--- /dev/null
+++ b/test/test.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+export PATH=.:$PATH
+
+function prints {
+ if [ `./$1` -ne $2 ]; then
+ echo "FAIL: $1"
+ else
+ echo "PASS: $1"
+ fi
+}
+
+function returns {
+ ./$1
+ if [ $? -eq $2 ]; then
+ echo "PASS: $1"
+ else
+ echo "FAIL: $1"
+ fi
+}
+
+returns main 0
+returns add 53
+returns struct 42