|
|
|
@@ -26,6 +26,8 @@ test "zig fmt: tuple struct" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: preserves clobbers in inline asm with stray comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ asm volatile (""
|
|
|
|
@@ -44,6 +46,8 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: remove trailing comma at the end of assembly clobber" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ asm volatile (""
|
|
|
|
@@ -66,6 +70,8 @@ test "zig fmt: remove trailing comma at the end of assembly clobber" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: respect line breaks in struct field value declaration" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const Foo = struct {
|
|
|
|
|
\\ bar: u32 =
|
|
|
|
@@ -220,6 +226,8 @@ test "zig fmt: file ends in comment after var decl" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if statement" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ if (optional()) |some|
|
|
|
|
@@ -318,6 +326,8 @@ test "zig fmt: decl between fields" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: errdefer with payload" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn main() anyerror!void {
|
|
|
|
|
\\ errdefer |a| x += 1;
|
|
|
|
@@ -331,6 +341,8 @@ test "zig fmt: errdefer with payload" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: nosuspend block" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn main() anyerror!void {
|
|
|
|
|
\\ nosuspend {
|
|
|
|
@@ -342,6 +354,8 @@ test "zig fmt: nosuspend block" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: nosuspend await" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ x = nosuspend await y;
|
|
|
|
@@ -362,6 +376,8 @@ test "zig fmt: container declaration, single line" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: container declaration, one item, multi line trailing comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ comptime {
|
|
|
|
@@ -375,6 +391,8 @@ test "zig fmt: container declaration, one item, multi line trailing comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: container declaration, no trailing comma on separate line" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ comptime {
|
|
|
|
@@ -501,6 +519,8 @@ test "zig fmt: remove empty lines at start/end of container decl" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: remove empty lines at start/end of block" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\test {
|
|
|
|
|
\\
|
|
|
|
@@ -521,6 +541,8 @@ test "zig fmt: remove empty lines at start/end of block" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: allow empty line before comment at start of block" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\
|
|
|
|
@@ -584,6 +606,8 @@ test "zig fmt: comptime struct field" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: break from block" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const a = blk: {
|
|
|
|
|
\\ break :blk 42;
|
|
|
|
@@ -616,6 +640,8 @@ test "zig fmt: c pointer type" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: builtin call with trailing comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn main() void {
|
|
|
|
|
\\ @breakpoint();
|
|
|
|
@@ -631,6 +657,8 @@ test "zig fmt: builtin call with trailing comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: asm expression with comptime content" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ asm ("foo" ++ "bar");
|
|
|
|
@@ -655,6 +683,8 @@ test "zig fmt: asm expression with comptime content" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: array types last token" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = [40]u32;
|
|
|
|
@@ -668,6 +698,8 @@ test "zig fmt: array types last token" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: sentinel-terminated array type" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn cStrToPrefixedFileW(s: [*:0]const u8) ![PATH_MAX_WIDE:0]u16 {
|
|
|
|
|
\\ return sliceToPrefixedFileW(mem.toSliceConst(u8, s));
|
|
|
|
@@ -677,6 +709,8 @@ test "zig fmt: sentinel-terminated array type" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: sentinel-terminated slice type" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn toSlice(self: Buffer) [:0]u8 {
|
|
|
|
|
\\ return self.list.toSlice()[0..self.len()];
|
|
|
|
@@ -748,6 +782,8 @@ test "zig fmt: anon literal in array" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: alignment in anonymous literal" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\const a = .{
|
|
|
|
|
\\ "U", "L", "F",
|
|
|
|
@@ -766,6 +802,8 @@ test "zig fmt: alignment in anonymous literal" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon struct literal 0 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{};
|
|
|
|
@@ -775,6 +813,8 @@ test "zig fmt: anon struct literal 0 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon struct literal 1 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{ .a = b };
|
|
|
|
@@ -784,6 +824,8 @@ test "zig fmt: anon struct literal 1 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon struct literal 1 element comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{
|
|
|
|
@@ -795,6 +837,8 @@ test "zig fmt: anon struct literal 1 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon struct literal 2 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{ .a = b, .c = d };
|
|
|
|
@@ -804,6 +848,8 @@ test "zig fmt: anon struct literal 2 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon struct literal 2 element comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{
|
|
|
|
@@ -816,6 +862,8 @@ test "zig fmt: anon struct literal 2 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon struct literal 3 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{ .a = b, .c = d, .e = f };
|
|
|
|
@@ -825,6 +873,8 @@ test "zig fmt: anon struct literal 3 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon struct literal 3 element comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{
|
|
|
|
@@ -838,6 +888,8 @@ test "zig fmt: anon struct literal 3 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct literal 0 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = X{};
|
|
|
|
@@ -847,6 +899,8 @@ test "zig fmt: struct literal 0 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct literal 1 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = X{ .a = b };
|
|
|
|
@@ -856,6 +910,8 @@ test "zig fmt: struct literal 1 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: Unicode code point literal larger than u8" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = X{
|
|
|
|
@@ -867,6 +923,8 @@ test "zig fmt: Unicode code point literal larger than u8" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct literal 2 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = X{ .a = b, .c = d };
|
|
|
|
@@ -876,6 +934,8 @@ test "zig fmt: struct literal 2 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct literal 2 element comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = X{
|
|
|
|
@@ -888,6 +948,8 @@ test "zig fmt: struct literal 2 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct literal 3 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = X{ .a = b, .c = d, .e = f };
|
|
|
|
@@ -897,6 +959,8 @@ test "zig fmt: struct literal 3 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct literal 3 element comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = X{
|
|
|
|
@@ -910,6 +974,8 @@ test "zig fmt: struct literal 3 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon list literal 1 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{a};
|
|
|
|
@@ -930,6 +996,8 @@ test "zig fmt: anon list literal 1 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon list literal 2 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{ a, b };
|
|
|
|
@@ -951,6 +1019,8 @@ test "zig fmt: anon list literal 2 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon list literal 3 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = .{ a, b, c };
|
|
|
|
@@ -975,6 +1045,8 @@ test "zig fmt: anon list literal 3 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: array literal 0 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = [_]u32{};
|
|
|
|
@@ -984,6 +1056,8 @@ test "zig fmt: array literal 0 element" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: array literal 1 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = [_]u32{a};
|
|
|
|
@@ -1004,6 +1078,8 @@ test "zig fmt: array literal 1 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: array literal 2 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = [_]u32{ a, b };
|
|
|
|
@@ -1025,6 +1101,8 @@ test "zig fmt: array literal 2 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: array literal 3 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = [_]u32{ a, b, c };
|
|
|
|
@@ -1047,6 +1125,8 @@ test "zig fmt: array literal 3 element comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: sentinel array literal 1 element" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const x = [_:9000]u32{a};
|
|
|
|
@@ -1076,6 +1156,8 @@ test "zig fmt: slices with spaces in bounds" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: block in slice expression" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const a = b[{
|
|
|
|
|
\\ _ = x;
|
|
|
|
@@ -1094,6 +1176,8 @@ test "zig fmt: block in slice expression" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: async function" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub const Server = struct {
|
|
|
|
|
\\ handleRequestFn: fn (*Server, *const std.net.Address, File) callconv(.Async) void,
|
|
|
|
@@ -1106,6 +1190,8 @@ test "zig fmt: async function" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: whitespace fixes" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform("test \"\" {\r\n\tconst hi = x;\r\n}\n// zig fmt: off\ntest \"\"{\r\n\tconst a = b;}\r\n",
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ const hi = x;
|
|
|
|
@@ -1118,6 +1204,8 @@ test "zig fmt: whitespace fixes" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: while else err prong with no block" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ const result = while (returnError()) |value| {
|
|
|
|
@@ -1147,6 +1235,8 @@ test "zig fmt: tagged union with enum values" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: tagged union enum tag last token" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const U = union(enum(u32)) {};
|
|
|
|
@@ -1482,6 +1572,8 @@ test "zig fmt: doc and line comment following 'zig fmt: on'" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: 'zig fmt: (off|on)' works in the middle of code" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ const x = 42;
|
|
|
|
@@ -1508,6 +1600,8 @@ test "zig fmt: 'zig fmt: (off|on)' works in the middle of code" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: 'zig fmt: on' indentation is unchanged" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn initOptionsAndLayouts(output: *Output, context: *Context) !void {
|
|
|
|
|
\\ // zig fmt: off
|
|
|
|
@@ -1550,6 +1644,8 @@ test "zig fmt: spaces around slice operator" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: async call in if condition" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ if (async b()) {
|
|
|
|
@@ -1561,6 +1657,8 @@ test "zig fmt: async call in if condition" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: 2nd arg multiline string" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ cases.addAsm("hello world linux x86_64",
|
|
|
|
@@ -1589,6 +1687,8 @@ test "zig fmt: 2nd arg multiline string" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: 2nd arg multiline string many args" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ cases.addAsm("hello world linux x86_64",
|
|
|
|
@@ -1600,6 +1700,8 @@ test "zig fmt: 2nd arg multiline string many args" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: final arg multiline string" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ cases.addAsm("hello world linux x86_64", "Hello, world!\n",
|
|
|
|
@@ -1611,6 +1713,8 @@ test "zig fmt: final arg multiline string" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if condition wraps" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ if (cond and
|
|
|
|
@@ -1692,6 +1796,8 @@ test "zig fmt: if condition wraps" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if condition has line break but must not wrap" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ if (self.user_input_options.put(
|
|
|
|
@@ -1716,6 +1822,8 @@ test "zig fmt: if condition has line break but must not wrap" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if condition has line break but must not wrap (no fn call comma)" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ if (self.user_input_options.put(name, UserInputOption{
|
|
|
|
@@ -1737,6 +1845,8 @@ test "zig fmt: if condition has line break but must not wrap (no fn call comma)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: function call with multiline argument" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ self.user_input_options.put(name, UserInputOption{
|
|
|
|
@@ -1749,6 +1859,8 @@ test "zig fmt: function call with multiline argument" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if-else with comment before else" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ // cexp(finite|nan +- i inf|nan) = nan + i nan
|
|
|
|
@@ -1767,6 +1879,8 @@ test "zig fmt: if-else with comment before else" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if nested" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn foo() void {
|
|
|
|
|
\\ return if ((aInt & bInt) >= 0)
|
|
|
|
@@ -1790,6 +1904,8 @@ test "zig fmt: if nested" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: respect line breaks in if-else" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ return if (cond) a else b;
|
|
|
|
@@ -1809,6 +1925,8 @@ test "zig fmt: respect line breaks in if-else" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: respect line breaks after infix operators" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ self.crc =
|
|
|
|
@@ -1872,6 +1990,8 @@ test "zig fmt: switch comment after prong" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct literal no trailing comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\const a = foo{ .x = 1, .y = 2 };
|
|
|
|
|
\\const a = foo{ .x = 1,
|
|
|
|
@@ -1890,6 +2010,8 @@ test "zig fmt: struct literal no trailing comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct literal containing a multiline expression" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\const a = A{ .x = if (f1()) 10 else 20 };
|
|
|
|
|
\\const a = A{ .x = if (f1()) 10 else 20, };
|
|
|
|
@@ -1951,6 +2073,8 @@ test "zig fmt: struct literal containing a multiline expression" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: array literal with hint" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\const a = []u8{
|
|
|
|
|
\\ 1, 2, //
|
|
|
|
@@ -2028,6 +2152,8 @@ test "zig fmt: array literal with hint" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: array literal vertical column alignment" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\const a = []u8{
|
|
|
|
|
\\ 1000, 200,
|
|
|
|
@@ -2075,6 +2201,8 @@ test "zig fmt: array literal vertical column alignment" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: multiline string with backslash at end of line" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ err(
|
|
|
|
@@ -2086,6 +2214,8 @@ test "zig fmt: multiline string with backslash at end of line" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: multiline string parameter in fn call with trailing comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ try stdout.print(
|
|
|
|
@@ -2104,6 +2234,8 @@ test "zig fmt: multiline string parameter in fn call with trailing comma" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: trailing comma on fn call" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ var module = try Module.create(
|
|
|
|
@@ -2117,6 +2249,8 @@ test "zig fmt: trailing comma on fn call" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: multi line arguments without last comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\pub fn foo(
|
|
|
|
|
\\ a: usize,
|
|
|
|
@@ -2178,6 +2312,8 @@ test "zig fmt: extra newlines at the end" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: simple asm" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ asm volatile (
|
|
|
|
@@ -2215,6 +2351,8 @@ test "zig fmt: simple asm" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: nested struct literal with one item" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const a = foo{
|
|
|
|
|
\\ .item = bar{ .a = b },
|
|
|
|
@@ -2258,6 +2396,8 @@ test "zig fmt: slice align" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: add trailing comma to array literal" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ return []u16{'m', 's', 'y', 's', '-' // hi
|
|
|
|
@@ -2299,6 +2439,8 @@ test "zig fmt: line comment after doc comment" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: bit field alignment" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ assert(@TypeOf(&blah.b) == *align(1:3:6) const u3);
|
|
|
|
@@ -2330,6 +2472,8 @@ test "zig fmt: float literal with exponent" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if-else end of comptime" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ if (a) {
|
|
|
|
@@ -2343,6 +2487,8 @@ test "zig fmt: if-else end of comptime" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: nested blocks" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ {
|
|
|
|
@@ -2358,6 +2504,8 @@ test "zig fmt: nested blocks" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: block with same line comment after end brace" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ {
|
|
|
|
@@ -2369,6 +2517,8 @@ test "zig fmt: block with same line comment after end brace" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: statements with comment between" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ a = b;
|
|
|
|
@@ -2380,6 +2530,8 @@ test "zig fmt: statements with comment between" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: statements with empty line between" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ a = b;
|
|
|
|
@@ -2399,6 +2551,8 @@ test "zig fmt: ptr deref operator and unwrap optional operator" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: comment after if before another if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "aoeu" {
|
|
|
|
|
\\ // comment
|
|
|
|
@@ -2421,6 +2575,8 @@ test "zig fmt: comment after if before another if" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: line comment between if block and else keyword" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "aoeu" {
|
|
|
|
|
\\ // cexp(finite|nan +- i inf|nan) = nan + i nan
|
|
|
|
@@ -2442,6 +2598,8 @@ test "zig fmt: line comment between if block and else keyword" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: same line comments in expression" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "aoeu" {
|
|
|
|
|
\\ const x = ( // a
|
|
|
|
@@ -2482,6 +2640,8 @@ test "zig fmt: add comma on last switch prong" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: same-line comment after a statement" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ a = b;
|
|
|
|
@@ -2527,6 +2687,8 @@ test "zig fmt: same-line comment after switch prong" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: same-line comment after non-block if expression" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\comptime {
|
|
|
|
|
\\ if (sr > n_uword_bits - 1) // d > r
|
|
|
|
@@ -2537,6 +2699,8 @@ test "zig fmt: same-line comment after non-block if expression" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: same-line comment on comptime expression" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt
|
|
|
|
@@ -2546,6 +2710,8 @@ test "zig fmt: same-line comment on comptime expression" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: switch with empty body" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ foo() catch |err| switch (err) {};
|
|
|
|
@@ -2555,6 +2721,8 @@ test "zig fmt: switch with empty body" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: line comments in struct initializer" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ return Self{
|
|
|
|
@@ -2577,6 +2745,8 @@ test "zig fmt: line comments in struct initializer" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: first line comment in struct initializer" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn acquire(self: *Self) HeldLock {
|
|
|
|
|
\\ return HeldLock{
|
|
|
|
@@ -2645,6 +2815,8 @@ test "zig fmt: union(enum(u32)) with assigned enum values" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: resume from suspend block" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ suspend {
|
|
|
|
@@ -2730,6 +2902,8 @@ test "zig fmt: comments before global variables" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: comments in statements" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "std" {
|
|
|
|
|
\\ // statement comment
|
|
|
|
@@ -2757,6 +2931,8 @@ test "zig fmt: comments before test decl" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: preserve spacing" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const std = @import("std");
|
|
|
|
|
\\
|
|
|
|
@@ -2825,6 +3001,8 @@ test "zig fmt: alignment" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: C main" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn main(argc: c_int, argv: **u8) c_int {
|
|
|
|
|
\\ const a = b;
|
|
|
|
@@ -2834,6 +3012,8 @@ test "zig fmt: C main" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: return" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo(argc: c_int, argv: **u8) c_int {
|
|
|
|
|
\\ return 0;
|
|
|
|
@@ -2896,6 +3076,8 @@ test "zig fmt: slice attributes" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: test declaration" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "test name" {
|
|
|
|
|
\\ const a = 1;
|
|
|
|
@@ -2906,6 +3088,8 @@ test "zig fmt: test declaration" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: infix operators" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ var i = undefined;
|
|
|
|
@@ -2958,6 +3142,8 @@ test "zig fmt: infix operators" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: precedence" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "precedence" {
|
|
|
|
|
\\ a!b();
|
|
|
|
@@ -2990,6 +3176,8 @@ test "zig fmt: precedence" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: prefix operators" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "prefix operators" {
|
|
|
|
|
\\ try return --%~!&0;
|
|
|
|
@@ -2999,6 +3187,8 @@ test "zig fmt: prefix operators" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: call expression" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "test calls" {
|
|
|
|
|
\\ a();
|
|
|
|
@@ -3018,6 +3208,8 @@ test "zig fmt: anytype type" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: functions" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\extern fn puts(s: *const u8) c_int;
|
|
|
|
|
\\extern "c" fn puts(s: *const u8) c_int;
|
|
|
|
@@ -3042,6 +3234,8 @@ test "zig fmt: functions" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: multiline string" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "" {
|
|
|
|
|
\\ const s1 =
|
|
|
|
@@ -3060,6 +3254,8 @@ test "zig fmt: multiline string" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: values" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "values" {
|
|
|
|
|
\\ 1;
|
|
|
|
@@ -3079,6 +3275,8 @@ test "zig fmt: values" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: indexing" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "test index" {
|
|
|
|
|
\\ a[0];
|
|
|
|
@@ -3099,6 +3297,8 @@ test "zig fmt: indexing" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: struct declaration" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const S = struct {
|
|
|
|
|
\\ const Self = @This();
|
|
|
|
@@ -3205,6 +3405,8 @@ test "zig fmt: union declaration" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: arrays" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "test array" {
|
|
|
|
|
\\ const a: [2]u8 = [2]u8{
|
|
|
|
@@ -3223,6 +3425,8 @@ test "zig fmt: arrays" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: container initializers" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const a0 = []u8{};
|
|
|
|
|
\\const a1 = []u8{1};
|
|
|
|
@@ -3243,6 +3447,8 @@ test "zig fmt: container initializers" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: catch" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "catch" {
|
|
|
|
|
\\ const a: anyerror!u8 = 0;
|
|
|
|
@@ -3258,6 +3464,8 @@ test "zig fmt: catch" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: blocks" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "blocks" {
|
|
|
|
|
\\ {
|
|
|
|
@@ -3280,6 +3488,8 @@ test "zig fmt: blocks" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: switch" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "switch" {
|
|
|
|
|
\\ switch (0) {
|
|
|
|
@@ -3335,6 +3545,8 @@ test "zig fmt: switch" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: switch multiline string" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "switch multiline string" {
|
|
|
|
|
\\ const x: u32 = 0;
|
|
|
|
@@ -3366,6 +3578,8 @@ test "zig fmt: switch multiline string" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: while" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "while" {
|
|
|
|
|
\\ while (10 < 1) unreachable;
|
|
|
|
@@ -3441,6 +3655,8 @@ test "zig fmt: while" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: for" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "for" {
|
|
|
|
|
\\ for (a) |v| {
|
|
|
|
@@ -3542,6 +3758,8 @@ test "zig fmt: for" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: for if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ for (a) |x| if (x) f(x);
|
|
|
|
@@ -3567,6 +3785,8 @@ test "zig fmt: for if" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if for" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ if (a) for (x) |x| f(x);
|
|
|
|
@@ -3592,6 +3812,8 @@ test "zig fmt: if for" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: while if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ while (a) if (x) f(x);
|
|
|
|
@@ -3617,6 +3839,8 @@ test "zig fmt: while if" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if while" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ if (a) while (x) : (cont) f(x);
|
|
|
|
@@ -3642,6 +3866,8 @@ test "zig fmt: if while" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: while for" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ while (a) for (x) |x| f(x);
|
|
|
|
@@ -3667,6 +3893,8 @@ test "zig fmt: while for" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: for while" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ for (a) |a| while (x) |x| f(x);
|
|
|
|
@@ -3692,6 +3920,8 @@ test "zig fmt: for while" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "if" {
|
|
|
|
|
\\ if (10 < 0) {
|
|
|
|
@@ -3741,6 +3971,8 @@ test "zig fmt: if" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: fix single statement if/for/while line breaks" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ if (cond) a
|
|
|
|
@@ -3793,6 +4025,8 @@ test "zig fmt: fix single statement if/for/while line breaks" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: anon struct/array literal in if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const a = if (cond) .{
|
|
|
|
@@ -3817,6 +4051,8 @@ test "zig fmt: anon struct/array literal in if" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: defer" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "defer" {
|
|
|
|
|
\\ var i: usize = 0;
|
|
|
|
@@ -3837,6 +4073,8 @@ test "zig fmt: defer" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: comptime" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn a() u8 {
|
|
|
|
|
\\ return 5;
|
|
|
|
@@ -3876,6 +4114,8 @@ test "zig fmt: comptime" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: fn type" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn a(i: u8) u8 {
|
|
|
|
|
\\ return i + 1;
|
|
|
|
@@ -3889,6 +4129,8 @@ test "zig fmt: fn type" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: inline asm" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn syscall1(number: usize, arg1: usize) usize {
|
|
|
|
|
\\ return asm volatile ("syscall"
|
|
|
|
@@ -3903,6 +4145,8 @@ test "zig fmt: inline asm" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: async functions" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn simpleAsyncFn() void {
|
|
|
|
|
\\ const a = async a.b();
|
|
|
|
@@ -3931,6 +4175,8 @@ test "zig fmt: nosuspend" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: Block after if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ if (true) {
|
|
|
|
@@ -3962,6 +4208,8 @@ test "zig fmt: string identifier" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: error return" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn err() anyerror {
|
|
|
|
|
\\ call();
|
|
|
|
@@ -3972,6 +4220,8 @@ test "zig fmt: error return" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: comptime block in container" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn container() type {
|
|
|
|
|
\\ return struct {
|
|
|
|
@@ -3987,6 +4237,8 @@ test "zig fmt: comptime block in container" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: inline asm parameter alignment" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn main() void {
|
|
|
|
|
\\ asm volatile (
|
|
|
|
@@ -4025,6 +4277,8 @@ test "zig fmt: inline asm parameter alignment" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: multiline string in array" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const Foo = [][]const u8{
|
|
|
|
|
\\ \\aaa
|
|
|
|
@@ -4050,6 +4304,8 @@ test "zig fmt: multiline string in array" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: if type expr" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const mycond = true;
|
|
|
|
|
\\pub fn foo() if (mycond) i32 else void {
|
|
|
|
@@ -4078,6 +4334,8 @@ test "zig fmt: comment after empty comment" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: line comment in array" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\test "a" {
|
|
|
|
|
\\ var arr = [_]u32{
|
|
|
|
@@ -4136,6 +4394,8 @@ test "zig fmt: comment after params" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: comment in array initializer/access" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "a" {
|
|
|
|
|
\\ var a = x{ //aa
|
|
|
|
@@ -4172,6 +4432,8 @@ test "zig fmt: comment in array initializer/access" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: comments at several places in struct init" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\var bar = Bar{
|
|
|
|
|
\\ .x = 10, // test
|
|
|
|
@@ -4395,6 +4657,8 @@ test "zig fmt: integer literals with underscore separators" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: hex literals with underscore separators" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\pub fn orMask(a: [ 1_000 ]u64, b: [ 1_000] u64) [1_000]u64 {
|
|
|
|
|
\\ var c: [1_000]u64 = [1]u64{ 0xFFFF_FFFF_FFFF_FFFF}**1_000;
|
|
|
|
@@ -4418,6 +4682,8 @@ test "zig fmt: hex literals with underscore separators" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: decimal float literals with underscore separators" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\pub fn main() void {
|
|
|
|
|
\\ const a:f64=(10.0e-0+(10.0e+0))+10_00.00_00e-2+20_00.00_10e+4;
|
|
|
|
@@ -4435,6 +4701,8 @@ test "zig fmt: decimal float literals with underscore separators" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: hexadeciaml float literals with underscore separators" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\pub fn main() void {
|
|
|
|
|
\\ const a: f64 = (0x10.0p-0+(0x10.0p+0))+0x10_00.00_00p-8+0x00_00.00_10p+16;
|
|
|
|
@@ -4459,6 +4727,8 @@ test "zig fmt: C var args" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: Only indent multiline string literals in function calls" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test "zig fmt:" {
|
|
|
|
|
\\ try testTransform(
|
|
|
|
@@ -4476,6 +4746,8 @@ test "zig fmt: Only indent multiline string literals in function calls" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: Don't add extra newline after if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn atomicSymLink(allocator: Allocator, existing_path: []const u8, new_path: []const u8) !void {
|
|
|
|
|
\\ if (cwd().symLink(existing_path, new_path, .{})) {
|
|
|
|
@@ -4487,6 +4759,8 @@ test "zig fmt: Don't add extra newline after if" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: comments in ternary ifs" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const x = if (true) {
|
|
|
|
|
\\ 1;
|
|
|
|
@@ -4506,6 +4780,8 @@ test "zig fmt: comments in ternary ifs" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: while statement in blockless if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn main() void {
|
|
|
|
|
\\ const zoom_node = if (focused_node == layout_first)
|
|
|
|
@@ -4555,6 +4831,8 @@ test "zig fmt: test comments in field access chain" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: allow line break before field access" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ const w = foo.bar().zippy(zag).iguessthisisok();
|
|
|
|
@@ -4603,6 +4881,8 @@ test "zig fmt: allow line break before field access" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: Indent comma correctly after multiline string literals in arg list (trailing comma)" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ z.display_message_dialog(
|
|
|
|
@@ -4628,6 +4908,8 @@ test "zig fmt: Indent comma correctly after multiline string literals in arg lis
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: Control flow statement as body of blockless if" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn main() void {
|
|
|
|
|
\\ const zoom_node = if (focused_node == layout_first)
|
|
|
|
@@ -4663,6 +4945,8 @@ test "zig fmt: Control flow statement as body of blockless if" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: regression test for #5722" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn sendViewTags(self: Self) void {
|
|
|
|
|
\\ var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32));
|
|
|
|
@@ -4685,6 +4969,8 @@ test "zig fmt: regression test for #8974" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: allow trailing line comments to do manual array formatting" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ self.code.appendSliceAssumeCapacity(&[_]u8{
|
|
|
|
@@ -4723,6 +5009,8 @@ test "zig fmt: allow trailing line comments to do manual array formatting" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: multiline string literals should play nice with array initializers" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn main() void {
|
|
|
|
|
\\ var a = .{.{.{.{.{.{.{.{
|
|
|
|
@@ -4789,6 +5077,8 @@ test "zig fmt: multiline string literals should play nice with array initializer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: use of comments and multiline string literals may force the parameters over multiple lines" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn makeMemUndefined(qzz: []u8) i1 {
|
|
|
|
|
\\ cases.add( // fixed bug foo
|
|
|
|
@@ -4829,6 +5119,8 @@ test "zig fmt: use of comments and multiline string literals may force the param
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: single argument trailing commas in @builtins()" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn foo(qzz: []u8) i1 {
|
|
|
|
|
\\ @panic(
|
|
|
|
@@ -4862,6 +5154,8 @@ test "zig fmt: trailing comma should force multiline 1 column" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: function params should align nicely" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\pub fn foo() void {
|
|
|
|
|
\\ cases.addRuntimeSafety("slicing operator with sentinel",
|
|
|
|
@@ -4918,6 +5212,8 @@ test "zig fmt: remove trailing whitespace after doc comment" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: for loop with ptr payload and index" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ for (self.entries.items, 0..) |*item, i| {}
|
|
|
|
@@ -4930,6 +5226,8 @@ test "zig fmt: for loop with ptr payload and index" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: proper indent line comment after multi-line single expr while loop" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ while (a) : (b)
|
|
|
|
@@ -4943,6 +5241,8 @@ test "zig fmt: proper indent line comment after multi-line single expr while loo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: function with labeled block as return type" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() t: {
|
|
|
|
|
\\ break :t bar;
|
|
|
|
@@ -4965,6 +5265,8 @@ test "zig fmt: extern function with missing param name" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: line comment after multiline single expr if statement with multiline string" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ if (foo)
|
|
|
|
@@ -4997,6 +5299,8 @@ test "zig fmt: line comment after multiline single expr if statement with multil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: respect extra newline between fn and pub usingnamespace" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\fn foo() void {
|
|
|
|
|
\\ bar();
|
|
|
|
@@ -5121,6 +5425,8 @@ test "zig fmt: insert trailing comma if comments in array init" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: make single-line if no trailing comma" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\test "function call no trailing comma" {
|
|
|
|
|
\\ foo(
|
|
|
|
@@ -5300,6 +5606,8 @@ test "zig fmt: missing const/var before local variable" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: while continue expr" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\test {
|
|
|
|
|
\\ while (i > 0)
|
|
|
|
@@ -5319,6 +5627,8 @@ test "zig fmt: while continue expr" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: canonicalize symbols (simple)" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\const val_normal: Normal = .{};
|
|
|
|
|
\\const @"val_unesc_me": @"UnescMe" = .{};
|
|
|
|
@@ -5468,6 +5778,8 @@ test "zig fmt: canonicalize symbols (simple)" {
|
|
|
|
|
|
|
|
|
|
// Contextually unescape when shadowing primitive types and values.
|
|
|
|
|
test "zig fmt: canonicalize symbols (primitive types)" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\const @"anyopaque" = struct {
|
|
|
|
|
\\ @"u8": @"type" = true,
|
|
|
|
@@ -5577,6 +5889,8 @@ test "zig fmt: canonicalize symbols (primitive types)" {
|
|
|
|
|
|
|
|
|
|
// Never unescape names spelled like keywords.
|
|
|
|
|
test "zig fmt: canonicalize symbols (keywords)" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const @"enum" = struct {
|
|
|
|
|
\\ @"error": @"struct" = true,
|
|
|
|
@@ -5604,6 +5918,8 @@ test "zig fmt: canonicalize symbols (keywords)" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: no space before newline before multiline string" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testCanonical(
|
|
|
|
|
\\const S = struct {
|
|
|
|
|
\\ text: []const u8,
|
|
|
|
@@ -5634,6 +5950,8 @@ test "zig fmt: no space before newline before multiline string" {
|
|
|
|
|
|
|
|
|
|
// Normalize \xNN and \u{NN} escapes and unicode inside @"" escapes.
|
|
|
|
|
test "zig fmt: canonicalize symbols (character escapes)" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\const @"\x46\x6f\x6f\x64" = struct {
|
|
|
|
|
\\ @"\x62\x61\x72\x6E": @"\x43\x72\x61\x62" = false,
|
|
|
|
@@ -5676,6 +5994,8 @@ test "zig fmt: canonicalize symbols (character escapes)" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test "zig fmt: canonicalize symbols (asm)" {
|
|
|
|
|
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
|
|
|
|
|
|
|
|
|
try testTransform(
|
|
|
|
|
\\test "asm" {
|
|
|
|
|
\\ const @"null" = usize;
|
|
|
|
|