summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile3
-rwxr-xr-xrun_tests.sh34
-rw-r--r--tests/Apply.expected8
-rw-r--r--tests/Apply.ml8
-rw-r--r--tests/Assert.expected3
-rw-r--r--tests/Assert.ml3
-rw-r--r--tests/BoxedInt.expected8
-rw-r--r--tests/BoxedInt.ml7
-rw-r--r--tests/LetIn.expected3
-rw-r--r--tests/LetIn.ml4
-rw-r--r--tests/Standard.expected6
-rw-r--r--tests/Standard.ml5
-rw-r--r--tests/TrivialMatch.expected3
-rw-r--r--tests/TrivialMatch.ml4
-rw-r--r--tests/TrivialValue.expected4
-rw-r--r--tests/TrivialValue.ml2
16 files changed, 105 insertions, 0 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 1cabcc1..0ca9786 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -5,4 +5,7 @@ PKG= bigarray compiler-libs.bytecomp compiler-libs.common
PKG+= compiler-libs.toplevel
PROG= tamasheq
+tests: $(PROG)
+ ./run_tests.sh
+
include ostumake/gnu.ocaml.prog.mk
diff --git a/run_tests.sh b/run_tests.sh
new file mode 100755
index 0000000..dcfa7ef
--- /dev/null
+++ b/run_tests.sh
@@ -0,0 +1,34 @@
+#!/bin/env bash
+
+tmp=$(mktemp -d "/tmp/tamasheq.XXXX")
+failure_count=0
+
+cd tests
+
+for input in *.ml; do
+ expected="${input/ml/expected}"
+ name="${input%\.ml}"
+ output="$tmp/${input/ml/output}"
+
+ if ../tamasheq -denv -o "$tmp" "$input" > "$output" 2>&1; then
+ if cmp -s "$expected" "$output"; then
+ printf "%-20s\tSUCCESS\n" "$name" >&2
+ rm "$tmp"/*
+ else
+ printf "%-20s\tFAILURE\n" "$name" >&2
+ failure_count=$((failure_count + 1))
+ fi
+ else
+ printf "%-20s\tFAILURE\n" "$name" >&2
+ failure_count=$((failure_count + 1))
+ fi
+done
+
+if [ "$failure_count" -gt 0 ]; then
+ printf "\n$failure_count test(s) failed\nplease see $tmp for more information\n" >&2
+ exit 1
+else
+ printf "\nall the tests were successful\n" >&2
+ rm -r "$tmp"
+ exit 0
+fi
diff --git a/tests/Apply.expected b/tests/Apply.expected
new file mode 100644
index 0000000..661e043
--- /dev/null
+++ b/tests/Apply.expected
@@ -0,0 +1,8 @@
+Apply_0 = [6] {
+ (no name) = <abstr:247>
+ (no name) = 2
+ (no name) = 4
+ (no name) = <abstr:247>
+ (no name) = <abstr:247>
+ (no name) = 8
+}
diff --git a/tests/Apply.ml b/tests/Apply.ml
new file mode 100644
index 0000000..1cbd3e6
--- /dev/null
+++ b/tests/Apply.ml
@@ -0,0 +1,8 @@
+let f x = x + 1
+let x = f 1
+let y = f (f (f 1))
+
+let g x y z = x + y + z
+let h x y = g x y 5
+
+let z = h 1 2
diff --git a/tests/Assert.expected b/tests/Assert.expected
new file mode 100644
index 0000000..f6fb00d
--- /dev/null
+++ b/tests/Assert.expected
@@ -0,0 +1,3 @@
+Assert_0 = [1] {
+ (no name) = 0
+}
diff --git a/tests/Assert.ml b/tests/Assert.ml
new file mode 100644
index 0000000..5017ed6
--- /dev/null
+++ b/tests/Assert.ml
@@ -0,0 +1,3 @@
+let x =
+ assert (1 > 0);
+ 0
diff --git a/tests/BoxedInt.expected b/tests/BoxedInt.expected
new file mode 100644
index 0000000..e129041
--- /dev/null
+++ b/tests/BoxedInt.expected
@@ -0,0 +1,8 @@
+BoxedInt_0 = [6] {
+ (no name) = <abstr:255>
+ (no name) = <abstr:255>
+ (no name) = <abstr:255>
+ (no name) = 1
+ (no name) = 1
+ (no name) = 2
+}
diff --git a/tests/BoxedInt.ml b/tests/BoxedInt.ml
new file mode 100644
index 0000000..ad8db7c
--- /dev/null
+++ b/tests/BoxedInt.ml
@@ -0,0 +1,7 @@
+let x = Int32.of_int 1
+let y = Int64.of_int 1
+let z = Int64.to_int32 y |> Int32.add x |> Nativeint.of_int32
+
+let a = Int32.to_int x
+let b = Int64.to_int y
+let c = Nativeint.to_int z
diff --git a/tests/LetIn.expected b/tests/LetIn.expected
new file mode 100644
index 0000000..5424c00
--- /dev/null
+++ b/tests/LetIn.expected
@@ -0,0 +1,3 @@
+LetIn_0 = [1] {
+ (no name) = 2
+}
diff --git a/tests/LetIn.ml b/tests/LetIn.ml
new file mode 100644
index 0000000..6b5c3f2
--- /dev/null
+++ b/tests/LetIn.ml
@@ -0,0 +1,4 @@
+let x =
+ let y = 1 in
+
+ 2 * y
diff --git a/tests/Standard.expected b/tests/Standard.expected
new file mode 100644
index 0000000..63c8893
--- /dev/null
+++ b/tests/Standard.expected
@@ -0,0 +1,6 @@
+Hello world!
+3
+The length of [1; 2; 3] is 3
+Standard_0 = [1] {
+ (no name) = <abstr:247>
+}
diff --git a/tests/Standard.ml b/tests/Standard.ml
new file mode 100644
index 0000000..e13b98c
--- /dev/null
+++ b/tests/Standard.ml
@@ -0,0 +1,5 @@
+let ( $ ) f x = f x
+
+let () = print_endline "Hello world!"
+let () = print_int $ List.length [1; 2; 3] |> print_newline
+let () = Printf.printf "The length of [1; 2; 3] is %d\n" $ List.length [1; 2; 3]
diff --git a/tests/TrivialMatch.expected b/tests/TrivialMatch.expected
new file mode 100644
index 0000000..19d249c
--- /dev/null
+++ b/tests/TrivialMatch.expected
@@ -0,0 +1,3 @@
+TrivialMatch_0 = [1] {
+ (no name) = correct
+}
diff --git a/tests/TrivialMatch.ml b/tests/TrivialMatch.ml
new file mode 100644
index 0000000..971eafb
--- /dev/null
+++ b/tests/TrivialMatch.ml
@@ -0,0 +1,4 @@
+let x =
+ match 1 < 0 with
+ | true -> "something is terribly wrong here"
+ | false -> "correct"
diff --git a/tests/TrivialValue.expected b/tests/TrivialValue.expected
new file mode 100644
index 0000000..29a20b3
--- /dev/null
+++ b/tests/TrivialValue.expected
@@ -0,0 +1,4 @@
+TrivialValue_0 = [2] {
+ (no name) = 1
+ (no name) = 2
+}
diff --git a/tests/TrivialValue.ml b/tests/TrivialValue.ml
new file mode 100644
index 0000000..6f76e0e
--- /dev/null
+++ b/tests/TrivialValue.ml
@@ -0,0 +1,2 @@
+let x = 1
+let y = x + 1