diff options
| author | Alasdair | 2020-05-21 17:02:15 +0100 |
|---|---|---|
| committer | Alasdair | 2020-05-21 17:02:15 +0100 |
| commit | 2f3dae605081e8d0f7005d127c0462ee71d1424f (patch) | |
| tree | 4ce66b11bd012984d20a6f7a74aff04d381ada1e /test/typecheck | |
| parent | fc6412708024d7c614e3c47a2de3be0548d184c7 (diff) | |
| parent | 07ceceff23cf4aac2c6fe8de764cb404e21c7828 (diff) | |
Merge branch 'mono-tweaks' into sail2
Diffstat (limited to 'test/typecheck')
| -rw-r--r-- | test/typecheck/pass/floor_pow2.sail | 17 | ||||
| -rw-r--r-- | test/typecheck/pass/reg_32_64/v2.expect | 10 | ||||
| -rw-r--r-- | test/typecheck/pass/repeat_constraint.sail | 9 | ||||
| -rw-r--r-- | test/typecheck/pass/repeat_constraint/v1.expect | 6 | ||||
| -rw-r--r-- | test/typecheck/pass/repeat_constraint/v1.sail | 9 |
5 files changed, 45 insertions, 6 deletions
diff --git a/test/typecheck/pass/floor_pow2.sail b/test/typecheck/pass/floor_pow2.sail new file mode 100644 index 00000000..fa8680cf --- /dev/null +++ b/test/typecheck/pass/floor_pow2.sail @@ -0,0 +1,17 @@ +$include <arith.sail> + +val "pow2" : forall 'n, 'n >= 0. int('n) -> int(2 ^ 'n) + +val floor_pow2 : forall ('x : Int), 'x >= 0. int('x) -> int + +function floor_pow2 x = { + if x == 0 then { + return(0); + } else { + n : {'n, 'n >= 1. int('n)} = 1; + while x >= pow2(n) do { + n = n + 1 + }; + return(pow2(n - 1)) + } +} diff --git a/test/typecheck/pass/reg_32_64/v2.expect b/test/typecheck/pass/reg_32_64/v2.expect index 90166904..8854282d 100644 --- a/test/typecheck/pass/reg_32_64/v2.expect +++ b/test/typecheck/pass/reg_32_64/v2.expect @@ -1,13 +1,11 @@ Type error: -[[96mreg_32_64/v2.sail[0m]:21:18-22 +[[96mreg_32_64/v2.sail[0m]:21:2-15 21[96m |[0m (*R)['d .. 0] = data - [91m |[0m [91m^--^[0m - [91m |[0m Tried performing type coercion from bitvector('d, dec) to bitvector((('d - 0) + 1), dec) on data - [91m |[0m Coercion failed because: - [91m |[0m Mismatched argument types in subtype check + [91m |[0m [91m^-----------^[0m + [91m |[0m Bounds check failed for l-expression: ((0 <= 0 & 0 <= 'd) & 'd < 64) [91m |[0m This error was caused by: [91m |[0m [[96mreg_32_64/v2.sail[0m]:21:2-15 [91m |[0m 21[96m |[0m (*R)['d .. 0] = data [91m |[0m [91m |[0m [91m^-----------^[0m - [91m |[0m [91m |[0m Mismatched argument types in subtype check + [91m |[0m [91m |[0m Bounds check failed for l-expression: ((0 <= 0 & 0 <= 'd) & 'd < 64) [91m |[0m diff --git a/test/typecheck/pass/repeat_constraint.sail b/test/typecheck/pass/repeat_constraint.sail new file mode 100644 index 00000000..6d63f2e8 --- /dev/null +++ b/test/typecheck/pass/repeat_constraint.sail @@ -0,0 +1,9 @@ +$include <flow.sail> + +val main : unit -> unit + +function main() = { + repeat { + _not_prove(constraint(false)); + } until (false); +} diff --git a/test/typecheck/pass/repeat_constraint/v1.expect b/test/typecheck/pass/repeat_constraint/v1.expect new file mode 100644 index 00000000..9d561e11 --- /dev/null +++ b/test/typecheck/pass/repeat_constraint/v1.expect @@ -0,0 +1,6 @@ +Type error: +[[96mrepeat_constraint/v1.sail[0m]:7:4-29 +7[96m |[0m _prove(constraint(false)); + [91m |[0m [91m^-----------------------^[0m + [91m |[0m Cannot prove false + [91m |[0m diff --git a/test/typecheck/pass/repeat_constraint/v1.sail b/test/typecheck/pass/repeat_constraint/v1.sail new file mode 100644 index 00000000..5dd2f513 --- /dev/null +++ b/test/typecheck/pass/repeat_constraint/v1.sail @@ -0,0 +1,9 @@ +$include <flow.sail> + +val main : unit -> unit + +function main() = { + repeat { + _prove(constraint(false)); + } until (false); +} |
