harec

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

commit 91f5e5fd6052a9d4cf090139ece04f627cda9d76
parent a4173d8607e63bbcbb658b2731f925e9426a1a9a
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Fri,  3 Sep 2021 22:13:03 +0000

tests: test embedded structs

Signed-off-by: Eyal Sawady <ecs@d2evs.net>

Diffstat:
Mtests/06-structs.ha | 33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git a/tests/06-structs.ha b/tests/06-structs.ha @@ -45,7 +45,40 @@ fn deref() void = { assert(coords.x == 42 && coords.y == 96); }; +type embedded = struct { + foo: u8, +}; + +type embed1 = struct { + embedded, + struct { + bar: u8, + baz: u64, + }, +}; + +type embed2 = struct { + struct { + bar: u8, + baz: u64, + }, + embedded, +}; + fn nested() void = { + let s = embed1 { + foo = 42, + bar = 69, + baz = 1337, + }; + assert(s.foo == 42 && s.bar == 69 && s.baz == 1337); + let s = embed2 { + foo = 42, + bar = 69, + baz = 1337, + }; + assert(s.foo == 42 && s.bar == 69 && s.baz == 1337); + let s = struct { x: int = 10, y: struct {