diff options
Diffstat (limited to 'test/c')
| -rw-r--r-- | test/c/anf_as_pattern.expect | 1 | ||||
| -rw-r--r-- | test/c/anf_as_pattern.sail | 19 | ||||
| -rw-r--r-- | test/c/anon_rec.expect | 1 | ||||
| -rw-r--r-- | test/c/anon_rec.sail | 12 | ||||
| -rw-r--r-- | test/c/execute.isail | 1 | ||||
| -rw-r--r-- | test/c/flow_restrict.expect | 1 | ||||
| -rw-r--r-- | test/c/flow_restrict.sail | 23 | ||||
| -rw-r--r-- | test/c/poly_int_record.expect | 3 | ||||
| -rw-r--r-- | test/c/poly_int_record.sail | 21 | ||||
| -rw-r--r-- | test/c/poly_record.expect | 1 | ||||
| -rw-r--r-- | test/c/poly_record.sail | 18 | ||||
| -rwxr-xr-x | test/c/run_tests.py | 2 | ||||
| -rw-r--r-- | test/c/tuple_union.expect | 42 | ||||
| -rw-r--r-- | test/c/tuple_union.sail | 48 | ||||
| -rw-r--r-- | test/c/unused_poly_ctor.expect | 1 | ||||
| -rw-r--r-- | test/c/unused_poly_ctor.sail | 18 |
16 files changed, 211 insertions, 1 deletions
diff --git a/test/c/anf_as_pattern.expect b/test/c/anf_as_pattern.expect new file mode 100644 index 00000000..9766475a --- /dev/null +++ b/test/c/anf_as_pattern.expect @@ -0,0 +1 @@ +ok diff --git a/test/c/anf_as_pattern.sail b/test/c/anf_as_pattern.sail new file mode 100644 index 00000000..9b9196b1 --- /dev/null +++ b/test/c/anf_as_pattern.sail @@ -0,0 +1,19 @@ +default Order dec + +$include <prelude.sail> + +val "print_endline" : string -> unit + +function test () : unit -> option(int) = { + match Some(3) { + Some(_) as x => x, + _ => None() + } +} + +function main() : unit -> unit = { + match test() { + Some(3) => print_endline("ok"), + _ => print_endline("fail") + } +}
\ No newline at end of file diff --git a/test/c/anon_rec.expect b/test/c/anon_rec.expect new file mode 100644 index 00000000..9766475a --- /dev/null +++ b/test/c/anon_rec.expect @@ -0,0 +1 @@ +ok diff --git a/test/c/anon_rec.sail b/test/c/anon_rec.sail new file mode 100644 index 00000000..17dd1e07 --- /dev/null +++ b/test/c/anon_rec.sail @@ -0,0 +1,12 @@ +default Order dec + +union Foo ('a : Type) = { + MkFoo : { field1 : 'a, field2 : int } +} + +val "print_endline" : string -> unit + +function main((): unit) -> unit = { + let _: Foo(unit) = MkFoo(struct { field1 = (), field2 = 22 }); + print_endline("ok") +} diff --git a/test/c/execute.isail b/test/c/execute.isail index f4b5ea0f..018dd92c 100644 --- a/test/c/execute.isail +++ b/test/c/execute.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run main() diff --git a/test/c/flow_restrict.expect b/test/c/flow_restrict.expect new file mode 100644 index 00000000..9766475a --- /dev/null +++ b/test/c/flow_restrict.expect @@ -0,0 +1 @@ +ok diff --git a/test/c/flow_restrict.sail b/test/c/flow_restrict.sail new file mode 100644 index 00000000..ef2ec412 --- /dev/null +++ b/test/c/flow_restrict.sail @@ -0,0 +1,23 @@ +default Order dec + +$include <flow.sail> +$include <exception_basic.sail> + +val "print_endline" : string -> unit + +register R : bool + +function main((): unit) -> unit = { + R = false; + let 'x = 3180327502475943573495720457203572045720485720458724; + y : range(0, 'x) = 1; + if R then { + assert(constraint('x <= 2)); + y = 2; + let z = y; + let x = 2; + () + } else { + print_endline("ok") + } +} diff --git a/test/c/poly_int_record.expect b/test/c/poly_int_record.expect new file mode 100644 index 00000000..a8a10253 --- /dev/null +++ b/test/c/poly_int_record.expect @@ -0,0 +1,3 @@ +x = 1 +y = 2 +ok diff --git a/test/c/poly_int_record.sail b/test/c/poly_int_record.sail new file mode 100644 index 00000000..ebb18713 --- /dev/null +++ b/test/c/poly_int_record.sail @@ -0,0 +1,21 @@ +default Order dec + +val "print_endline" : string -> unit +val "print_int" : (string, int) -> unit + +struct S('a: Type) = { + field1 : ('a, 'a), + field2 : unit +} + +function main((): unit) -> unit = { + var s : S(range(0, 3)) = struct { field1 = (0, 3), field2 = () }; + s.field1 = (1, 2); + match s.field1 { + (x, y) => { + print_int("x = ", x); + print_int("y = ", y); + } + }; + print_endline("ok"); +} diff --git a/test/c/poly_record.expect b/test/c/poly_record.expect new file mode 100644 index 00000000..9766475a --- /dev/null +++ b/test/c/poly_record.expect @@ -0,0 +1 @@ +ok diff --git a/test/c/poly_record.sail b/test/c/poly_record.sail new file mode 100644 index 00000000..afe1f144 --- /dev/null +++ b/test/c/poly_record.sail @@ -0,0 +1,18 @@ +default Order dec + +val "print_endline" : string -> unit + +struct S('a: Type) = { + field1 : 'a, + field2 : unit +} + +function f forall ('a :Type). (s: S('a)) -> unit = { + s.field2 +} + +function main((): unit) -> unit = { + let s : S(unit) = struct { field1 = (), field2 = () }; + f(s); + print_endline("ok"); +} diff --git a/test/c/run_tests.py b/test/c/run_tests.py index 2ee44fca..be953749 100755 --- a/test/c/run_tests.py +++ b/test/c/run_tests.py @@ -40,7 +40,7 @@ def test_interpreter(name): basename = os.path.splitext(os.path.basename(filename))[0] tests[filename] = os.fork() if tests[filename] == 0: - step('sail -is execute.isail -iout {}.iresult {}'.format(basename, filename)) + step('sail -undefined_gen -is execute.isail -iout {}.iresult {}'.format(basename, filename)) step('diff {}.iresult {}.expect'.format(basename, basename)) print '{} {}{}{}'.format(filename, color.PASS, 'ok', color.END) sys.exit() diff --git a/test/c/tuple_union.expect b/test/c/tuple_union.expect new file mode 100644 index 00000000..d8ea9f4f --- /dev/null +++ b/test/c/tuple_union.expect @@ -0,0 +1,42 @@ +y = 1 +z = 2 +y = 1 +z = 2 +y = 1 +z = 2 + +y = 3 +z = 4 +y = 3 +z = 4 +y = 3 +z = 4 + +y = 5 +z = 6 +y = 5 +z = 6 +y = 5 +z = 6 + +y = 7 +z = 8 +y = 7 +z = 8 +y = 7 +z = 8 + +y = 9 +z = 10 +y = 9 +z = 10 +y = 9 +z = 10 + +y = 11 +z = 12 +y = 11 +z = 12 +y = 11 +z = 12 + diff --git a/test/c/tuple_union.sail b/test/c/tuple_union.sail new file mode 100644 index 00000000..1914038f --- /dev/null +++ b/test/c/tuple_union.sail @@ -0,0 +1,48 @@ +default Order dec + +$include <prelude.sail> + +val "print_endline" : string -> unit + +union U('a: Type) = { + Ctor : 'a +} + +type pair = (int, int) + +function foo(x: U(pair)) -> unit = { + match x { + Ctor(y, z) => { + print_int("y = ", y); + print_int("z = ", z) + } + }; + match x { + Ctor((y, z)) => { + print_int("y = ", y); + print_int("z = ", z) + } + }; + match x { + Ctor(x) => match x { + (y, z) => { + print_int("y = ", y); + print_int("z = ", z) + } + } + }; + print_endline("") +} + +function main((): unit) -> unit = { + foo(Ctor(1, 2)); + foo(Ctor((3, 4))); + let x = (5, 6); + foo(Ctor(x)); + let x = Ctor(7, 8); + foo(x); + let x = Ctor(((9, 10))); + foo(x); + let x = (11, 12); + foo(Ctor(x)); +} diff --git a/test/c/unused_poly_ctor.expect b/test/c/unused_poly_ctor.expect new file mode 100644 index 00000000..e55551e8 --- /dev/null +++ b/test/c/unused_poly_ctor.expect @@ -0,0 +1 @@ +y = 0xFFFF diff --git a/test/c/unused_poly_ctor.sail b/test/c/unused_poly_ctor.sail new file mode 100644 index 00000000..c752cb33 --- /dev/null +++ b/test/c/unused_poly_ctor.sail @@ -0,0 +1,18 @@ +default Order dec + +$include <prelude.sail> + +val "print_endline" : string -> unit + +union U('a: Type) = { + Err : 'a, + Ok : bits(16) +} + +function main((): unit) -> unit = { + let x : U(unit) = Ok(0xFFFF); + match x { + Err() => print_endline("error"), + Ok(y) => print_bits("y = ", y) + } +} |
