[wiptest] fix calling toBe in describe (#1000)

This commit is contained in:
Zilin Zhu
2022-08-06 17:32:32 +08:00
committed by GitHub
parent c94091d8b1
commit b8993dbd78

View File

@@ -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();