+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(hasProperty.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(hasProperty.name, "hasProperty");
+ });
+ });
+});
+
+describe("hasOwnProperty", () => {
+ it("[[Call]] gets whether an own property exists on the provided object", () => {
+ assertStrictEquals(
+ hasOwnProperty({ success: "etaoin" }, "success"),
+ true,
+ );
+ assertStrictEquals(hasOwnProperty({}, "hasOwnProperty"), false);
+ });
+
+ it("[[Call]] works for values coercible to objects", () => {
+ assertStrictEquals(hasOwnProperty("", "length"), true);
+ assertStrictEquals(hasOwnProperty("", "toString"), false);
+ });
+
+ it("[[Call]] throws for null and undefined", () => {
+ assertThrows(() => hasOwnProperty(null, "valueOf"));
+ assertThrows(() => hasOwnProperty(undefined, "valueOf"));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new hasOwnProperty({}, "valueOf"));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(hasOwnProperty.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(hasOwnProperty.name, "hasOwnProperty");
+ });
+ });
+});
+
+describe("isExtensibleObject", () => {
+ it("[[Call]] returns true for extensible objects", () => {
+ assertStrictEquals(isExtensibleObject({}), true);
+ });
+
+ it("[[Call]] returns false for coercible primitives", () => {
+ assertStrictEquals(isExtensibleObject(1), false);
+ assertStrictEquals(isExtensibleObject(Symbol()), false);
+ });
+
+ it("[[Call]] returns false for non·extensible objects", () => {
+ assertStrictEquals(
+ isExtensibleObject(Object.preventExtensions({})),
+ false,
+ );
+ });
+
+ it("[[Call]] returns false for null and undefined", () => {
+ assertStrictEquals(isExtensibleObject(null), false);
+ assertStrictEquals(isExtensibleObject(undefined), false);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new isExtensibleObject({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(isExtensibleObject.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ isExtensibleObject.name,
+ "isExtensibleObject",
+ );
+ });
+ });
+});
+
+describe("isUnfrozenObject", () => {
+ it("[[Call]] returns true for unfrozen objects", () => {
+ assertStrictEquals(isUnfrozenObject({}), true);
+ });
+
+ it("[[Call]] returns false for coercible primitives", () => {
+ assertStrictEquals(isUnfrozenObject(1), false);
+ assertStrictEquals(isUnfrozenObject(Symbol()), false);
+ });
+
+ it("[[Call]] returns false for frozen objects", () => {
+ assertStrictEquals(isUnfrozenObject(Object.freeze({})), false);
+ });
+
+ it("[[Call]] returns false for null and undefined", () => {
+ assertStrictEquals(isUnfrozenObject(null), false);
+ assertStrictEquals(isUnfrozenObject(undefined), false);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new isUnfrozenObject({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(isUnfrozenObject.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(isUnfrozenObject.name, "isUnfrozenObject");
+ });
+ });
+});
+
+describe("isUnsealedObject", () => {
+ it("[[Call]] returns true for unsealed objects", () => {
+ assertStrictEquals(isUnsealedObject({}), true);
+ });
+
+ it("[[Call]] returns false for coercible primitives", () => {
+ assertStrictEquals(isUnsealedObject(1), false);
+ assertStrictEquals(isUnsealedObject(Symbol()), false);
+ });
+
+ it("[[Call]] returns false for sealed objects", () => {
+ assertStrictEquals(isUnsealedObject(Object.seal({})), false);
+ });
+
+ it("[[Call]] returns false for null and undefined", () => {
+ assertStrictEquals(isUnsealedObject(null), false);
+ assertStrictEquals(isUnsealedObject(undefined), false);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new isUnsealedObject({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(isUnsealedObject.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(isUnsealedObject.name, "isUnsealedObject");
+ });
+ });
+});
+
+describe("namedEntries", () => {
+ it("[[Call]] gets named entries", () => {
+ assertEquals(namedEntries({ success: true }), [["success", true]]);
+ });
+
+ it("[[Call]] works for values coercible to objects", () => {
+ assertEquals(namedEntries("foo"), [
+ ["0", "f"],
+ ["1", "o"],
+ ["2", "o"],
+ ]);
+ });
+
+ it("[[Call]] throws for null and undefined", () => {
+ assertThrows(() => namedEntries(null));
+ assertThrows(() => namedEntries(undefined));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new namedEntries({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(namedEntries.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(namedEntries.name, "namedEntries");
+ });
+ });
+});
+
+describe("namedKeys", () => {
+ it("[[Call]] gets named keys", () => {
+ assertEquals(namedKeys({ success: true }), ["success"]);
+ });
+
+ it("[[Call]] works for values coercible to objects", () => {
+ assertEquals(namedKeys("foo"), [
+ "0",
+ "1",
+ "2",
+ ]);
+ });
+
+ it("[[Call]] throws for null and undefined", () => {
+ assertThrows(() => namedKeys(null));
+ assertThrows(() => namedKeys(undefined));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new namedKeys({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(namedKeys.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(namedKeys.name, "namedKeys");
+ });
+ });
+});
+
+describe("namedValues", () => {
+ it("[[Call]] gets named values", () => {
+ assertEquals(namedValues({ success: true }), [true]);
+ });
+
+ it("[[Call]] works for values coercible to objects", () => {
+ assertEquals(namedValues("foo"), [
+ "f",
+ "o",
+ "o",
+ ]);
+ });
+
+ it("[[Call]] throws for null and undefined", () => {
+ assertThrows(() => namedValues(null));
+ assertThrows(() => namedValues(undefined));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new namedValues({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(namedValues.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(namedValues.name, "namedValues");
+ });
+ });
+});
+
+describe("objectCreate", () => {
+ it("[[Call]] creates an object", () => {
+ const obj = objectCreate(null);
+ assertStrictEquals(Object(obj), obj);
+ });
+
+ it("[[Call]] correctly sets the prototype", () => {
+ const proto = {};
+ assertStrictEquals(
+ Object.getPrototypeOf(objectCreate(proto)),
+ proto,
+ );
+ assertStrictEquals(
+ Object.getPrototypeOf(objectCreate(null)),
+ null,
+ );
+ });
+
+ it("[[Call]] correctly sets own properties", () => {
+ assertEquals(
+ Object.getOwnPropertyDescriptors(
+ objectCreate(null, { success: { value: true } }),
+ ),
+ {
+ success: {
+ configurable: false,
+ enumerable: false,
+ value: true,
+ writable: false,
+ },
+ },
+ );
+ });
+
+ it("[[Call]] throws for coercible primitives", () => {
+ assertThrows(() => objectCreate(1));
+ assertThrows(() => objectCreate(Symbol()));
+ });
+
+ it("[[Call]] throws for undefined", () => {
+ assertThrows(() => objectCreate(undefined));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new objectCreate({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(objectCreate.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(objectCreate.name, "objectCreate");
+ });
+ });
+});
+
+describe("objectFromEntries", () => {
+ it("[[Call]] creates an object", () => {
+ const obj = objectFromEntries([]);
+ assertStrictEquals(Object(obj), obj);
+ });
+
+ it("[[Call]] correctly sets the prototype", () => {
+ assertStrictEquals(
+ Object.getPrototypeOf(objectFromEntries([])),
+ Object.prototype,
+ );
+ });
+
+ it("[[Call]] correctly sets own properties", () => {
+ assertEquals(
+ Object.entries(objectFromEntries([["success", true]])),
+ [["success", true]],
+ );
+ });
+
+ it("[[Call]] throws if the argument is not a nested arraylike", () => {
+ assertThrows(() => objectFromEntries(1));
+ assertThrows(() => objectFromEntries(Symbol()));
+ assertThrows(() => objectFromEntries(null));
+ assertThrows(() => objectFromEntries(undefined));
+ assertThrows(() => objectFromEntries({}));
+ assertThrows(() => objectFromEntries([undefined]));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new objectFromEntries([]));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(objectFromEntries.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(objectFromEntries.name, "objectFromEntries");
+ });
+ });
+});
+
+describe("preventExtensions", () => {
+ it("[[Call]] prevents extensions on the object", () => {
+ const obj = {};
+ preventExtensions(obj);
+ assert(!Object.isExtensible(obj));
+ });
+
+ it("[[Call]] returns the provided object", () => {
+ const obj = {};
+ assertStrictEquals(preventExtensions(obj), obj);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new preventExtensions({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(preventExtensions.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(preventExtensions.name, "preventExtensions");
+ });
+ });
+});
+
+describe("seal", () => {
+ it("[[Call]] seals the object", () => {
+ const obj = {};
+ seal(obj);
+ assert(Object.isSealed(obj));
+ });
+
+ it("[[Call]] returns the provided object", () => {
+ const obj = {};
+ assertStrictEquals(seal(obj), obj);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new seal({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(seal.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(seal.name, "seal");
+ });
+ });
+});
+
+describe("setPropertyValue", () => {
+ it("[[Call]] sets the provided property on the provided object", () => {
+ const obj = {};
+ setPropertyValue(obj, "success", true);
+ assertStrictEquals(obj.success, true);
+ });
+
+ it("[[Call]] calls setters", () => {
+ const setter = spy((_) => {});
+ const obj = Object.create(null, { success: { set: setter } });
+ setPropertyValue(obj, "success", true);
+ assertSpyCalls(setter, 1);
+ assertSpyCall(setter, 0, {
+ args: [true],
+ self: obj,