diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-06-24 16:58:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-24 16:58:19 -0700 |
| commit | 146b79af153bbd5dafda0ba12a040385c7fc58f8 (patch) | |
| tree | 67e3db8b444d65c667e314770fc983a7fc8ba293 /test/behavior/packed-struct.zig | |
| parent | 13853bef0df3c90633021850cc6d6abaeea03282 (diff) | |
| parent | 21ac0beb436f49fe49c6982a872f2dc48e4bea5e (diff) | |
| download | zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.tar.gz zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.zip | |
Merge pull request #16163 from mlugg/feat/builtins-infer-dest-ty
Infer destination type of cast builtins using result type
Diffstat (limited to 'test/behavior/packed-struct.zig')
| -rw-r--r-- | test/behavior/packed-struct.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/behavior/packed-struct.zig b/test/behavior/packed-struct.zig index 037fee74ee..12cc027ef4 100644 --- a/test/behavior/packed-struct.zig +++ b/test/behavior/packed-struct.zig @@ -166,7 +166,7 @@ test "correct sizeOf and offsets in packed structs" { try expectEqual(4, @sizeOf(PStruct)); if (native_endian == .Little) { - const s1 = @bitCast(PStruct, @as(u32, 0x12345678)); + const s1 = @as(PStruct, @bitCast(@as(u32, 0x12345678))); try expectEqual(false, s1.bool_a); try expectEqual(false, s1.bool_b); try expectEqual(false, s1.bool_c); @@ -180,7 +180,7 @@ test "correct sizeOf and offsets in packed structs" { try expectEqual(@as(u10, 0b1101000101), s1.u10_a); try expectEqual(@as(u10, 0b0001001000), s1.u10_b); - const s2 = @bitCast(packed struct { x: u1, y: u7, z: u24 }, @as(u32, 0xd5c71ff4)); + const s2 = @as(packed struct { x: u1, y: u7, z: u24 }, @bitCast(@as(u32, 0xd5c71ff4))); try expectEqual(@as(u1, 0), s2.x); try expectEqual(@as(u7, 0b1111010), s2.y); try expectEqual(@as(u24, 0xd5c71f), s2.z); @@ -207,7 +207,7 @@ test "nested packed structs" { try expectEqual(24, @bitOffsetOf(S3, "y")); if (native_endian == .Little) { - const s3 = @bitCast(S3Padded, @as(u64, 0xe952d5c71ff4)).s3; + const s3 = @as(S3Padded, @bitCast(@as(u64, 0xe952d5c71ff4))).s3; try expectEqual(@as(u8, 0xf4), s3.x.a); try expectEqual(@as(u8, 0x1f), s3.x.b); try expectEqual(@as(u8, 0xc7), s3.x.c); @@ -600,7 +600,7 @@ test "packed struct initialized in bitcast" { const T = packed struct { val: u8 }; var val: u8 = 123; - const t = @bitCast(u8, T{ .val = val }); + const t = @as(u8, @bitCast(T{ .val = val })); try expect(t == val); } @@ -627,7 +627,7 @@ test "pointer to container level packed struct field" { }, var arr = [_]u32{0} ** 2; }; - @ptrCast(*S, &S.arr[0]).other_bits.enable_3 = true; + @as(*S, @ptrCast(&S.arr[0])).other_bits.enable_3 = true; try expect(S.arr[0] == 0x10000000); } |
