Skip to content

Commit 730a78d

Browse files
committed
x86_64: add behavior test for packed store
1 parent 1feaaf1 commit 730a78d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/behavior/struct.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,3 +2140,25 @@ test "anonymous struct equivalence" {
21402140
comptime assert(A != C);
21412141
comptime assert(B != C);
21422142
}
2143+
2144+
test "packed struct store" {
2145+
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
2146+
2147+
const S1 = packed struct {
2148+
val1: u3,
2149+
val2: u3,
2150+
};
2151+
const S2 = packed struct {
2152+
a: bool,
2153+
b: bool,
2154+
};
2155+
2156+
var A: S1 = .{ .val1 = 1, .val2 = 1 };
2157+
A.val2 += 1;
2158+
try expectEqual(1, A.val1);
2159+
try expectEqual(2, A.val2);
2160+
try expect((A.val2 & 1) != 1);
2161+
const result: S2 = .{ .a = (A.val2 & 1) != 1, .b = (A.val1 & 1) != 1 };
2162+
try expect(result.a);
2163+
try expect(!result.b);
2164+
}

0 commit comments

Comments
 (0)