ref: 594d18234e9f3c0591dfe2da55e6d0b9e0d97c9c
parent: 033c515dda93159968574d4d0a1f32353a2b7750
author: Ori Bernstein <[email protected]>
date: Mon Jun 4 22:26:53 EDT 2012
Add start of test cases. Stub in a few compilations and such.
--- /dev/null
+++ b/test/Makefile
@@ -1,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:
--- /dev/null
+++ b/test/add.myr
@@ -1,0 +1,8 @@
+const main = {
+ var a
+ var b
+
+ a = 42
+ b = 11
+ -> a + b
+}
--- /dev/null
+++ b/test/build.sh
@@ -1,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
--- /dev/null
+++ b/test/main.myr
@@ -1,0 +1,3 @@
+const main = {
+ -> 0
+}
--- /dev/null
+++ b/test/struct.myr
@@ -1,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
+}
--- /dev/null
+++ b/test/test.sh
@@ -1,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