mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
14 lines
411 B
Zig
14 lines
411 B
Zig
const expect = @import("std").testing.expect;
|
|
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 expect(arr[0] == 2); // succeeds
|
|
try expect(arr[1] == 1); // fails
|
|
}
|
|
|
|
// test_error=
|