From 7813a12ed59274989ce954c931bf02ebea2a0104 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Sat, 24 Jan 2026 23:53:08 +0000 Subject: Fix for #115 --- tests/features/test_unions.zc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/features/test_unions.zc (limited to 'tests') diff --git a/tests/features/test_unions.zc b/tests/features/test_unions.zc new file mode 100644 index 0000000..ee9848b --- /dev/null +++ b/tests/features/test_unions.zc @@ -0,0 +1,24 @@ + +struct Circle { + radius: f32; +} + +struct Rect { + width: f32; + height: f32; +} + +union Shape { + circle: Circle; + rect: Rect; +} + +test "union_init" { + var c = Circle{ radius: 10.0 }; + var s = Shape{ circle: c }; + assert(s.circle.radius == 10.0, "s.circle.radius != 10.0"); + + var s2 = Shape{}; + s2.rect = Rect{ width: 5.0, height: 5.0 }; + assert(s2.rect.width == 5.0, "s2.rect.width != 5.0"); +} -- cgit v1.2.3