authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-20 15:21:24-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-20 15:21:24-07:00
log379beceffd1b0a0b0d8f3163dc02eba1e53ffa39
treea29344d24999157b40a3644d25e941d482663913
parentd41dd499a9fd42be3a30018dccb6a9a9fbf43f3d

improve test case from previous commit

Now it checks that the code is correctly compiled rather than only checking that it does not crash the compiler.

1 files changed, 9 insertions(+), 8 deletions(-)

test/behavior/packed-struct.zig+9-8
...@@ -421,16 +421,17 @@ test "load pointer from packed struct" {...@@ -421,16 +421,17 @@ test "load pointer from packed struct" {
421 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;421 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
422 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;422 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
423423
424 const Symbol = struct {424 const A = struct {
425 index: u16,425 index: u16,
426 };426 };
427 const Relocation = packed struct {427 const B = packed struct {
428 symbol: *Symbol,428 x: *A,
429 a: u32,429 y: u32,
430 };430 };
431 var a: []Relocation = &.{};431 var a: A = .{ .index = 123 };
432 for (a) |rela| {432 var b_list: []B = &.{.{ .x = &a, .y = 99 }};
433 var b = rela.symbol.index;433 for (b_list) |b| {
434 _ = b;434 var i = b.x.index;
435 try expect(i == 123);
435 }436 }
436}437}