diff options
| author | Jon French | 2019-02-25 12:10:30 +0000 |
|---|---|---|
| committer | Jon French | 2019-02-25 12:10:30 +0000 |
| commit | 915d75f9c49fa2c2a9d47d189e4224cee16582c9 (patch) | |
| tree | 77a93e682796977898af0b56e0a61d7689db112e /test/typecheck | |
| parent | a8a5308e4981b3d09fb2bf0c59d592ef6ae4417e (diff) | |
| parent | 38656b50ad24df6a29f3a84e50adfcf409131fb0 (diff) | |
Merge branch 'sail2' into rmem_interpreter
Diffstat (limited to 'test/typecheck')
| -rw-r--r-- | test/typecheck/pass/complex_exist_sat.sail | 7 | ||||
| -rw-r--r-- | test/typecheck/pass/complex_exist_sat/v1.expect | 8 | ||||
| -rw-r--r-- | test/typecheck/pass/complex_exist_sat/v1.sail | 3 | ||||
| -rw-r--r-- | test/typecheck/pass/complex_exist_sat/v2.expect | 8 | ||||
| -rw-r--r-- | test/typecheck/pass/complex_exist_sat/v2.sail | 3 | ||||
| -rw-r--r-- | test/typecheck/pass/int_synonym.sail | 18 | ||||
| -rw-r--r-- | test/typecheck/pass/pow_32_64.sail | 14 | ||||
| -rwxr-xr-x | test/typecheck/run_tests.sh | 6 |
8 files changed, 64 insertions, 3 deletions
diff --git a/test/typecheck/pass/complex_exist_sat.sail b/test/typecheck/pass/complex_exist_sat.sail new file mode 100644 index 00000000..65c3b6a9 --- /dev/null +++ b/test/typecheck/pass/complex_exist_sat.sail @@ -0,0 +1,7 @@ +val foo : int -> {'q, 'q in {0, 1}. atom(2 * 'q)} + +function foo(x) = 2 + +val bar : int -> {'q, 'q in {0, 1}. atom(2 * 'q)} + +function bar(x) = 0 diff --git a/test/typecheck/pass/complex_exist_sat/v1.expect b/test/typecheck/pass/complex_exist_sat/v1.expect new file mode 100644 index 00000000..b1937f47 --- /dev/null +++ b/test/typecheck/pass/complex_exist_sat/v1.expect @@ -0,0 +1,8 @@ +Type error: +[[96mcomplex_exist_sat/v1.sail[0m]:3:18-19 +3[96m |[0mfunction foo(x) = 3 + [91m |[0m [91m^[0m + [91m |[0m Tried performing type coercion from int(3) to {('q : Int), 'q in {0, 1}. int((2 * 'q))} on 3 + [91m |[0m Coercion failed because: + [91m |[0m Constraint 3 == (2 * 'ex1#) is not satisfiable + [91m |[0m diff --git a/test/typecheck/pass/complex_exist_sat/v1.sail b/test/typecheck/pass/complex_exist_sat/v1.sail new file mode 100644 index 00000000..f36f2dda --- /dev/null +++ b/test/typecheck/pass/complex_exist_sat/v1.sail @@ -0,0 +1,3 @@ +val foo : int -> {'q, 'q in {0, 1}. atom(2 * 'q)} + +function foo(x) = 3
\ No newline at end of file diff --git a/test/typecheck/pass/complex_exist_sat/v2.expect b/test/typecheck/pass/complex_exist_sat/v2.expect new file mode 100644 index 00000000..27af46d2 --- /dev/null +++ b/test/typecheck/pass/complex_exist_sat/v2.expect @@ -0,0 +1,8 @@ +Type error: +[[96mcomplex_exist_sat/v2.sail[0m]:3:18-19 +3[96m |[0mfunction foo(x) = 4 + [91m |[0m [91m^[0m + [91m |[0m Tried performing type coercion from int(4) to {('q : Int), 'q in {0, 1}. int((2 * 'q))} on 4 + [91m |[0m Coercion failed because: + [91m |[0m int(4) is not a subtype of {('q : Int), 'q in {0, 1}. int((2 * 'q))} + [91m |[0m diff --git a/test/typecheck/pass/complex_exist_sat/v2.sail b/test/typecheck/pass/complex_exist_sat/v2.sail new file mode 100644 index 00000000..e3e18e8c --- /dev/null +++ b/test/typecheck/pass/complex_exist_sat/v2.sail @@ -0,0 +1,3 @@ +val foo : int -> {'q, 'q in {0, 1}. atom(2 * 'q)} + +function foo(x) = 4
\ No newline at end of file diff --git a/test/typecheck/pass/int_synonym.sail b/test/typecheck/pass/int_synonym.sail new file mode 100644 index 00000000..33bdaf0c --- /dev/null +++ b/test/typecheck/pass/int_synonym.sail @@ -0,0 +1,18 @@ +/* from prelude */ +default Order dec + +$include <flow.sail> + +type bits ('n : Int) = vector('n, dec, bit) + +type xlen : Int = 64 +type xlen_bytes : Int = 8 +type xlenbits = bits(xlen) + +val "sign_extend" : forall 'n 'm, 'm >= 'n. (bits('n), atom('m)) -> bits('m) +val EXTS : forall 'n 'm, 'm >= 'n. (implicit('m), bits('n)) -> bits('m) +function EXTS(m, v) = sign_extend(v, m) + +val extend : forall 'n, 'n <= xlen_bytes. (bool, bits(8 * 'n)) -> xlenbits + +function extend(flag, value) = EXTS(value) diff --git a/test/typecheck/pass/pow_32_64.sail b/test/typecheck/pass/pow_32_64.sail new file mode 100644 index 00000000..bb4f207a --- /dev/null +++ b/test/typecheck/pass/pow_32_64.sail @@ -0,0 +1,14 @@ +default Order dec + +$include <prelude.sail> + +$option -smt_linearize + +val bar : forall 'n, 'n <= 2 ^ 64 - 1. int('n) -> unit + +val foo : forall 'n, 'n in {32, 64}. bits('n) -> unit + +function foo(xs) = { + let x = unsigned(xs); + bar(x) +} diff --git a/test/typecheck/run_tests.sh b/test/typecheck/run_tests.sh index ad2592df..e5650646 100755 --- a/test/typecheck/run_tests.sh +++ b/test/typecheck/run_tests.sh @@ -50,9 +50,9 @@ printf "<testsuites>\n" >> $DIR/tests.xml for i in `ls $DIR/pass/ | grep sail`; do - if $SAILDIR/sail -just_check -ddump_tc_ast -dsanity $DIR/pass/$i 2> /dev/null 1> $DIR/rtpass/$i; + if $SAILDIR/sail -no_memo_z3 -just_check -ddump_tc_ast -dsanity $DIR/pass/$i 2> /dev/null 1> $DIR/rtpass/$i; then - if $SAILDIR/sail -just_check -ddump_tc_ast -dmagic_hash -dno_cast -dsanity $DIR/rtpass/$i 2> /dev/null 1> $DIR/rtpass2/$i; + if $SAILDIR/sail -no_memo_z3 -just_check -ddump_tc_ast -dmagic_hash -dno_cast -dsanity $DIR/rtpass/$i 2> /dev/null 1> $DIR/rtpass2/$i; then if diff $DIR/rtpass/$i $DIR/rtpass2/$i; then @@ -71,7 +71,7 @@ do for file in $DIR/pass/${i%.sail}/*.sail; do pushd $DIR/pass > /dev/null; - if $SAILDIR/sail ${i%.sail}/$(basename $file) 2> result; + if $SAILDIR/sail -no_memo_z3 ${i%.sail}/$(basename $file) 2> result; then red "failing variant of $i $(basename $file) passed" "fail" else |
