diff --git a/parser_test.zig b/parser_test.zig index de26b011f2..1f513eb3bb 100644 --- a/parser_test.zig +++ b/parser_test.zig @@ -545,6 +545,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( \\ @@ -4557,15 +4558,6 @@ 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 "zig fmt: remove newlines surrounding doc comment between members within container decl (1)" { try testTransform( \\const Foo = struct { @@ -4588,6 +4580,7 @@ test "zig fmt: remove newlines surrounding doc comment between members within co \\ ); } + test "zig fmt: remove newlines surrounding doc comment between members within container decl (2)" { try testTransform( \\const Foo = struct { @@ -4609,6 +4602,7 @@ test "zig fmt: remove newlines surrounding doc comment between members within co \\ ); } + test "zig fmt: remove newlines surrounding doc comment within container decl" { try testTransform( \\const Foo = struct { @@ -4627,6 +4621,7 @@ test "zig fmt: remove newlines surrounding doc comment within container decl" { \\ ); } + test "zig fmt: comments with CRLF line endings" { try testTransform("" ++ "//! Top-level doc comment\r\n" ++ @@ -4648,6 +4643,7 @@ test "zig fmt: comments with CRLF line endings" { \\ ); } + test "zig fmt: else comptime expr" { try testCanonical( \\comptime { @@ -4662,6 +4658,7 @@ test "zig fmt: else comptime expr" { \\ ); } + test "zig fmt: integer literals with underscore separators" { try testTransform( \\const @@ -4674,6 +4671,7 @@ test "zig fmt: integer literals with underscore separators" { \\ ); } + test "zig fmt: hex literals with underscore separators" { try testTransform( \\pub fn orMask(a: [ 1_000 ]u64, b: [ 1_000] u64) [1_000]u64 { @@ -4696,6 +4694,16 @@ test "zig fmt: hex literals with underscore separators" { \\ ); } + +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: hexadecimal float literals with underscore separators" { try testTransform( \\pub fn main() void { @@ -4712,12 +4720,14 @@ test "zig fmt: hexadecimal float literals with underscore separators" { \\ ); } + test "zig fmt: C var args" { try testCanonical( \\pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; \\ ); } + test "zig fmt: Only indent multiline string literals in function calls" { try testCanonical( \\test "zig fmt:" { @@ -4734,6 +4744,7 @@ test "zig fmt: Only indent multiline string literals in function calls" { \\ ); } + test "zig fmt: Don't add extra newline after if" { try testCanonical( \\pub fn atomicSymLink(allocator: Allocator, existing_path: []const u8, new_path: []const u8) !void { @@ -4744,6 +4755,7 @@ test "zig fmt: Don't add extra newline after if" { \\ ); } + test "zig fmt: comments in ternary ifs" { try testCanonical( \\const x = if (true) { @@ -4762,6 +4774,7 @@ test "zig fmt: comments in ternary ifs" { \\ ); } + test "zig fmt: while statement in blockless if" { try testCanonical( \\pub fn main() void { @@ -4775,6 +4788,7 @@ test "zig fmt: while statement in blockless if" { \\ ); } + test "zig fmt: test comments in field access chain" { try testCanonical( \\pub const str = struct {