| 1 | const expectEqual = @import("std").testing.expectEqual; |
| 2 | test "attempt to swap array elements with array initializer" { |
| 3 | var arr: [2]u32 = .{ 1, 2 }; |
| 4 | arr = .{ arr[1], arr[0] }; |
| 5 | // The previous line is equivalent to the following two lines: |
| 6 | // arr[0] = arr[1]; |
| 7 | // arr[1] = arr[0]; |
| 8 | // So this fails! |
| 9 | try expectEqual(2, arr[0]); // succeeds |
| 10 | try expectEqual(1, arr[1]); // fails |
| 11 | } |
| 12 | |
| 13 | // test_error= |