authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-11 21:20:50+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-11 21:20:50+03:00
log1a989ba39dbf2b718df7cc9792b6abaac7f5986d
tree96499d37103186eea8c885af473268eebbac42cf
parente85fe13e44b1e2957b9d90e19c171fdfa8cb5505
signaturelock-open Commit is signed but in an unrecognized format.

fix parser tests and add test for anytype conversion


1 files changed, 21 insertions(+), 5 deletions(-)

lib/std/zig/parser_test.zig+21-5
...@@ -422,10 +422,10 @@ test "zig fmt: asm expression with comptime content" {...@@ -422,10 +422,10 @@ test "zig fmt: asm expression with comptime content" {
422 );422 );
423}423}
424424
425test "zig fmt: var struct field" {425test "zig fmt: anytype struct field" {
426 try testCanonical(426 try testCanonical(
427 \\pub const Pointer = struct {427 \\pub const Pointer = struct {
428 \\ sentinel: var,428 \\ sentinel: anytype,
429 \\};429 \\};
430 \\430 \\
431 );431 );
...@@ -1932,7 +1932,7 @@ test "zig fmt: preserve spacing" {...@@ -1932,7 +1932,7 @@ test "zig fmt: preserve spacing" {
1932test "zig fmt: return types" {1932test "zig fmt: return types" {
1933 try testCanonical(1933 try testCanonical(
1934 \\pub fn main() !void {}1934 \\pub fn main() !void {}
1935 \\pub fn main() var {}1935 \\pub fn main() anytype {}
1936 \\pub fn main() i32 {}1936 \\pub fn main() i32 {}
1937 \\1937 \\
1938 );1938 );
...@@ -2140,9 +2140,9 @@ test "zig fmt: call expression" {...@@ -2140,9 +2140,9 @@ test "zig fmt: call expression" {
2140 );2140 );
2141}2141}
21422142
2143test "zig fmt: var type" {2143test "zig fmt: anytype type" {
2144 try testCanonical(2144 try testCanonical(
2145 \\fn print(args: var) var {}2145 \\fn print(args: anytype) anytype {}
2146 \\2146 \\
2147 );2147 );
2148}2148}
...@@ -3180,6 +3180,22 @@ test "zig fmt: convert extern fn proto into callconv(.C)" {...@@ -3180,6 +3180,22 @@ test "zig fmt: convert extern fn proto into callconv(.C)" {
3180 );3180 );
3181}3181}
31823182
3183test "zig fmt: convert var to anytype" {
3184 // TODO remove in next release cycle
3185 try testTransform(
3186 \\pub fn main(
3187 \\ a: var,
3188 \\ bar: var,
3189 \\) void {}
3190 ,
3191 \\pub fn main(
3192 \\ a: anytype,
3193 \\ bar: anytype,
3194 \\) void {}
3195 \\
3196 );
3197}
3198
3183const std = @import("std");3199const std = @import("std");
3184const mem = std.mem;3200const mem = std.mem;
3185const warn = std.debug.warn;3201const warn = std.debug.warn;