diff options
| author | Alasdair Armstrong | 2018-07-24 18:09:18 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-07-24 18:09:18 +0100 |
| commit | 6b4f407ad34ca7d4d8a89a5a4d401ac80c7413b0 (patch) | |
| tree | ed09b22b7ea4ca20fbcc89b761f1955caea85041 /test/c/eq_struct.sail | |
| parent | dafb09e7c26840dce3d522fef3cf359729ca5b61 (diff) | |
| parent | 8114501b7b956ee4a98fa8599c7efee62fc19206 (diff) | |
Merge remote-tracking branch 'origin/sail2' into c_fixes
Diffstat (limited to 'test/c/eq_struct.sail')
| -rw-r--r-- | test/c/eq_struct.sail | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/c/eq_struct.sail b/test/c/eq_struct.sail new file mode 100644 index 00000000..b4258569 --- /dev/null +++ b/test/c/eq_struct.sail @@ -0,0 +1,38 @@ +default Order dec + +$include <flow.sail> +$include <exception_basic.sail> + +val eq = "eq_anything" : forall ('a : Type). ('a, 'a) -> bool + +overload operator == = {eq} + +val neq : forall ('a : Type). ('a, 'a) -> bool + +overload operator != = {neq} + +overload ~ = {not_bool} + +function neq(x, y) = ~(eq(x, y)) + +struct S = { + field1: int, + field2: vector(8, dec, bit) +} + +val "print" : string -> unit + +val main : unit -> unit effect {escape} + +function main() = { + let s : S = struct { + field1 = 4, + field2 = 0xFF + }; + assert(s == s, "1"); + assert(~(s == { s with field2 = 0xAB }), "2"); + assert(s != { s with field1 = 5}, "3"); + assert(s == { s with field2 = 0xFF }); + assert({ s with field1 = 0} == {s with field1 = 0}); + print("ok\n") +}
\ No newline at end of file |
