summaryrefslogtreecommitdiff
path: root/test/c
diff options
context:
space:
mode:
Diffstat (limited to 'test/c')
-rw-r--r--test/c/custom_flow.expect5
-rw-r--r--test/c/custom_flow.sail43
2 files changed, 48 insertions, 0 deletions
diff --git a/test/c/custom_flow.expect b/test/c/custom_flow.expect
new file mode 100644
index 00000000..cf275436
--- /dev/null
+++ b/test/c/custom_flow.expect
@@ -0,0 +1,5 @@
+1
+2
+3
+4
+4
diff --git a/test/c/custom_flow.sail b/test/c/custom_flow.sail
new file mode 100644
index 00000000..43c980d6
--- /dev/null
+++ b/test/c/custom_flow.sail
@@ -0,0 +1,43 @@
+val "print_endline" : string -> unit
+
+val operator <= = {
+ coq: "Z.leb",
+ _: "lteq"
+} : forall 'n 'm. (int('n), int('m)) -> bool('n <= 'm)
+
+function test1 forall 'n 'm. (n: int('n), m: int('m)) -> unit = {
+ if n <= m then {
+ _prove(constraint('n <= 'm));
+ print_endline("1");
+ } else {
+ print_endline("2");
+ _prove(constraint('n > 'm));
+ }
+}
+
+val and_bool = {
+ coq: "andb",
+ _: "and_bool"
+} : forall ('p: Bool) ('q: Bool). (bool('p), bool('q)) -> bool('p & 'q)
+
+overload operator & = {and_bool}
+
+function test2 forall 'n 'm. (n: int('n), m: int('m)) -> unit = {
+ let x = n <= m & n <= 20;
+ if x then {
+ _prove(constraint('n <= 20));
+ _prove(constraint('n <= 'm));
+ print_endline("3")
+ } else {
+ _prove(constraint('n > 'm | 'n > 20));
+ print_endline("4")
+ }
+}
+
+function main((): unit) -> unit = {
+ test1(1, 2);
+ test1(2, 1);
+ test2(1, 2);
+ test2(2, 1);
+ test2(21, 0)
+} \ No newline at end of file