authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-09 00:03:08-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-09 00:05:21-05:00
logd571fad20eac23cadf6116742ad4abab5ed281e5
tree98cd82274f1fad58954456af9d5ff907a640965d
parent03396b3caac1ab76dae5f672800aafb176d46cad
signature Commit is signed but in an unrecognized format.

update tests to new format API


3 files changed, 41 insertions(+), 41 deletions(-)

lib/std/special/compiler_rt/truncXfYf2_test.zig+1-1
......@@ -217,7 +217,7 @@ fn test__truncdfsf2(a: f64, expected: u32) void {
217217 }
218218 }
219219
220 @import("std").debug.warn("got 0x{x} wanted 0x{x}\n", rep, expected);
220 @import("std").debug.warn("got 0x{x} wanted 0x{x}\n", .{ rep, expected });
221221
222222 @panic("__trunctfsf2 test failure");
223223}
test/compare_output.zig+33-33
......@@ -20,7 +20,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
2020 \\pub fn main() void {
2121 \\ privateFunction();
2222 \\ const stdout = &getStdOut().outStream().stream;
23 \\ stdout.print("OK 2\n") catch unreachable;
23 \\ stdout.print("OK 2\n", .{}) catch unreachable;
2424 \\}
2525 \\
2626 \\fn privateFunction() void {
......@@ -35,7 +35,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
3535 \\// but it's private so it should be OK
3636 \\fn privateFunction() void {
3737 \\ const stdout = &getStdOut().outStream().stream;
38 \\ stdout.print("OK 1\n") catch unreachable;
38 \\ stdout.print("OK 1\n", .{}) catch unreachable;
3939 \\}
4040 \\
4141 \\pub fn printText() void {
......@@ -61,7 +61,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
6161 \\usingnamespace @import("std").io;
6262 \\pub fn foo_function() void {
6363 \\ const stdout = &getStdOut().outStream().stream;
64 \\ stdout.print("OK\n") catch unreachable;
64 \\ stdout.print("OK\n", .{}) catch unreachable;
6565 \\}
6666 );
6767
......@@ -72,7 +72,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
7272 \\pub fn bar_function() void {
7373 \\ if (foo_function()) {
7474 \\ const stdout = &getStdOut().outStream().stream;
75 \\ stdout.print("OK\n") catch unreachable;
75 \\ stdout.print("OK\n", .{}) catch unreachable;
7676 \\ }
7777 \\}
7878 );
......@@ -104,7 +104,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
104104 \\
105105 \\pub fn ok() void {
106106 \\ const stdout = &io.getStdOut().outStream().stream;
107 \\ stdout.print(b_text) catch unreachable;
107 \\ stdout.print(b_text, .{}) catch unreachable;
108108 \\}
109109 );
110110
......@@ -122,7 +122,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
122122 \\
123123 \\pub fn main() void {
124124 \\ const stdout = &io.getStdOut().outStream().stream;
125 \\ stdout.print("Hello, world!\n{d:4} {x:3} {c}\n", @as(u32, 12), @as(u16, 0x12), @as(u8, 'a')) catch unreachable;
125 \\ stdout.print("Hello, world!\n{d:4} {x:3} {c}\n", .{@as(u32, 12), @as(u16, 0x12), @as(u8, 'a')}) catch unreachable;
126126 \\}
127127 , "Hello, world!\n 12 12 a\n");
128128
......@@ -265,7 +265,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
265265 \\}
266266 \\fn print_ok(val: @typeOf(x)) @typeOf(foo) {
267267 \\ const stdout = &io.getStdOut().outStream().stream;
268 \\ stdout.print("OK\n") catch unreachable;
268 \\ stdout.print("OK\n", .{}) catch unreachable;
269269 \\ return 0;
270270 \\}
271271 \\const foo : i32 = 0;
......@@ -348,12 +348,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
348348 \\ const foo = Foo {.field1 = bar,};
349349 \\ const stdout = &io.getStdOut().outStream().stream;
350350 \\ if (!foo.method()) {
351 \\ stdout.print("BAD\n") catch unreachable;
351 \\ stdout.print("BAD\n", .{}) catch unreachable;
352352 \\ }
353353 \\ if (!bar.method()) {
354 \\ stdout.print("BAD\n") catch unreachable;
354 \\ stdout.print("BAD\n", .{}) catch unreachable;
355355 \\ }
356 \\ stdout.print("OK\n") catch unreachable;
356 \\ stdout.print("OK\n", .{}) catch unreachable;
357357 \\}
358358 , "OK\n");
359359
......@@ -361,11 +361,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
361361 \\const io = @import("std").io;
362362 \\pub fn main() void {
363363 \\ const stdout = &io.getStdOut().outStream().stream;
364 \\ stdout.print("before\n") catch unreachable;
365 \\ defer stdout.print("defer1\n") catch unreachable;
366 \\ defer stdout.print("defer2\n") catch unreachable;
367 \\ defer stdout.print("defer3\n") catch unreachable;
368 \\ stdout.print("after\n") catch unreachable;
364 \\ stdout.print("before\n", .{}) catch unreachable;
365 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
366 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
367 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
368 \\ stdout.print("after\n", .{}) catch unreachable;
369369 \\}
370370 , "before\nafter\ndefer3\ndefer2\ndefer1\n");
371371
......@@ -374,13 +374,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
374374 \\const os = @import("std").os;
375375 \\pub fn main() void {
376376 \\ const stdout = &io.getStdOut().outStream().stream;
377 \\ stdout.print("before\n") catch unreachable;
378 \\ defer stdout.print("defer1\n") catch unreachable;
379 \\ defer stdout.print("defer2\n") catch unreachable;
377 \\ stdout.print("before\n", .{}) catch unreachable;
378 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
379 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
380380 \\ var args_it = @import("std").process.args();
381381 \\ if (args_it.skip() and !args_it.skip()) return;
382 \\ defer stdout.print("defer3\n") catch unreachable;
383 \\ stdout.print("after\n") catch unreachable;
382 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
383 \\ stdout.print("after\n", .{}) catch unreachable;
384384 \\}
385385 , "before\ndefer2\ndefer1\n");
386386
......@@ -391,12 +391,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
391391 \\}
392392 \\fn do_test() !void {
393393 \\ const stdout = &io.getStdOut().outStream().stream;
394 \\ stdout.print("before\n") catch unreachable;
395 \\ defer stdout.print("defer1\n") catch unreachable;
396 \\ errdefer stdout.print("deferErr\n") catch unreachable;
394 \\ stdout.print("before\n", .{}) catch unreachable;
395 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
396 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
397397 \\ try its_gonna_fail();
398 \\ defer stdout.print("defer3\n") catch unreachable;
399 \\ stdout.print("after\n") catch unreachable;
398 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
399 \\ stdout.print("after\n", .{}) catch unreachable;
400400 \\}
401401 \\fn its_gonna_fail() !void {
402402 \\ return error.IToldYouItWouldFail;
......@@ -410,12 +410,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
410410 \\}
411411 \\fn do_test() !void {
412412 \\ const stdout = &io.getStdOut().outStream().stream;
413 \\ stdout.print("before\n") catch unreachable;
414 \\ defer stdout.print("defer1\n") catch unreachable;
415 \\ errdefer stdout.print("deferErr\n") catch unreachable;
413 \\ stdout.print("before\n", .{}) catch unreachable;
414 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
415 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
416416 \\ try its_gonna_pass();
417 \\ defer stdout.print("defer3\n") catch unreachable;
418 \\ stdout.print("after\n") catch unreachable;
417 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
418 \\ stdout.print("after\n", .{}) catch unreachable;
419419 \\}
420420 \\fn its_gonna_pass() anyerror!void { }
421421 , "before\nafter\ndefer3\ndefer1\n");
......@@ -427,7 +427,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
427427 \\
428428 \\pub fn main() void {
429429 \\ const stdout = &io.getStdOut().outStream().stream;
430 \\ stdout.print(foo_txt) catch unreachable;
430 \\ stdout.print(foo_txt, .{}) catch unreachable;
431431 \\}
432432 , "1234\nabcd\n");
433433
......@@ -452,7 +452,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
452452 \\ _ = args_it.skip();
453453 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
454454 \\ const arg = try arg_or_err;
455 \\ try stdout.print("{}: {}\n", index, arg);
455 \\ try stdout.print("{}: {}\n", .{index, arg});
456456 \\ }
457457 \\}
458458 ,
......@@ -493,7 +493,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
493493 \\ _ = args_it.skip();
494494 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
495495 \\ const arg = try arg_or_err;
496 \\ try stdout.print("{}: {}\n", index, arg);
496 \\ try stdout.print("{}: {}\n", .{index, arg});
497497 \\ }
498498 \\}
499499 ,
test/standalone/guess_number/main.zig+7-7
......@@ -6,7 +6,7 @@ const fmt = std.fmt;
66pub fn main() !void {
77 const stdout = &io.getStdOut().outStream().stream;
88
9 try stdout.print("Welcome to the Guess Number Game in Zig.\n");
9 try stdout.print("Welcome to the Guess Number Game in Zig.\n", .{});
1010
1111 var seed_bytes: [@sizeOf(u64)]u8 = undefined;
1212 std.crypto.randomBytes(seed_bytes[0..]) catch |err| {
......@@ -19,27 +19,27 @@ pub fn main() !void {
1919 const answer = prng.random.range(u8, 0, 100) + 1;
2020
2121 while (true) {
22 try stdout.print("\nGuess a number between 1 and 100: ");
22 try stdout.print("\nGuess a number between 1 and 100: ", .{});
2323 var line_buf: [20]u8 = undefined;
2424
2525 const line = io.readLineSlice(line_buf[0..]) catch |err| switch (err) {
2626 error.OutOfMemory => {
27 try stdout.print("Input too long.\n");
27 try stdout.print("Input too long.\n", .{});
2828 continue;
2929 },
3030 else => return err,
3131 };
3232
3333 const guess = fmt.parseUnsigned(u8, line, 10) catch {
34 try stdout.print("Invalid number.\n");
34 try stdout.print("Invalid number.\n", .{});
3535 continue;
3636 };
3737 if (guess > answer) {
38 try stdout.print("Guess lower.\n");
38 try stdout.print("Guess lower.\n", .{});
3939 } else if (guess < answer) {
40 try stdout.print("Guess higher.\n");
40 try stdout.print("Guess higher.\n", .{});
4141 } else {
42 try stdout.print("You win!\n");
42 try stdout.print("You win!\n", .{});
4343 return;
4444 }
4545 }