harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c99e4b84cbd216ef61842f9c2dc07e698461be12
parent ddce9e82212b3ba80e1de93c667d5d2604470488
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Tue, 20 Apr 2021 18:36:29 -0400

Add gen test

Containing minimal reproductions of various bugs I found in WIP versions
of the improved gen_copy. This should help with debugging when we
revisit gen_copy.

Diffstat:
Atests/26-gen.ha | 45+++++++++++++++++++++++++++++++++++++++++++++
Mtests/configure | 3++-
2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/tests/26-gen.ha b/tests/26-gen.ha @@ -0,0 +1,45 @@ +// Tests for various gen bugs + +type embedded = struct { + a: u64, + b: u8, +}; + +type thing = struct { + offs: u64, + e: embedded, +}; + +export fn main() void = { + let t = thing { + offs = 0, + e = embedded { + a = 1, + b = 0, + }, + }; + let t = t; + assert(t.e.a == 1); + + let x: (void | int) = 10; + match (x) { + i: int => assert(i == 10), + _: void => abort(), + }; + + let p = 0; + let p = &p: uintptr: u64: (u64 | void); + let p = match (p) { + _: void => abort(), + p: u64 => p: uintptr: *int, + }; + assert(*p == 0); + + let thing: int = 0; + let thing = &thing: (*int | int); + let p = match (thing) { + _: int => abort(), + p: *int => p, + }; + *p = 0; +}; diff --git a/tests/configure b/tests/configure @@ -28,7 +28,8 @@ tests() { 22-delete \ 23-errors \ 24-imports \ - 25-promotion + 25-promotion \ + 26-gen do cat <<EOF tests/$t: libhart.a tests/$t.ha