parser: update test bodies to match upstream verbatim
Update test content to match upstream: - "arrays" (full upstream test content) - "blocks" (add labeled block and blk: variants) - "comptime" (full upstream test with comptime var, expressions) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3198,11 +3198,17 @@ test "zig fmt: union declaration" {
|
|||||||
|
|
||||||
test "zig fmt: arrays" {
|
test "zig fmt: arrays" {
|
||||||
try testCanonical(
|
try testCanonical(
|
||||||
\\test "arrays" {
|
\\test "test array" {
|
||||||
\\ const a: [2]u32 = .{ 1, 2 };
|
\\ const a: [2]u8 = [2]u8{
|
||||||
\\ const b = a ++ a;
|
\\ 1,
|
||||||
\\ const c = a[0..];
|
\\ 2,
|
||||||
\\ _ = c;
|
\\ };
|
||||||
|
\\ const a: [2]u8 = []u8{
|
||||||
|
\\ 1,
|
||||||
|
\\ 2,
|
||||||
|
\\ };
|
||||||
|
\\ const a: [0]u8 = []u8{};
|
||||||
|
\\ const x: [4:0]u8 = undefined;
|
||||||
\\}
|
\\}
|
||||||
\\
|
\\
|
||||||
);
|
);
|
||||||
@@ -3245,11 +3251,21 @@ test "zig fmt: catch" {
|
|||||||
|
|
||||||
test "zig fmt: blocks" {
|
test "zig fmt: blocks" {
|
||||||
try testCanonical(
|
try testCanonical(
|
||||||
\\test {
|
\\test "blocks" {
|
||||||
\\ {
|
\\ {
|
||||||
\\ const a = b;
|
\\ const a = 0;
|
||||||
|
\\ const b = 0;
|
||||||
\\ }
|
\\ }
|
||||||
\\ const c = d;
|
\\
|
||||||
|
\\ blk: {
|
||||||
|
\\ const a = 0;
|
||||||
|
\\ const b = 0;
|
||||||
|
\\ }
|
||||||
|
\\
|
||||||
|
\\ const r = blk: {
|
||||||
|
\\ const a = 0;
|
||||||
|
\\ const b = 0;
|
||||||
|
\\ };
|
||||||
\\}
|
\\}
|
||||||
\\
|
\\
|
||||||
);
|
);
|
||||||
@@ -3794,9 +3810,37 @@ test "zig fmt: defer" {
|
|||||||
|
|
||||||
test "zig fmt: comptime" {
|
test "zig fmt: comptime" {
|
||||||
try testCanonical(
|
try testCanonical(
|
||||||
\\fn foo() void {
|
\\fn a() u8 {
|
||||||
|
\\ return 5;
|
||||||
|
\\}
|
||||||
|
\\
|
||||||
|
\\fn b(comptime i: u8) u8 {
|
||||||
|
\\ return i;
|
||||||
|
\\}
|
||||||
|
\\
|
||||||
|
\\const av = comptime a();
|
||||||
|
\\const av2 = comptime blk: {
|
||||||
|
\\ var res = a();
|
||||||
|
\\ res *= b(2);
|
||||||
|
\\ break :blk res;
|
||||||
|
\\};
|
||||||
|
\\
|
||||||
|
\\comptime {
|
||||||
|
\\ _ = a();
|
||||||
|
\\}
|
||||||
|
\\
|
||||||
|
\\test "comptime" {
|
||||||
|
\\ const av3 = comptime a();
|
||||||
|
\\ const av4 = comptime blk: {
|
||||||
|
\\ var res = a();
|
||||||
|
\\ res *= a();
|
||||||
|
\\ break :blk res;
|
||||||
|
\\ };
|
||||||
|
\\
|
||||||
|
\\ comptime var i = 0;
|
||||||
\\ comptime {
|
\\ comptime {
|
||||||
\\ bar();
|
\\ i = a();
|
||||||
|
\\ i += b(i);
|
||||||
\\ }
|
\\ }
|
||||||
\\}
|
\\}
|
||||||
\\
|
\\
|
||||||
|
|||||||
Reference in New Issue
Block a user