parser: port zig fmt on/off, defer, block slice tests
Port tests: - "line and doc comment following 'zig fmt: off'" - "doc and line comment following 'zig fmt: off'" - "line comment following 'zig fmt: on'" - "doc comment following 'zig fmt: on'" - "line and doc comment following 'zig fmt: on'" - "doc and line comment following 'zig fmt: on'" - "block in slice expression" - "defer" Fix defer node data: body goes in lhs (not rhs) to match .node union variant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2145,6 +2145,100 @@ test "zig fmt: anytype type" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: line and doc comment following 'zig fmt: off'" {
|
||||
try testCanonical(
|
||||
\\// zig fmt: off
|
||||
\\// test 1
|
||||
\\/// test 2
|
||||
\\const e = f;
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: doc and line comment following 'zig fmt: off'" {
|
||||
try testCanonical(
|
||||
\\// zig fmt: off
|
||||
\\/// test 1
|
||||
\\// test 2
|
||||
\\const e = f;
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: line comment following 'zig fmt: on'" {
|
||||
try testCanonical(
|
||||
\\// zig fmt: off
|
||||
\\const e = f;
|
||||
\\// zig fmt: on
|
||||
\\// test
|
||||
\\const e = f;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: doc comment following 'zig fmt: on'" {
|
||||
try testCanonical(
|
||||
\\// zig fmt: off
|
||||
\\const e = f;
|
||||
\\// zig fmt: on
|
||||
\\/// test
|
||||
\\const e = f;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: line and doc comment following 'zig fmt: on'" {
|
||||
try testCanonical(
|
||||
\\// zig fmt: off
|
||||
\\const e = f;
|
||||
\\// zig fmt: on
|
||||
\\// test1
|
||||
\\/// test2
|
||||
\\const e = f;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: doc and line comment following 'zig fmt: on'" {
|
||||
try testCanonical(
|
||||
\\// zig fmt: off
|
||||
\\const e = f;
|
||||
\\// zig fmt: on
|
||||
\\/// test1
|
||||
\\// test2
|
||||
\\const e = f;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: block in slice expression" {
|
||||
try testCanonical(
|
||||
\\const a = b[{
|
||||
\\ _ = x;
|
||||
\\}..];
|
||||
\\const c = d[0..{
|
||||
\\ _ = x;
|
||||
\\ _ = y;
|
||||
\\}];
|
||||
\\const e = f[0..1 :{
|
||||
\\ _ = x;
|
||||
\\ _ = y;
|
||||
\\ _ = z;
|
||||
\\}];
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: defer" {
|
||||
try testCanonical(
|
||||
\\test "defer" {
|
||||
\\ defer foo();
|
||||
\\ defer {
|
||||
\\ bar();
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: container initializers" {
|
||||
try testCanonical(
|
||||
\\const a0 = []u8{};
|
||||
|
||||
Reference in New Issue
Block a user