1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:27:45 +00:00

LibJS: Disallow negative set record sizes

This is a normative change in the Set Methods proposal. See:
4155e6e
This commit is contained in:
Timothy Flynn 2023-07-18 07:00:14 -04:00 committed by Linus Groh
parent ac124fbaae
commit 31e555aaa5
8 changed files with 65 additions and 5 deletions

View file

@ -1,3 +1,11 @@
describe("errors", () => {
test("called with negative size", () => {
expect(() => {
new Set().difference({ size: -1 });
}).toThrowWithMessage(RangeError, "size must not be negative");
});
});
test("basic functionality", () => {
expect(Set.prototype.difference).toHaveLength(1);

View file

@ -1,3 +1,11 @@
describe("errors", () => {
test("called with negative size", () => {
expect(() => {
new Set().intersection({ size: -1 });
}).toThrowWithMessage(RangeError, "size must not be negative");
});
});
test("basic functionality", () => {
expect(Set.prototype.intersection).toHaveLength(1);

View file

@ -1,3 +1,11 @@
describe("errors", () => {
test("called with negative size", () => {
expect(() => {
new Set().isDisjointFrom({ size: -1 });
}).toThrowWithMessage(RangeError, "size must not be negative");
});
});
test("basic functionality", () => {
expect(Set.prototype.isDisjointFrom).toHaveLength(1);

View file

@ -1,3 +1,11 @@
describe("errors", () => {
test("called with negative size", () => {
expect(() => {
new Set().isSubsetOf({ size: -1 });
}).toThrowWithMessage(RangeError, "size must not be negative");
});
});
test("basic functionality", () => {
expect(Set.prototype.isSubsetOf).toHaveLength(1);

View file

@ -1,3 +1,11 @@
describe("errors", () => {
test("called with negative size", () => {
expect(() => {
new Set().isSupersetOf({ size: -1 });
}).toThrowWithMessage(RangeError, "size must not be negative");
});
});
test("basic functionality", () => {
expect(Set.prototype.isSupersetOf).toHaveLength(1);

View file

@ -1,3 +1,11 @@
describe("errors", () => {
test("called with negative size", () => {
expect(() => {
new Set().symmetricDifference({ size: -1 });
}).toThrowWithMessage(RangeError, "size must not be negative");
});
});
test("basic functionality", () => {
expect(Set.prototype.symmetricDifference).toHaveLength(1);

View file

@ -1,3 +1,11 @@
describe("errors", () => {
test("called with negative size", () => {
expect(() => {
new Set().union({ size: -1 });
}).toThrowWithMessage(RangeError, "size must not be negative");
});
});
test("basic functionality", () => {
expect(Set.prototype.union).toHaveLength(1);