diff options
Diffstat (limited to 'test/behavior/struct.zig')
| -rw-r--r-- | test/behavior/struct.zig | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index ed3e1ce88f..348e269682 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -1330,7 +1330,6 @@ test "struct field init value is size of the struct" { } test "under-aligned struct field" { - if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO @@ -1578,3 +1577,38 @@ test "directly initiating tuple like struct" { const a = struct { u8 }{8}; try expect(a[0] == 8); } + +test "instantiate struct with comptime field" { + { + var things = struct { + comptime foo: i8 = 1, + }{}; + + comptime std.debug.assert(things.foo == 1); + } + + { + const T = struct { + comptime foo: i8 = 1, + }; + var things = T{}; + + comptime std.debug.assert(things.foo == 1); + } + + { + var things: struct { + comptime foo: i8 = 1, + } = .{}; + + comptime std.debug.assert(things.foo == 1); + } + + { + var things: struct { + comptime foo: i8 = 1, + } = undefined; // Segmentation fault at address 0x0 + + comptime std.debug.assert(things.foo == 1); + } +} |
