Skip to content

Commit a26f176

Browse files
committed
x86_64: add behavior test for packed store
1 parent c62fb11 commit a26f176

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/behavior/packed-struct.zig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1339+
test "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+
}

0 commit comments

Comments
 (0)