summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/c/nonexistent_pragma.expect1
-rw-r--r--test/c/nonexistent_pragma.sail12
-rw-r--r--test/c/unroll.expect6
-rw-r--r--test/c/unroll.sail37
-rw-r--r--test/isabelle/Makefile12
-rw-r--r--test/typecheck/pass/nonexistent_pragma.sail12
6 files changed, 77 insertions, 3 deletions
diff --git a/test/c/nonexistent_pragma.expect b/test/c/nonexistent_pragma.expect
new file mode 100644
index 00000000..9daeafb9
--- /dev/null
+++ b/test/c/nonexistent_pragma.expect
@@ -0,0 +1 @@
+test
diff --git a/test/c/nonexistent_pragma.sail b/test/c/nonexistent_pragma.sail
new file mode 100644
index 00000000..da4b99f7
--- /dev/null
+++ b/test/c/nonexistent_pragma.sail
@@ -0,0 +1,12 @@
+default Order dec
+
+$include <prelude.sail>
+
+$not_a_valid_pragma test
+
+val "print_endline" : string -> unit
+
+function main((): unit) -> unit = {
+ print_endline("test")
+}
+
diff --git a/test/c/unroll.expect b/test/c/unroll.expect
new file mode 100644
index 00000000..355943c1
--- /dev/null
+++ b/test/c/unroll.expect
@@ -0,0 +1,6 @@
+fac(4) = 24
+fac(5) = 120
+fac(6) = 720
+fac2(4) = 24
+fac2(5) = 120
+fac2(6) = 720
diff --git a/test/c/unroll.sail b/test/c/unroll.sail
new file mode 100644
index 00000000..c68bb49d
--- /dev/null
+++ b/test/c/unroll.sail
@@ -0,0 +1,37 @@
+default Order dec
+
+$include <prelude.sail>
+
+/* It's hard to test that this optimization does the right thing, but
+we can at least test that it doesn't do the wrong thing. */
+
+$optimize unroll 20
+val fac : forall 'n, 'n >= 0. int('n) -> int
+function fac(n) = {
+ if n == 0 then {
+ 1
+ } else {
+ n * fac(n - 1)
+ }
+}
+
+$optimize unroll 2
+val fac2 : forall 'n, 'n >= 0. int('n) -> int
+function fac2(n) = {
+ if n == 0 then {
+ 1
+ } else {
+ n * fac2(n - 1)
+ }
+}
+
+val "print_int" : (string, int) -> unit
+
+function main((): unit) -> unit = {
+ print_int("fac(4) = ", fac(4));
+ print_int("fac(5) = ", fac(5));
+ print_int("fac(6) = ", fac(6));
+ print_int("fac2(4) = ", fac2(4));
+ print_int("fac2(5) = ", fac2(5));
+ print_int("fac2(6) = ", fac2(6))
+} \ No newline at end of file
diff --git a/test/isabelle/Makefile b/test/isabelle/Makefile
index 43028fed..1f488db1 100644
--- a/test/isabelle/Makefile
+++ b/test/isabelle/Makefile
@@ -1,7 +1,13 @@
-CHERI_DIR = ../../cheri
-AARCH64_DIR = ../../aarch64
+LEM_ISA_LIB?=$(shell opam config var lem:share)/isabelle-lib
+ifeq ($(wildcard $(LEM_ISA_LIB)/ROOT),)
+$(error isabelle-lib directory of Lem not found. Please set the LEM_ISA_LIB environment variable)
+endif
+
+SAIL_ISA_LIB = ../../lib/isabelle
+CHERI_DIR ?= ../../../sail-cheri-mips/cheri
+AARCH64_DIR ?= ../../aarch64
TGTS = run_cheri.native run_aarch64.native
-SESSION_DIRS = -d $(CHERI_DIR) -d $(AARCH64_DIR) -d .
+SESSION_DIRS = -d $(LEM_ISA_LIB) -d $(SAIL_ISA_LIB) -d $(CHERI_DIR) -d $(AARCH64_DIR) -d .
.PHONY: all clean
diff --git a/test/typecheck/pass/nonexistent_pragma.sail b/test/typecheck/pass/nonexistent_pragma.sail
new file mode 100644
index 00000000..da4b99f7
--- /dev/null
+++ b/test/typecheck/pass/nonexistent_pragma.sail
@@ -0,0 +1,12 @@
+default Order dec
+
+$include <prelude.sail>
+
+$not_a_valid_pragma test
+
+val "print_endline" : string -> unit
+
+function main((): unit) -> unit = {
+ print_endline("test")
+}
+