summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGabriel Kerneis2014-01-08 17:32:29 +0100
committerGabriel Kerneis2014-01-08 17:32:29 +0100
commitfa31291af1f89bfd4f11e7df8b08425377765c48 (patch)
tree2556426253fb87799096916b412e73891f3da72a /src/test
parent2eb3e063615a24cd93fb4b301b25c8a402520bf3 (diff)
More tests for various vector patterns bugs
Diffstat (limited to 'src/test')
-rw-r--r--src/test/vectors.sail33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/test/vectors.sail b/src/test/vectors.sail
index 54defa08..f51b5d93 100644
--- a/src/test/vectors.sail
+++ b/src/test/vectors.sail
@@ -1,10 +1,41 @@
let (bit[32]) v = 0b101
register (bit[32]) i
+register nat match_success
+
+function unit decode ([bitzero, bitzero, bitone, bitzero]) = match_success := 1
+and decode x = match_success := x
+
function unit main _ = {
i := [bitzero, bitzero, bitone, bitzero];
- i := 0b101 ;
+
+ (* literal match *)
+ switch v {
+ case 0b101 -> match_success := 1
+ case _ -> match_success := v
+ };
+
+ switch i {
+ case [bitzero, bitzero, bitone, bitzero] -> match_success := 1
+ case _ -> match_success := i
+ };
+
+ (* XXX function clause match fail *)
+ (* parameter is wrapped in a 1-tuple upon call, but probably not
+ unwrapped for the pattern-matching *)
+ decode(i);
+
+ (* concatenation *)
+ switch i {
+ (* XXX match fails *)
+ case ([bitzero] : [bitzero, bitone] : [bitzero]) -> match_success := 1
+ (* but this works *)
+ case ([bitzero] : [bitzero] : [bitone] : [bitzero]) -> match_success := 2
+ case _ -> match_success := i
+ };
+
+ (* XXX slice access not implemented *)
i[0] := bitzero;
(* XXX Vector access of non-vector *)
v[0];