diff options
author | 2022-08-06 17:32:32 +0800 | |
---|---|---|
committer | 2022-08-06 02:32:32 -0700 | |
commit | b8993dbd780d4afd5ef9f7d86fe931aa651babe6 (patch) | |
tree | fcb36bd6605930ca377517cf14660fecd952375d /src | |
parent | c94091d8b10a8fc979fbc62d06aa9526df5f7d8b (diff) | |
download | bun-b8993dbd780d4afd5ef9f7d86fe931aa651babe6.tar.gz bun-b8993dbd780d4afd5ef9f7d86fe931aa651babe6.tar.zst bun-b8993dbd780d4afd5ef9f7d86fe931aa651babe6.zip |
[wiptest] fix calling toBe in describe (#1000)
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/test/jest.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 7922c4940..6cbfe3226 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -365,6 +365,16 @@ pub const Expect = struct { ); return js.JSValueMakeUndefined(ctx); } + if (this.scope.tests.items.len <= this.test_id) { + JSC.JSError( + getAllocator(ctx), + ".toBe() called in wrong scope", + .{}, + ctx, + exception, + ); + return js.JSValueMakeUndefined(ctx); + } this.scope.tests.items[this.test_id].counter.actual += 1; const left = JSValue.fromRef(arguments[0]); left.ensureStillAlive(); @@ -418,6 +428,16 @@ pub const Expect = struct { ); return js.JSValueMakeUndefined(ctx); } + if (this.scope.tests.items.len <= this.test_id) { + JSC.JSError( + getAllocator(ctx), + ".toHaveLength() called in wrong scope", + .{}, + ctx, + exception, + ); + return js.JSValueMakeUndefined(ctx); + } this.scope.tests.items[this.test_id].counter.actual += 1; const expected = JSC.JSValue.fromRef(arguments[0]).toU32(); |