@@ -64,7 +64,7 @@ pub fn Runner(comptime State: type, comptime Global: type, comptime types: anyty
6464 }
6565
6666 const RunOpts = struct {};
67- pub const Case = std .meta .Tuple (&.{ []const u8 , []const u8 });
67+ pub const Case = std .meta .Tuple (&.{ []const u8 , ? []const u8 });
6868 pub fn testCases (self : * Self , cases : []const Case , _ : RunOpts ) ! void {
6969 for (cases , 0.. ) | case , i | {
7070 var try_catch : Env.TryCatch = undefined ;
@@ -82,18 +82,22 @@ pub fn Runner(comptime State: type, comptime Global: type, comptime types: anyty
8282 return err ;
8383 };
8484
85- const actual = try value .toString (allocator );
86- defer allocator .free (actual );
87- if (std .mem .eql (u8 , case .@"1" , actual ) == false ) {
88- std .debug .print ("Expected:\n {s}\n\n Got:\n {s}\n\n Case: {d}\n {s}\n " , .{ case .@"1" , actual , i + 1 , case .@"0" });
89- return error .UnexpectedResult ;
85+ if (case .@"1" ) | expected | {
86+ const actual = try value .toString (allocator );
87+ defer allocator .free (actual );
88+ if (std .mem .eql (u8 , expected , actual ) == false ) {
89+ std .debug .print ("Expected:\n {s}\n\n Got:\n {s}\n\n Case: {d}\n {s}\n " , .{ expected , actual , i + 1 , case .@"0" });
90+ return error .UnexpectedResult ;
91+ }
9092 }
9193 }
9294 }
9395 };
9496}
9597
96- fn isExpectedTypeError (expected : []const u8 , msg : []const u8 ) bool {
98+ fn isExpectedTypeError (expected_ : ? []const u8 , msg : []const u8 ) bool {
99+ const expected = expected_ orelse return false ;
100+
97101 if (! std .mem .eql (u8 , expected , "TypeError" )) {
98102 return false ;
99103 }
0 commit comments