summaryrefslogtreecommitdiff
path: root/test/mono
diff options
context:
space:
mode:
Diffstat (limited to 'test/mono')
-rwxr-xr-xtest/mono/test.sh4
-rw-r--r--test/mono/tests1
-rw-r--r--test/mono/union-exist.sail33
3 files changed, 36 insertions, 2 deletions
diff --git a/test/mono/test.sh b/test/mono/test.sh
index b82406c3..2a5aa80b 100755
--- a/test/mono/test.sh
+++ b/test/mono/test.sh
@@ -26,7 +26,7 @@ while read -u 3 TEST ARGS; do
if [ -z "$TESTONLY" -o "$TEST" = "$TESTONLY" ]; then
# echo "$TEST ocaml"
# rm -f -- "$OUTDIR"/*
-# "$SAILDIR/sail" -ocaml "$SAILDIR/lib/prelude.sail" "$DIR/$TEST" -o "$OUTDIR/testout" $ARGS
+# "$SAILDIR/sail" -ocaml "$SAILDIR/lib/prelude.sail" "$SAILDIR/lib/prelude_wrappers.sail" "$DIR/$TEST" -o "$OUTDIR/testout" $ARGS
# cp -- "$SAILDIR"/src/gen_lib/sail_values.ml .
# cp -- "$DIR"/test.ml .
# ocamlc -I "$ZARITH" "$ZARITH/zarith.cma" -dllpath "$ZARITH" -I "$LEMDIR/ocaml-lib" "$LEMDIR/ocaml-lib/extract.cma" -I "$SAILDIR/src/_build/lem_interp" "$SAILDIR/src/_build/lem_interp/extract.cma" sail_values.ml testout.ml test.ml -o test
@@ -34,7 +34,7 @@ while read -u 3 TEST ARGS; do
echo "$TEST lem - ocaml" | tee -a -- "$LOG"
rm -f -- "$OUTDIR"/*
- "$SAILDIR/sail" -lem -lem_sequential -lem_mwords "$SAILDIR/lib/prelude.sail" "$DIR/$TEST".sail -o "$OUTDIR/testout" $ARGS $@ &>> "$LOG" && \
+ "$SAILDIR/sail" -lem -lem_sequential -lem_mwords "$SAILDIR/lib/prelude.sail" "$SAILDIR/lib/prelude_wrappers.sail" "$DIR/$TEST".sail -o "$OUTDIR/testout" $ARGS $@ &>> "$LOG" && \
"$LEMDIR/bin/lem" -ocaml -lib "$SAILDIR/src/lem_interp" "$SAILDIR/src/gen_lib/sail_values.lem" "$SAILDIR/src/gen_lib/sail_operators_mwords.lem" "$SAILDIR/src/gen_lib/state.lem" testout_embed_types_sequential.lem testout_embed_sequential.lem -outdir "$OUTDIR" &>> "$LOG" && \
cp -- "$DIR"/test.ml "$OUTDIR" && \
ocamlc -I "$ZARITH" "$ZARITH/zarith.cma" -dllpath "$ZARITH" -I "$LEMDIR/ocaml-lib" "$LEMDIR/ocaml-lib/extract.cma" -I "$SAILDIR/src/_build/lem_interp" "$SAILDIR/src/_build/lem_interp/extract.cma" sail_values.ml sail_operators_mwords.ml state.ml testout_embed_types_sequential.ml testout_embed_sequential.ml test.ml -o test &>> "$LOG" && \
diff --git a/test/mono/tests b/test/mono/tests
index 425230da..0825c686 100644
--- a/test/mono/tests
+++ b/test/mono/tests
@@ -1,3 +1,4 @@
fnreduce -mono-split fnreduce.sail:43:x
varmatch -mono-split varmatch.sail:7:x
vector -mono-split vector.sail:7:sel
+union-exist -mono-split union-exist.sail:9:v
diff --git a/test/mono/union-exist.sail b/test/mono/union-exist.sail
new file mode 100644
index 00000000..74ab429a
--- /dev/null
+++ b/test/mono/union-exist.sail
@@ -0,0 +1,33 @@
+default Order dec
+
+typedef myunion = const union {
+ (exist 'n, 'n in {8,16}. ([:'n:],bit['n])) MyConstr;
+}
+
+val bit[2] -> myunion effect pure make
+
+function make(v) =
+ (* Can't mention these below without running into exp/nexp parsing conflict! *)
+ let eight = 8 in let sixteen = 16 in
+ switch v {
+ case 0b00 -> MyConstr( ( eight, 0x12) )
+ case 0b01 -> MyConstr( (sixteen,0x1234) )
+ case 0b10 -> MyConstr( ( eight, 0x56) )
+ case 0b11 -> MyConstr( (sixteen,0x5678) )
+ }
+
+val myunion -> bit[32] effect pure use
+
+function use(MyConstr('n)) = {
+ switch n {
+ case (n,v) -> extz(v)
+ }
+}
+val unit -> bool effect pure run
+
+function run () = {
+ use(make(0b00)) == 0x00000012 &
+ use(make(0b01)) == 0x00001234 &
+ use(make(0b10)) == 0x00000056 &
+ use(make(0b11)) == 0x00005678
+}