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 {...@@ -217,7 +217,7 @@ fn test__truncdfsf2(a: f64, expected: u32) void {
217 }217 }
218 }218 }
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
222 @panic("__trunctfsf2 test failure");222 @panic("__trunctfsf2 test failure");
223}223}
test/compare_output.zig+33-33
...@@ -20,7 +20,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -20,7 +20,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
20 \\pub fn main() void {20 \\pub fn main() void {
21 \\ privateFunction();21 \\ privateFunction();
22 \\ const stdout = &getStdOut().outStream().stream;22 \\ const stdout = &getStdOut().outStream().stream;
23 \\ stdout.print("OK 2\n") catch unreachable;23 \\ stdout.print("OK 2\n", .{}) catch unreachable;
24 \\}24 \\}
25 \\25 \\
26 \\fn privateFunction() void {26 \\fn privateFunction() void {
...@@ -35,7 +35,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -35,7 +35,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
35 \\// but it's private so it should be OK35 \\// but it's private so it should be OK
36 \\fn privateFunction() void {36 \\fn privateFunction() void {
37 \\ const stdout = &getStdOut().outStream().stream;37 \\ const stdout = &getStdOut().outStream().stream;
38 \\ stdout.print("OK 1\n") catch unreachable;38 \\ stdout.print("OK 1\n", .{}) catch unreachable;
39 \\}39 \\}
40 \\40 \\
41 \\pub fn printText() void {41 \\pub fn printText() void {
...@@ -61,7 +61,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -61,7 +61,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
61 \\usingnamespace @import("std").io;61 \\usingnamespace @import("std").io;
62 \\pub fn foo_function() void {62 \\pub fn foo_function() void {
63 \\ const stdout = &getStdOut().outStream().stream;63 \\ const stdout = &getStdOut().outStream().stream;
64 \\ stdout.print("OK\n") catch unreachable;64 \\ stdout.print("OK\n", .{}) catch unreachable;
65 \\}65 \\}
66 );66 );
6767
...@@ -72,7 +72,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -72,7 +72,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
72 \\pub fn bar_function() void {72 \\pub fn bar_function() void {
73 \\ if (foo_function()) {73 \\ if (foo_function()) {
74 \\ const stdout = &getStdOut().outStream().stream;74 \\ const stdout = &getStdOut().outStream().stream;
75 \\ stdout.print("OK\n") catch unreachable;75 \\ stdout.print("OK\n", .{}) catch unreachable;
76 \\ }76 \\ }
77 \\}77 \\}
78 );78 );
...@@ -104,7 +104,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -104,7 +104,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
104 \\104 \\
105 \\pub fn ok() void {105 \\pub fn ok() void {
106 \\ const stdout = &io.getStdOut().outStream().stream;106 \\ const stdout = &io.getStdOut().outStream().stream;
107 \\ stdout.print(b_text) catch unreachable;107 \\ stdout.print(b_text, .{}) catch unreachable;
108 \\}108 \\}
109 );109 );
110110
...@@ -122,7 +122,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -122,7 +122,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
122 \\122 \\
123 \\pub fn main() void {123 \\pub fn main() void {
124 \\ const stdout = &io.getStdOut().outStream().stream;124 \\ 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;
126 \\}126 \\}
127 , "Hello, world!\n 12 12 a\n");127 , "Hello, world!\n 12 12 a\n");
128128
...@@ -265,7 +265,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -265,7 +265,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
265 \\}265 \\}
266 \\fn print_ok(val: @typeOf(x)) @typeOf(foo) {266 \\fn print_ok(val: @typeOf(x)) @typeOf(foo) {
267 \\ const stdout = &io.getStdOut().outStream().stream;267 \\ const stdout = &io.getStdOut().outStream().stream;
268 \\ stdout.print("OK\n") catch unreachable;268 \\ stdout.print("OK\n", .{}) catch unreachable;
269 \\ return 0;269 \\ return 0;
270 \\}270 \\}
271 \\const foo : i32 = 0;271 \\const foo : i32 = 0;
...@@ -348,12 +348,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -348,12 +348,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
348 \\ const foo = Foo {.field1 = bar,};348 \\ const foo = Foo {.field1 = bar,};
349 \\ const stdout = &io.getStdOut().outStream().stream;349 \\ const stdout = &io.getStdOut().outStream().stream;
350 \\ if (!foo.method()) {350 \\ if (!foo.method()) {
351 \\ stdout.print("BAD\n") catch unreachable;351 \\ stdout.print("BAD\n", .{}) catch unreachable;
352 \\ }352 \\ }
353 \\ if (!bar.method()) {353 \\ if (!bar.method()) {
354 \\ stdout.print("BAD\n") catch unreachable;354 \\ stdout.print("BAD\n", .{}) catch unreachable;
355 \\ }355 \\ }
356 \\ stdout.print("OK\n") catch unreachable;356 \\ stdout.print("OK\n", .{}) catch unreachable;
357 \\}357 \\}
358 , "OK\n");358 , "OK\n");
359359
...@@ -361,11 +361,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -361,11 +361,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
361 \\const io = @import("std").io;361 \\const io = @import("std").io;
362 \\pub fn main() void {362 \\pub fn main() void {
363 \\ const stdout = &io.getStdOut().outStream().stream;363 \\ const stdout = &io.getStdOut().outStream().stream;
364 \\ stdout.print("before\n") catch unreachable;364 \\ stdout.print("before\n", .{}) catch unreachable;
365 \\ defer stdout.print("defer1\n") catch unreachable;365 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
366 \\ defer stdout.print("defer2\n") catch unreachable;366 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
367 \\ defer stdout.print("defer3\n") catch unreachable;367 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
368 \\ stdout.print("after\n") catch unreachable;368 \\ stdout.print("after\n", .{}) catch unreachable;
369 \\}369 \\}
370 , "before\nafter\ndefer3\ndefer2\ndefer1\n");370 , "before\nafter\ndefer3\ndefer2\ndefer1\n");
371371
...@@ -374,13 +374,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -374,13 +374,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
374 \\const os = @import("std").os;374 \\const os = @import("std").os;
375 \\pub fn main() void {375 \\pub fn main() void {
376 \\ const stdout = &io.getStdOut().outStream().stream;376 \\ const stdout = &io.getStdOut().outStream().stream;
377 \\ stdout.print("before\n") catch unreachable;377 \\ stdout.print("before\n", .{}) catch unreachable;
378 \\ defer stdout.print("defer1\n") catch unreachable;378 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
379 \\ defer stdout.print("defer2\n") catch unreachable;379 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
380 \\ var args_it = @import("std").process.args();380 \\ var args_it = @import("std").process.args();
381 \\ if (args_it.skip() and !args_it.skip()) return;381 \\ if (args_it.skip() and !args_it.skip()) return;
382 \\ defer stdout.print("defer3\n") catch unreachable;382 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
383 \\ stdout.print("after\n") catch unreachable;383 \\ stdout.print("after\n", .{}) catch unreachable;
384 \\}384 \\}
385 , "before\ndefer2\ndefer1\n");385 , "before\ndefer2\ndefer1\n");
386386
...@@ -391,12 +391,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -391,12 +391,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
391 \\}391 \\}
392 \\fn do_test() !void {392 \\fn do_test() !void {
393 \\ const stdout = &io.getStdOut().outStream().stream;393 \\ const stdout = &io.getStdOut().outStream().stream;
394 \\ stdout.print("before\n") catch unreachable;394 \\ stdout.print("before\n", .{}) catch unreachable;
395 \\ defer stdout.print("defer1\n") catch unreachable;395 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
396 \\ errdefer stdout.print("deferErr\n") catch unreachable;396 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
397 \\ try its_gonna_fail();397 \\ try its_gonna_fail();
398 \\ defer stdout.print("defer3\n") catch unreachable;398 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
399 \\ stdout.print("after\n") catch unreachable;399 \\ stdout.print("after\n", .{}) catch unreachable;
400 \\}400 \\}
401 \\fn its_gonna_fail() !void {401 \\fn its_gonna_fail() !void {
402 \\ return error.IToldYouItWouldFail;402 \\ return error.IToldYouItWouldFail;
...@@ -410,12 +410,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -410,12 +410,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
410 \\}410 \\}
411 \\fn do_test() !void {411 \\fn do_test() !void {
412 \\ const stdout = &io.getStdOut().outStream().stream;412 \\ const stdout = &io.getStdOut().outStream().stream;
413 \\ stdout.print("before\n") catch unreachable;413 \\ stdout.print("before\n", .{}) catch unreachable;
414 \\ defer stdout.print("defer1\n") catch unreachable;414 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
415 \\ errdefer stdout.print("deferErr\n") catch unreachable;415 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
416 \\ try its_gonna_pass();416 \\ try its_gonna_pass();
417 \\ defer stdout.print("defer3\n") catch unreachable;417 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
418 \\ stdout.print("after\n") catch unreachable;418 \\ stdout.print("after\n", .{}) catch unreachable;
419 \\}419 \\}
420 \\fn its_gonna_pass() anyerror!void { }420 \\fn its_gonna_pass() anyerror!void { }
421 , "before\nafter\ndefer3\ndefer1\n");421 , "before\nafter\ndefer3\ndefer1\n");
...@@ -427,7 +427,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -427,7 +427,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
427 \\427 \\
428 \\pub fn main() void {428 \\pub fn main() void {
429 \\ const stdout = &io.getStdOut().outStream().stream;429 \\ const stdout = &io.getStdOut().outStream().stream;
430 \\ stdout.print(foo_txt) catch unreachable;430 \\ stdout.print(foo_txt, .{}) catch unreachable;
431 \\}431 \\}
432 , "1234\nabcd\n");432 , "1234\nabcd\n");
433433
...@@ -452,7 +452,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -452,7 +452,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
452 \\ _ = args_it.skip();452 \\ _ = args_it.skip();
453 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {453 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
454 \\ const arg = try arg_or_err;454 \\ const arg = try arg_or_err;
455 \\ try stdout.print("{}: {}\n", index, arg);455 \\ try stdout.print("{}: {}\n", .{index, arg});
456 \\ }456 \\ }
457 \\}457 \\}
458 ,458 ,
...@@ -493,7 +493,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -493,7 +493,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
493 \\ _ = args_it.skip();493 \\ _ = args_it.skip();
494 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {494 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
495 \\ const arg = try arg_or_err;495 \\ const arg = try arg_or_err;
496 \\ try stdout.print("{}: {}\n", index, arg);496 \\ try stdout.print("{}: {}\n", .{index, arg});
497 \\ }497 \\ }
498 \\}498 \\}
499 ,499 ,
test/standalone/guess_number/main.zig+7-7
...@@ -6,7 +6,7 @@ const fmt = std.fmt;...@@ -6,7 +6,7 @@ const fmt = std.fmt;
6pub fn main() !void {6pub fn main() !void {
7 const stdout = &io.getStdOut().outStream().stream;7 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
11 var seed_bytes: [@sizeOf(u64)]u8 = undefined;11 var seed_bytes: [@sizeOf(u64)]u8 = undefined;
12 std.crypto.randomBytes(seed_bytes[0..]) catch |err| {12 std.crypto.randomBytes(seed_bytes[0..]) catch |err| {
...@@ -19,27 +19,27 @@ pub fn main() !void {...@@ -19,27 +19,27 @@ pub fn main() !void {
19 const answer = prng.random.range(u8, 0, 100) + 1;19 const answer = prng.random.range(u8, 0, 100) + 1;
2020
21 while (true) {21 while (true) {
22 try stdout.print("\nGuess a number between 1 and 100: ");22 try stdout.print("\nGuess a number between 1 and 100: ", .{});
23 var line_buf: [20]u8 = undefined;23 var line_buf: [20]u8 = undefined;
2424
25 const line = io.readLineSlice(line_buf[0..]) catch |err| switch (err) {25 const line = io.readLineSlice(line_buf[0..]) catch |err| switch (err) {
26 error.OutOfMemory => {26 error.OutOfMemory => {
27 try stdout.print("Input too long.\n");27 try stdout.print("Input too long.\n", .{});
28 continue;28 continue;
29 },29 },
30 else => return err,30 else => return err,
31 };31 };
3232
33 const guess = fmt.parseUnsigned(u8, line, 10) catch {33 const guess = fmt.parseUnsigned(u8, line, 10) catch {
34 try stdout.print("Invalid number.\n");34 try stdout.print("Invalid number.\n", .{});
35 continue;35 continue;
36 };36 };
37 if (guess > answer) {37 if (guess > answer) {
38 try stdout.print("Guess lower.\n");38 try stdout.print("Guess lower.\n", .{});
39 } else if (guess < answer) {39 } else if (guess < answer) {
40 try stdout.print("Guess higher.\n");40 try stdout.print("Guess higher.\n", .{});
41 } else {41 } else {
42 try stdout.print("You win!\n");42 try stdout.print("You win!\n", .{});
43 return;43 return;
44 }44 }
45 }45 }