summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/c/warl.expect1
-rw-r--r--test/c/warl.sail31
-rw-r--r--test/c/warl_undef.expect1
-rw-r--r--test/c/warl_undef.sail29
-rw-r--r--test/typecheck/fail/missing_tick.expect11
-rw-r--r--test/typecheck/fail/missing_tick.sail7
-rw-r--r--test/typecheck/fail/struct_incomplete_literal.expect8
-rw-r--r--test/typecheck/fail/struct_incomplete_literal.sail12
-rwxr-xr-xtest/typecheck/run_tests.sh6
9 files changed, 103 insertions, 3 deletions
diff --git a/test/c/warl.expect b/test/c/warl.expect
new file mode 100644
index 00000000..9766475a
--- /dev/null
+++ b/test/c/warl.expect
@@ -0,0 +1 @@
+ok
diff --git a/test/c/warl.sail b/test/c/warl.sail
new file mode 100644
index 00000000..cc5337b5
--- /dev/null
+++ b/test/c/warl.sail
@@ -0,0 +1,31 @@
+default Order dec
+
+$include <prelude.sail>
+
+val "eq_anything" : forall ('a: Type). ('a, 'a) -> bool
+
+overload operator == = {eq_anything}
+
+function neq_anything forall ('a: Type). (x: 'a, y: 'a) -> bool =
+ not_bool(x == y)
+
+overload operator != = {neq_anything}
+
+val "print_endline" : string -> unit
+
+struct WARL_range = {
+ rangelist : list(int),
+}
+
+let x : WARL_range = struct {
+ rangelist = [|0, 1|]
+}
+
+function main () : unit -> unit = {
+ let y = x;
+ assert(x == y);
+ assert(x == x);
+ let z = y;
+ assert(z.rangelist != [||]);
+ print_endline("ok")
+}
diff --git a/test/c/warl_undef.expect b/test/c/warl_undef.expect
new file mode 100644
index 00000000..9766475a
--- /dev/null
+++ b/test/c/warl_undef.expect
@@ -0,0 +1 @@
+ok
diff --git a/test/c/warl_undef.sail b/test/c/warl_undef.sail
new file mode 100644
index 00000000..4828afc8
--- /dev/null
+++ b/test/c/warl_undef.sail
@@ -0,0 +1,29 @@
+default Order dec
+
+$option -undefined_gen
+
+$include <prelude.sail>
+
+val "eq_anything" : forall ('a: Type). ('a, 'a) -> bool
+
+overload operator == = {eq_anything}
+
+function neq_anything forall ('a: Type). (x: 'a, y: 'a) -> bool =
+ not_bool(x == y)
+
+overload operator != = {neq_anything}
+
+val "print_endline" : string -> unit
+
+struct WARL_range = {
+ rangelist : list(int),
+}
+
+let x : WARL_range = struct {
+ rangelist = [|0, 1|]
+}
+
+function main () : unit -> unit = {
+ let z: WARL_range = undefined;
+ print_endline("ok")
+}
diff --git a/test/typecheck/fail/missing_tick.expect b/test/typecheck/fail/missing_tick.expect
new file mode 100644
index 00000000..b447fdd2
--- /dev/null
+++ b/test/typecheck/fail/missing_tick.expect
@@ -0,0 +1,11 @@
+Type error:
+[missing_tick.sail]:5:16-17
+5 |type foo = bits(x)
+  | ^
+  | Undefined synonym x
+  | This error was caused by:
+  | [missing_tick.sail]:5:0-18
+  | 5 |type foo = bits(x)
+  |  |^----------------^
+  |  | Types are not well-formed within this type definition. Note that recursive types are forbidden.
+  |
diff --git a/test/typecheck/fail/missing_tick.sail b/test/typecheck/fail/missing_tick.sail
new file mode 100644
index 00000000..67a468b1
--- /dev/null
+++ b/test/typecheck/fail/missing_tick.sail
@@ -0,0 +1,7 @@
+default Order dec
+$include <vector_dec.sail>
+
+let 'x = 0
+type foo = bits(x)
+
+function y() : unit -> foo = sail_zeros(0)
diff --git a/test/typecheck/fail/struct_incomplete_literal.expect b/test/typecheck/fail/struct_incomplete_literal.expect
new file mode 100644
index 00000000..2178d1a1
--- /dev/null
+++ b/test/typecheck/fail/struct_incomplete_literal.expect
@@ -0,0 +1,8 @@
+Type error:
+[struct_incomplete_literal.sail]:10:20-12:1
+10 |let foo_val : foo = struct {
+  | ^-------
+12 |}
+  |^
+  | struct literal missing fields: b
+  |
diff --git a/test/typecheck/fail/struct_incomplete_literal.sail b/test/typecheck/fail/struct_incomplete_literal.sail
new file mode 100644
index 00000000..f5c07c2e
--- /dev/null
+++ b/test/typecheck/fail/struct_incomplete_literal.sail
@@ -0,0 +1,12 @@
+default Order dec
+
+$include <prelude.sail>
+
+struct foo = {
+ a : int,
+ b : int
+}
+
+let foo_val : foo = struct {
+ a = 1
+}
diff --git a/test/typecheck/run_tests.sh b/test/typecheck/run_tests.sh
index adc30c42..e0720baf 100755
--- a/test/typecheck/run_tests.sh
+++ b/test/typecheck/run_tests.sh
@@ -92,13 +92,13 @@ do
pushd $DIR/fail > /dev/null;
if $SAILDIR/sail -no_memo_z3 $(basename $file) 2> result
then
- red "Expected failure, but $i $(basename $file) passed" "fail"
+ red "Expected failure, but $(basename $file) passed" "fail"
else
if diff ${file%.sail}.expect result;
then
- green "failing $i $(basename $file)" "pass"
+ green "failing $(basename $file)" "pass"
else
- yellow "failing $i $(basename $file)" "unexpected error"
+ yellow "failing $(basename $file)" "unexpected error"
fi
fi;
rm -f result;