mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:24:49 +01:00
13 lines
427 B
Zig
13 lines
427 B
Zig
const expectEqual = @import("std").testing.expectEqual;
|
|
test "attempt to swap array elements with array initializer" {
|
|
var arr: [2]u32 = .{ 1, 2 };
|
|
arr = .{ arr[1], arr[0] };
|
|
// The previous line is equivalent to the following two lines:
|
|
// arr[0] = arr[1];
|
|
// arr[1] = arr[0];
|
|
// So this fails!
|
|
try expectEqual(2, arr[0]); // succeeds
|
|
try expectEqual(1, arr[1]); // fails
|
|
}
|
|
|
|
// test_error=
|