summaryrefslogtreecommitdiff
path: root/test/c
diff options
context:
space:
mode:
Diffstat (limited to 'test/c')
-rw-r--r--test/c/poly_pair.expect1
-rw-r--r--test/c/poly_pair.sail20
-rw-r--r--test/c/poly_simple.expect1
-rw-r--r--test/c/poly_simple.sail15
-rw-r--r--test/c/poly_union.expect1
-rw-r--r--test/c/poly_union.sail27
-rw-r--r--test/c/poly_union_rev.expect1
-rw-r--r--test/c/poly_union_rev.sail27
8 files changed, 93 insertions, 0 deletions
diff --git a/test/c/poly_pair.expect b/test/c/poly_pair.expect
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/test/c/poly_pair.expect
@@ -0,0 +1 @@
+1
diff --git a/test/c/poly_pair.sail b/test/c/poly_pair.sail
new file mode 100644
index 00000000..6d0bdaad
--- /dev/null
+++ b/test/c/poly_pair.sail
@@ -0,0 +1,20 @@
+default Order dec
+
+val print = "print_endline" : string -> unit
+
+val "eq_int" : (int, int) -> bool
+
+union test ('a : Type) ('b : Type) = {
+ Ctor1 : ('a, 'b),
+ Ctor2 : int
+}
+
+val main : unit -> unit
+
+function main() = {
+ let x = Ctor1(3, 2);
+ match x {
+ Ctor1(y, z) if eq_int(y, 3) => print("1"),
+ _ => print("2")
+ };
+} \ No newline at end of file
diff --git a/test/c/poly_simple.expect b/test/c/poly_simple.expect
new file mode 100644
index 00000000..8ab686ea
--- /dev/null
+++ b/test/c/poly_simple.expect
@@ -0,0 +1 @@
+Hello, World!
diff --git a/test/c/poly_simple.sail b/test/c/poly_simple.sail
new file mode 100644
index 00000000..6630c638
--- /dev/null
+++ b/test/c/poly_simple.sail
@@ -0,0 +1,15 @@
+default Order dec
+
+val "print" : string -> unit
+
+union Poly ('a : Type) = {
+ Ctor : 'a
+}
+
+function main() : unit -> unit = {
+ let x = Ctor(3 : int);
+ let y = Ctor("Hello, World!\n");
+ match y {
+ Ctor(str) => print(str)
+ }
+} \ No newline at end of file
diff --git a/test/c/poly_union.expect b/test/c/poly_union.expect
new file mode 100644
index 00000000..f6b3d557
--- /dev/null
+++ b/test/c/poly_union.expect
@@ -0,0 +1 @@
+HCF
diff --git a/test/c/poly_union.sail b/test/c/poly_union.sail
new file mode 100644
index 00000000..02a80e17
--- /dev/null
+++ b/test/c/poly_union.sail
@@ -0,0 +1,27 @@
+default Order dec
+
+val print = "print_endline" : string -> unit
+
+union ast = {
+ HCF : unit
+}
+
+union option ('a : Type) = {
+ Some : 'a,
+ None : unit
+}
+
+val decode : unit -> option(ast)
+
+function decode() = Some(HCF())
+
+val main : unit -> unit
+
+function main() = {
+ let instr = decode();
+ match instr {
+ Some(HCF()) => print("HCF"),
+ Some(_) => print("Some(_)"),
+ None() => print("None")
+ }
+} \ No newline at end of file
diff --git a/test/c/poly_union_rev.expect b/test/c/poly_union_rev.expect
new file mode 100644
index 00000000..f6b3d557
--- /dev/null
+++ b/test/c/poly_union_rev.expect
@@ -0,0 +1 @@
+HCF
diff --git a/test/c/poly_union_rev.sail b/test/c/poly_union_rev.sail
new file mode 100644
index 00000000..bc654808
--- /dev/null
+++ b/test/c/poly_union_rev.sail
@@ -0,0 +1,27 @@
+default Order dec
+
+val print = "print_endline" : string -> unit
+
+union option ('a : Type) = {
+ Some : 'a,
+ None : unit
+}
+
+union ast = {
+ HCF : unit
+}
+
+val decode : unit -> option(ast)
+
+function decode() = Some(HCF())
+
+val main : unit -> unit
+
+function main() = {
+ let instr = decode();
+ match instr {
+ Some(HCF()) => print("HCF"),
+ Some(_) => print("Some(_)"),
+ None() => print("None")
+ }
+} \ No newline at end of file