diff options
Diffstat (limited to 'test/mono')
| -rw-r--r-- | test/mono/.gitignore | 1 | ||||
| -rw-r--r-- | test/mono/test.ml | 2 | ||||
| -rwxr-xr-x | test/mono/test.sh | 37 | ||||
| -rw-r--r-- | test/mono/tests | 3 | ||||
| -rw-r--r-- | test/mono/varmatch.sail | 19 | ||||
| -rw-r--r-- | test/mono/vector.sail | 21 |
6 files changed, 72 insertions, 11 deletions
diff --git a/test/mono/.gitignore b/test/mono/.gitignore new file mode 100644 index 00000000..2dd3daa3 --- /dev/null +++ b/test/mono/.gitignore @@ -0,0 +1 @@ +test-out
\ No newline at end of file diff --git a/test/mono/test.ml b/test/mono/test.ml index cd6c6041..f99abfb8 100644 --- a/test/mono/test.ml +++ b/test/mono/test.ml @@ -1 +1 @@ -if Fnreduce_embed_sequential.run() then print_endline "OK" else print_endline "Failed";; +if Testout_embed_sequential.run() then print_endline "OK" else print_endline "Failed";; diff --git a/test/mono/test.sh b/test/mono/test.sh index 7b1eeb64..153b09f8 100755 --- a/test/mono/test.sh +++ b/test/mono/test.sh @@ -1,21 +1,38 @@ #!/bin/bash -set -ex +set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SAILDIR="$DIR/../.." LEMDIR="$DIR/../../../lem" -OUTDIR="$DIR/fnreduce-ml" +OUTDIR="$DIR/test-out" ZARITH="$LEMDIR/ocaml-lib/dependencies/zarith" -"$SAILDIR/sail" -lem "$SAILDIR/lib/prelude.sail" -mono-split fnreduce.sail:43:x "$DIR/fnreduce.sail" -o "$DIR/fnreduce" -if [ -d "$OUTDIR" ]; then - rm -- "$OUTDIR"/* -else +if [ ! -d "$OUTDIR" ]; then mkdir -- "$OUTDIR" fi -"$LEMDIR/bin/lem" -ocaml -lib "$SAILDIR/src/lem_interp" "$SAILDIR/src/gen_lib/sail_values.lem" "$SAILDIR/src/gen_lib/state.lem" "$DIR/fnreduce_embed_types.lem" "$DIR/fnreduce_embed_sequential.lem" -outdir "$OUTDIR" -cp -- "$DIR"/test.ml "$OUTDIR" cd "$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 state.ml fnreduce_embed_types.ml fnreduce_embed_sequential.ml test.ml -o test -./test + +TESTONLY="$1" +if [ -n "$TESTONLY" ]; then shift; fi + +exec 3< "$DIR/tests" +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 +# 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 +# ./test + + echo "$TEST lem - ocaml" + rm -f -- "$OUTDIR"/* + "$SAILDIR/sail" -lem "$SAILDIR/lib/prelude.sail" "$DIR/$TEST".sail -o "$OUTDIR/testout" $ARGS $@ + "$LEMDIR/bin/lem" -ocaml -lib "$SAILDIR/src/lem_interp" "$SAILDIR/src/gen_lib/sail_values.lem" "$SAILDIR/src/gen_lib/state.lem" testout_embed_types.lem testout_embed_sequential.lem -outdir "$OUTDIR" + 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 state.ml testout_embed_types.ml testout_embed_sequential.ml test.ml -o test + ./test + fi +done diff --git a/test/mono/tests b/test/mono/tests new file mode 100644 index 00000000..425230da --- /dev/null +++ b/test/mono/tests @@ -0,0 +1,3 @@ +fnreduce -mono-split fnreduce.sail:43:x +varmatch -mono-split varmatch.sail:7:x +vector -mono-split vector.sail:7:sel diff --git a/test/mono/varmatch.sail b/test/mono/varmatch.sail new file mode 100644 index 00000000..7d2b9b73 --- /dev/null +++ b/test/mono/varmatch.sail @@ -0,0 +1,19 @@ +(* Check that when we case split on a variable that the constant propagation + handles the default case correctly. *) + +typedef AnEnum = enumerate { One; Two; Three } + +function AnEnum foo((AnEnum) x) = { + switch (x) { + case One -> Two + case y -> y + } +} + +val unit -> bool effect pure run + +function run () = { + foo(One) == Two & + foo(Two) == Two & + foo(Three) == Three +} diff --git a/test/mono/vector.sail b/test/mono/vector.sail new file mode 100644 index 00000000..03f36da5 --- /dev/null +++ b/test/mono/vector.sail @@ -0,0 +1,21 @@ +(* Check case splitting on a vector *) + +default Order dec + +val bit[32] -> nat effect pure test + +function nat test((bit[2]) sel : (bit[30]) _) = { + switch (sel) { + case 0b00 -> 5 + case 0b10 -> 1 + case _ -> 0 + } +} + +val unit -> bool effect pure run + +function run () = { + test(0x0f353533) == 5 & + test(0x84534656) == 1 & + test(0xf3463903) == 0 +} |
