diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-10-17 10:19:14 +0100 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2024-10-18 08:50:40 +0100 |
| commit | 097766bba3d7f45df41a4233f849db99e1bb8676 (patch) | |
| tree | 71f8f296c31380be83d99639dbfd4ca71d61bb2b /test/behavior/struct.zig | |
| parent | fffbb511db5de611ca670fc13a223ddbe255c92c (diff) | |
| download | zig-097766bba3d7f45df41a4233f849db99e1bb8676.tar.gz zig-097766bba3d7f45df41a4233f849db99e1bb8676.zip | |
compiler: implement `@FieldType`
Resolves: #21702
Diffstat (limited to 'test/behavior/struct.zig')
| -rw-r--r-- | test/behavior/struct.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index 989da34ae7..cc373cd8b1 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -2159,3 +2159,27 @@ test "matching captures causes struct equivalence" { comptime assert(@TypeOf(a) == @TypeOf(b)); try expect(a.x == b.x); } + +test "struct @FieldType" { + const S = struct { + a: u32, + b: f64, + c: *@This(), + }; + + comptime assert(@FieldType(S, "a") == u32); + comptime assert(@FieldType(S, "b") == f64); + comptime assert(@FieldType(S, "c") == *S); +} + +test "extern struct @FieldType" { + const S = extern struct { + a: u32, + b: f64, + c: *@This(), + }; + + comptime assert(@FieldType(S, "a") == u32); + comptime assert(@FieldType(S, "b") == f64); + comptime assert(@FieldType(S, "c") == *S); +} |
