parser: reorder tests to match upstream file order

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-02-11 05:16:38 +00:00
parent ca3738bc3e
commit 64ca07dbfd

View File

@@ -544,6 +544,7 @@ fn testCanonical(source: [:0]const u8) !void {
test "zig fmt: remove extra whitespace at start and end of file with comment between" {
try testTransform(
\\
@@ -4166,78 +4167,6 @@ test "zig fmt: if" {
);
}
test "zig fmt: defer" {
try testCanonical(
\\test "defer" {
\\ defer foo();
\\ defer {
\\ bar();
\\ }
\\}
\\
);
}
test "zig fmt: comptime" {
try testCanonical(
\\fn foo() void {
\\ comptime {
\\ bar();
\\ }
\\}
\\
);
}
test "zig fmt: comptime block in container" {
try testCanonical(
\\const Foo = struct {
\\ comptime {
\\ @compileLog("hello comptime");
\\ }
\\};
\\
);
}
test "zig fmt: comment after empty comment" {
try testCanonical(
\\//
\\/// A doc comment
\\const a = b;
\\
);
}
test "zig fmt: comment after params" {
try testCanonical(
\\fn foo(
\\ a: i32, // comment
\\ b: i32, // comment
\\) void {}
\\
);
}
test "zig fmt: container doc comments" {
try testCanonical(
\\//! tld 1
\\//! tld 2
\\//! tld 3
\\const a = b;
\\
);
}
test "zig fmt: decimal float literals with underscore separators" {
try testCanonical(
\\const x = 1_234_567.89_10_11;
\\const y = 1_234_567.89_10_11e1_213_14;
\\const z = 1_234_567;
\\
);
}
test "zig fmt: fix single statement if/for/while line breaks" {
try testTransform(
\\test {
@@ -4290,6 +4219,28 @@ test "zig fmt: fix single statement if/for/while line breaks" {
);
}
test "zig fmt: defer" {
try testCanonical(
\\test "defer" {
\\ defer foo();
\\ defer {
\\ bar();
\\ }
\\}
\\
);
}
test "zig fmt: comptime" {
try testCanonical(
\\fn foo() void {
\\ comptime {
\\ bar();
\\ }
\\}
\\
);
}
test "zig fmt: fn type" {
try testCanonical(
@@ -4304,6 +4255,30 @@ test "zig fmt: fn type" {
);
}
test "zig fmt: inline asm" {
try testTransform(
\\pub fn syscall1(number: usize, arg1: usize) usize {
\\ return asm volatile ("syscall"
\\ : [ret] "={rax}" (-> usize),
\\ : [number] "{rax}" (number),
\\ [arg1] "{rdi}" (arg1),
\\ : "rcx", "r11"
\\ );
\\}
\\
,
\\pub fn syscall1(number: usize, arg1: usize) usize {
\\ return asm volatile ("syscall"
\\ : [ret] "={rax}" (-> usize),
\\ : [number] "{rax}" (number),
\\ [arg1] "{rdi}" (arg1),
\\ : .{ .rcx = true, .r11 = true }
\\ );
\\}
\\
);
}
test "zig fmt: nosuspend" {
try testCanonical(
\\const a = nosuspend foo();
@@ -4344,26 +4319,13 @@ test "zig fmt: error return" {
);
}
test "zig fmt: inline asm" {
try testTransform(
\\pub fn syscall1(number: usize, arg1: usize) usize {
\\ return asm volatile ("syscall"
\\ : [ret] "={rax}" (-> usize),
\\ : [number] "{rax}" (number),
\\ [arg1] "{rdi}" (arg1),
\\ : "rcx", "r11"
\\ );
\\}
\\
,
\\pub fn syscall1(number: usize, arg1: usize) usize {
\\ return asm volatile ("syscall"
\\ : [ret] "={rax}" (-> usize),
\\ : [number] "{rax}" (number),
\\ [arg1] "{rdi}" (arg1),
\\ : .{ .rcx = true, .r11 = true }
\\ );
\\}
test "zig fmt: comptime block in container" {
try testCanonical(
\\const Foo = struct {
\\ comptime {
\\ @compileLog("hello comptime");
\\ }
\\};
\\
);
}
@@ -4430,7 +4392,6 @@ test "zig fmt: multiline string in array" {
);
}
test "zig fmt: file ends with struct field" {
try testCanonical(
\\a: bool
@@ -4438,6 +4399,15 @@ test "zig fmt: file ends with struct field" {
);
}
test "zig fmt: comment after empty comment" {
try testCanonical(
\\//
\\/// A doc comment
\\const a = b;
\\
);
}
test "zig fmt: line comment in array" {
try testTransform(
\\test "a" {
@@ -4470,6 +4440,16 @@ test "zig fmt: line comment in array" {
);
}
test "zig fmt: comment after params" {
try testCanonical(
\\fn foo(
\\ a: i32, // comment
\\ b: i32, // comment
\\) void {}
\\
);
}
test "zig fmt: comment in array initializer/access" {
try testCanonical(
\\test "a" {
@@ -4533,6 +4513,16 @@ test "zig fmt: comments at several places in struct init" {
);
}
test "zig fmt: container doc comments" {
try testCanonical(
\\//! tld 1
\\//! tld 2
\\//! tld 3
\\const a = b;
\\
);
}
test "zig fmt: remove newlines surrounding doc comment" {
try testTransform(
\\
@@ -4567,7 +4557,14 @@ test "zig fmt: remove newlines surrounding doc comment between members" {
);
}
test "zig fmt: decimal float literals with underscore separators" {
try testCanonical(
\\const x = 1_234_567.89_10_11;
\\const y = 1_234_567.89_10_11e1_213_14;
\\const z = 1_234_567;
\\
);
}
test "Ast header smoke test" {
try std.testing.expectEqual(zigNode(c.AST_NODE_IF), Ast.Node.Tag.@"if");