summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/c/int_struct.expect1
-rw-r--r--test/c/int_struct.sail24
-rw-r--r--test/c/int_struct_constrained.expect1
-rw-r--r--test/c/int_struct_constrained.sail24
4 files changed, 50 insertions, 0 deletions
diff --git a/test/c/int_struct.expect b/test/c/int_struct.expect
new file mode 100644
index 00000000..f70f10e4
--- /dev/null
+++ b/test/c/int_struct.expect
@@ -0,0 +1 @@
+A
diff --git a/test/c/int_struct.sail b/test/c/int_struct.sail
new file mode 100644
index 00000000..42554593
--- /dev/null
+++ b/test/c/int_struct.sail
@@ -0,0 +1,24 @@
+default Order dec
+
+$include <prelude.sail>
+
+val print = "print_endline" : string -> unit
+
+struct Foo('n: Int) = {
+ field: bits('n)
+}
+
+type Foo32 = Foo(32)
+
+function bar(foo: Foo32) -> unit = {
+ if foo.field == 0xFFFF_FFFF then {
+ print("A")
+ } else {
+ print("B")
+ }
+}
+
+function main((): unit) -> unit = {
+ let x: Foo32 = struct { field = 0xFFFF_FFFF };
+ bar(x)
+} \ No newline at end of file
diff --git a/test/c/int_struct_constrained.expect b/test/c/int_struct_constrained.expect
new file mode 100644
index 00000000..f70f10e4
--- /dev/null
+++ b/test/c/int_struct_constrained.expect
@@ -0,0 +1 @@
+A
diff --git a/test/c/int_struct_constrained.sail b/test/c/int_struct_constrained.sail
new file mode 100644
index 00000000..95cb6e9b
--- /dev/null
+++ b/test/c/int_struct_constrained.sail
@@ -0,0 +1,24 @@
+default Order dec
+
+$include <prelude.sail>
+
+val print = "print_endline" : string -> unit
+
+struct Foo('n: Int), 'n <= 64 = {
+ field: bits('n)
+}
+
+type Foo32 = Foo(32)
+
+function bar(foo: Foo32) -> unit = {
+ if foo.field == 0xFFFF_FFFF then {
+ print("A")
+ } else {
+ print("B")
+ }
+}
+
+function main((): unit) -> unit = {
+ let x: Foo32 = struct { field = 0xFFFF_FFFF };
+ bar(x)
+} \ No newline at end of file