mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-04-05 04:06:08 +00:00
LibJS/Tests: Use hasOwnProperty() for duplicate test check
The current way of doing this would also traverse the prototype chain, and therefore yield false positive results for keys like "toString".
This commit is contained in:
@@ -53,8 +53,7 @@ describe("ability to work with generic non-array objects", () => {
|
||||
);
|
||||
});
|
||||
|
||||
// FIXME: test-js asserts when this is just called "toString" ಠ_ಠ
|
||||
test("toString (FIXME)", () => {
|
||||
test("toString", () => {
|
||||
expect(Array.prototype.toString.call({})).toBe("[object Object]");
|
||||
expect(Array.prototype.toString.call({ join: "foo" })).toBe("[object Object]");
|
||||
expect(Array.prototype.toString.call({ join: () => "foo" })).toBe("foo");
|
||||
|
||||
@@ -431,7 +431,7 @@ class ExpectationError extends Error {
|
||||
if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {};
|
||||
|
||||
const suite = __TestResults__[suiteMessage];
|
||||
if (suite[message]) {
|
||||
if (Object.prototype.hasOwnProperty.call(suite, message)) {
|
||||
suite[message] = {
|
||||
result: "fail",
|
||||
details: "Another test with the same message did already run",
|
||||
@@ -459,7 +459,13 @@ class ExpectationError extends Error {
|
||||
if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {};
|
||||
|
||||
const suite = __TestResults__[suiteMessage];
|
||||
if (suite[message]) throw new Error("Duplicate test name: " + message);
|
||||
if (Object.prototype.hasOwnProperty.call(suite, message)) {
|
||||
suite[message] = {
|
||||
result: "fail",
|
||||
details: "Another test with the same message did already run",
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
suite[message] = {
|
||||
result: "skip",
|
||||
|
||||
Reference in New Issue
Block a user