We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1feaaf1 commit 730a78dCopy full SHA for 730a78d
test/behavior/struct.zig
@@ -2140,3 +2140,25 @@ test "anonymous struct equivalence" {
2140
comptime assert(A != C);
2141
comptime assert(B != C);
2142
}
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