File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -1335,3 +1335,31 @@ test "assign packed struct initialized with RLS to packed struct literal field"
1335
1335
try expect (outer .inner .x == x );
1336
1336
try expect (outer .x == x );
1337
1337
}
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
+ }
You can’t perform that action at this time.
0 commit comments