~sircmpwn/harec unlisted

c99e4b84cbd216ef61842f9c2dc07e698461be12 — Eyal Sawady a month ago ddce9e8
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.
2 files changed, 47 insertions(+), 1 deletions(-)

A tests/26-gen.ha
M tests/configure
A tests/26-gen.ha => tests/26-gen.ha +45 -0
@@ 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;
};

M tests/configure => tests/configure +2 -1
@@ 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