mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Make expected runtime runner value optional to skip assertion
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
This commit is contained in:
@@ -64,7 +64,7 @@ pub fn Runner(comptime State: type, comptime Global: type, comptime types: anyty
|
|||||||
}
|
}
|
||||||
|
|
||||||
const RunOpts = struct {};
|
const RunOpts = struct {};
|
||||||
pub const Case = std.meta.Tuple(&.{ []const u8, []const u8 });
|
pub const Case = std.meta.Tuple(&.{ []const u8, ?[]const u8 });
|
||||||
pub fn testCases(self: *Self, cases: []const Case, _: RunOpts) !void {
|
pub fn testCases(self: *Self, cases: []const Case, _: RunOpts) !void {
|
||||||
for (cases, 0..) |case, i| {
|
for (cases, 0..) |case, i| {
|
||||||
var try_catch: Env.TryCatch = undefined;
|
var try_catch: Env.TryCatch = undefined;
|
||||||
@@ -82,18 +82,22 @@ pub fn Runner(comptime State: type, comptime Global: type, comptime types: anyty
|
|||||||
return err;
|
return err;
|
||||||
};
|
};
|
||||||
|
|
||||||
const actual = try value.toString(allocator);
|
if (case.@"1") |expected| {
|
||||||
defer allocator.free(actual);
|
const actual = try value.toString(allocator);
|
||||||
if (std.mem.eql(u8, case.@"1", actual) == false) {
|
defer allocator.free(actual);
|
||||||
std.debug.print("Expected:\n{s}\n\nGot:\n{s}\n\nCase: {d}\n{s}\n", .{ case.@"1", actual, i + 1, case.@"0" });
|
if (std.mem.eql(u8, expected, actual) == false) {
|
||||||
return error.UnexpectedResult;
|
std.debug.print("Expected:\n{s}\n\nGot:\n{s}\n\nCase: {d}\n{s}\n", .{ expected, actual, i + 1, case.@"0" });
|
||||||
|
return error.UnexpectedResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn isExpectedTypeError(expected: []const u8, msg: []const u8) bool {
|
fn isExpectedTypeError(expected_: ?[]const u8, msg: []const u8) bool {
|
||||||
|
const expected = expected_ orelse return false;
|
||||||
|
|
||||||
if (!std.mem.eql(u8, expected, "TypeError")) {
|
if (!std.mem.eql(u8, expected, "TypeError")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user