Skip to content

Commit 905eb1a

Browse files
karlseguinsjorsdonkers
authored andcommitted
Make expected runner value optional to skip assertion
1 parent 7862fc7 commit 905eb1a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/testing.zig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ pub const JsRunner = struct {
455455
}
456456

457457
const RunOpts = struct {};
458-
pub const Case = std.meta.Tuple(&.{ []const u8, []const u8 });
458+
pub const Case = std.meta.Tuple(&.{ []const u8, ?[]const u8 });
459459
pub fn testCases(self: *JsRunner, cases: []const Case, _: RunOpts) !void {
460460
const start = try std.time.Instant.now();
461461

@@ -473,10 +473,12 @@ pub const JsRunner = struct {
473473
try self.loop.run();
474474
@import("root").js_runner_duration += std.time.Instant.since(try std.time.Instant.now(), start);
475475

476-
const actual = try value.toString(self.arena);
477-
if (std.mem.eql(u8, case.@"1", actual) == false) {
478-
std.debug.print("Expected:\n{s}\n\nGot:\n{s}\n\nCase: {d}\n{s}\n", .{ case.@"1", actual, i + 1, case.@"0" });
479-
return error.UnexpectedResult;
476+
if (case.@"1") |expected| {
477+
const actual = try value.toString(self.arena);
478+
if (std.mem.eql(u8, expected, actual) == false) {
479+
std.debug.print("Expected:\n{s}\n\nGot:\n{s}\n\nCase: {d}\n{s}\n", .{ expected, actual, i + 1, case.@"0" });
480+
return error.UnexpectedResult;
481+
}
480482
}
481483
}
482484
}

0 commit comments

Comments
 (0)