fix parser tests and add test for anytype conversion

This commit is contained in:
Vexu 2020-07-11 21:20:50 +03:00
parent e85fe13e44
commit 1a989ba39d
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC

View File

@ -422,10 +422,10 @@ test "zig fmt: asm expression with comptime content" {
); );
} }
test "zig fmt: var struct field" { test "zig fmt: anytype struct field" {
try testCanonical( try testCanonical(
\\pub const Pointer = struct { \\pub const Pointer = struct {
\\ sentinel: var, \\ sentinel: anytype,
\\}; \\};
\\ \\
); );
@ -1932,7 +1932,7 @@ test "zig fmt: preserve spacing" {
test "zig fmt: return types" { test "zig fmt: return types" {
try testCanonical( try testCanonical(
\\pub fn main() !void {} \\pub fn main() !void {}
\\pub fn main() var {} \\pub fn main() anytype {}
\\pub fn main() i32 {} \\pub fn main() i32 {}
\\ \\
); );
@ -2140,9 +2140,9 @@ test "zig fmt: call expression" {
); );
} }
test "zig fmt: var type" { test "zig fmt: anytype type" {
try testCanonical( try testCanonical(
\\fn print(args: var) var {} \\fn print(args: anytype) anytype {}
\\ \\
); );
} }
@ -3180,6 +3180,22 @@ test "zig fmt: convert extern fn proto into callconv(.C)" {
); );
} }
test "zig fmt: convert var to anytype" {
// TODO remove in next release cycle
try testTransform(
\\pub fn main(
\\ a: var,
\\ bar: var,
\\) void {}
,
\\pub fn main(
\\ a: anytype,
\\ bar: anytype,
\\) void {}
\\
);
}
const std = @import("std"); const std = @import("std");
const mem = std.mem; const mem = std.mem;
const warn = std.debug.warn; const warn = std.debug.warn;