zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 379beceffd1b0a0b0d8f3163dc02eba1e53ffa39 (tree)
parent d41dd499a9fd42be3a30018dccb6a9a9fbf43f3d
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 20 Jul 2022 15:21:24 -0700

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.

Diffstat:
Mtest/behavior/packed-struct.zig | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/test/behavior/packed-struct.zig b/test/behavior/packed-struct.zig @@ -421,16 +421,17 @@ test "load pointer from packed struct" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; - const Symbol = struct { + const A = struct { index: u16, }; - const Relocation = packed struct { - symbol: *Symbol, - a: u32, + const B = packed struct { + x: *A, + y: u32, }; - var a: []Relocation = &.{}; - for (a) |rela| { - var b = rela.symbol.index; - _ = b; + var a: A = .{ .index = 123 }; + var b_list: []B = &.{.{ .x = &a, .y = 99 }}; + for (b_list) |b| { + var i = b.x.index; + try expect(i == 123); } }