authorgravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2025-03-16 09:02:34+08:00
committergravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2025-03-22 16:36:14+08:00
loga26f1768d829b28023e48333588dbf30b1f25738
tree5b9bf7654c6239f6cc7a1bf72ce8afd6d8843538
parentc62fb118e70faf531162b897d7e57df843229b72
signaturelock-open Commit is signed but in an unrecognized format.

x86_64: add behavior test for packed store


1 files changed, 28 insertions(+), 0 deletions(-)

test/behavior/packed-struct.zig+28
......@@ -1335,3 +1335,31 @@ test "assign packed struct initialized with RLS to packed struct literal field"
13351335 try expect(outer.inner.x == x);
13361336 try expect(outer.x == x);
13371337}
1338
1339test "packed struct store of comparison result" {
1340 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
1341
1342 const S1 = packed struct {
1343 val1: u3,
1344 val2: u3,
1345 };
1346 const S2 = packed struct {
1347 a: bool,
1348 b: bool,
1349 };
1350
1351 var A: S1 = .{ .val1 = 1, .val2 = 1 };
1352 A.val2 += 1;
1353 try expectEqual(1, A.val1);
1354 try expectEqual(2, A.val2);
1355 try expect((A.val2 & 1) != 1);
1356 const result1: S2 = .{ .a = (A.val2 & 1) != 1, .b = (A.val1 & 1) != 1 };
1357 try expect(result1.a);
1358 try expect(!result1.b);
1359
1360 try expect((A.val2 == 3) == false);
1361 try expect((A.val2 == 2) == true);
1362 const result2: S2 = .{ .a = !(A.val2 == 3), .b = (A.val1 == 2) };
1363 try expect(result2.a);
1364 try expect(!result2.b);
1365}