1 // ♓🌟 Piscēs ∷ object.test.js
2 // ====================================================================
4 // Copyright © 2022–2023 Lady [@ Lady’s Computer].
6 // This Source Code Form is subject to the terms of the Mozilla Public
7 // License, v. 2.0. If a copy of the MPL was not distributed with this
8 // file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
20 } from "./dev-deps.js";
28 getOwnPropertyDescriptor
,
29 getOwnPropertyDescriptors
,
31 getOwnPropertyStrings
,
32 getOwnPropertySymbols
,
56 describe("LazyLoader", () => {
57 const symbol
= Symbol("foo");
59 const etaoinMethod
= spy(() => "success");
60 const shrdluMethod
= spy(() => "success");
61 const cmfwypMethod
= spy(() => "success");
62 const vbgkqjMethod
= spy(() => "success");
63 const methodsObject
= Object
.create(
93 xz
fiflffffi: { configurable
: true, enumerable
: false, set(_
) {} },
103 it("[[Call]] throws an error", () => {
104 assertThrows(() => LazyLoader({}));
107 it("[[Construct]] creates a new object which inherits from the correct prototype", () => {
109 Object
.getPrototypeOf(new LazyLoader(methodsObject
)),
114 it("[[Construct]] creates a new object with the desired properties", () => {
116 Reflect
.ownKeys(new LazyLoader(methodsObject
)),
117 ["etaoin", "shrdlu", "cmfwyp", "vbgkqj", "xzfiflffffi", symbol
],
121 it("[[Construct]] creates a new object with configurable properties", () => {
125 for (const key
of Reflect
.ownKeys(ll
)) {
128 Object
.getOwnPropertyDescriptor(ll
, key
).configurable
,
131 }(new LazyLoader(methodsObject
)),
144 it("[[Construct]] creates a new object with the correct enumerability", () => {
148 for (const key
of Reflect
.ownKeys(ll
)) {
151 Object
.getOwnPropertyDescriptor(ll
, key
).enumerable
,
154 }(new LazyLoader(methodsObject
)),
167 it("[[Construct]] creates a new object with defined getters", () => {
171 for (const key
of Reflect
.ownKeys(ll
)) {
174 Object
.getOwnPropertyDescriptor(ll
, key
).get?.name
,
177 }(new LazyLoader(methodsObject
)),
180 etaoin
: "get etaoin",
181 shrdlu
: "get shrdlu",
182 cmfwyp
: "get cmfwyp",
183 vbgkqj
: "get vbgkqj",
184 xz
fiflffffi: "get xzfiflffffi",
185 [symbol
]: `get [${symbol.description}]`,
190 it("[[Construct]] creates a new object with defined setters for writable properties only", () => {
194 for (const key
of Reflect
.ownKeys(ll
)) {
197 Object
.getOwnPropertyDescriptor(ll
, key
).set?.name
,
200 }(new LazyLoader(methodsObject
)),
208 [symbol
]: `set [${symbol.description}]`,
213 it("[[Construct]] creates a new object with correct getter behaviour", () => {
214 const ll
= new LazyLoader(methodsObject
);
217 Object
.getOwnPropertyDescriptor(ll
, "etaoin"),
225 assertSpyCalls(etaoinMethod
, 1);
226 assertSpyCall(etaoinMethod
, 0, {
233 Object
.getOwnPropertyDescriptor(ll
, "shrdlu"),
241 assertSpyCalls(shrdluMethod
, 1);
242 assertSpyCall(shrdluMethod
, 0, {
249 Object
.getOwnPropertyDescriptor(ll
, "cmfwyp"),
257 assertSpyCalls(cmfwypMethod
, 1);
258 assertSpyCall(cmfwypMethod
, 0, {
265 Object
.getOwnPropertyDescriptor(ll
, "vbgkqj"),
273 assertSpyCalls(vbgkqjMethod
, 1);
274 assertSpyCall(vbgkqjMethod
, 0, {
279 assertThrows(() => ll
.xz
fiflffffi);
280 assertThrows(() => ll
[symbol
]);
283 it("[[Construct]] creates a new object with correct setter behaviour", () => {
284 const ll
= new LazyLoader(methodsObject
);
285 ll
[symbol
] = "success";
287 Object
.getOwnPropertyDescriptor(ll
, symbol
),
297 describe(".length", () => {
298 it("[[Get]] returns the correct length", () => {
299 assertStrictEquals(LazyLoader
.length
, 1);
303 describe(".name", () => {
304 it("[[Get]] returns the correct name", () => {
305 assertStrictEquals(LazyLoader
.name
, "LazyLoader");
310 describe("PropertyDescriptor", () => {
311 it("[[Call]] throws an error", () => {
312 assertThrows(() => PropertyDescriptor({}));
315 it("[[Construct]] creates a new PropertyDescriptor", () => {
317 Object
.getPrototypeOf(new PropertyDescriptor({})),
318 PropertyDescriptor
.prototype,
322 it("[[Construct]] throws for primitives", () => {
323 assertThrows(() => new PropertyDescriptor("failure"));
326 describe(".length", () => {
327 it("[[Get]] returns the correct length", () => {
328 assertStrictEquals(PropertyDescriptor
.length
, 1);
332 describe(".name", () => {
333 it("[[Get]] returns the correct name", () => {
335 PropertyDescriptor
.name
,
336 "PropertyDescriptor",
341 describe("::complete", () => {
342 it("[[Call]] completes a generic descriptor", () => {
344 PropertyDescriptor
.prototype.complete
.call(desc
);
353 it("[[Call]] completes a data descriptor", () => {
354 const desc
= { value
: undefined };
355 PropertyDescriptor
.prototype.complete
.call(desc
);
364 it("[[Call]] completes an accessor descriptor", () => {
365 const desc
= { get: undefined };
366 PropertyDescriptor
.prototype.complete
.call(desc
);
375 describe(".length", () => {
376 it("[[Get]] returns the correct length", () => {
378 PropertyDescriptor
.prototype.complete
.length
,
384 describe(".name", () => {
385 it("[[Get]] returns the correct name", () => {
387 PropertyDescriptor
.prototype.complete
.name
,
394 describe("::isAccessorDescriptor", () => {
395 it("[[Get]] returns false for a generic descriptor", () => {
398 PropertyDescriptor
.prototype,
399 "isAccessorDescriptor",
406 it("[[Get]] returns false for a data descriptor", () => {
409 PropertyDescriptor
.prototype,
410 "isAccessorDescriptor",
411 { value
: undefined },
417 it("[[Get]] returns true for an accessor descriptor", () => {
420 PropertyDescriptor
.prototype,
421 "isAccessorDescriptor",
428 describe("[[GetOwnProperty]].get.length", () => {
429 it("[[Get]] returns the correct length", () => {
431 Object
.getOwnPropertyDescriptor(
432 PropertyDescriptor
.prototype,
433 "isAccessorDescriptor",
440 describe("[[GetOwnProperty]].get.name", () => {
441 it("[[Get]] returns the correct name", () => {
443 Object
.getOwnPropertyDescriptor(
444 PropertyDescriptor
.prototype,
445 "isAccessorDescriptor",
447 "get isAccessorDescriptor",
453 describe("::isDataDescriptor", () => {
454 it("[[Get]] returns false for a generic descriptor", () => {
457 PropertyDescriptor
.prototype,
465 it("[[Get]] returns true for a data descriptor", () => {
468 PropertyDescriptor
.prototype,
470 { value
: undefined },
476 it("[[Get]] returns false for an accessor descriptor", () => {
479 PropertyDescriptor
.prototype,
487 describe("[[GetOwnProperty]].get.length", () => {
488 it("[[Get]] returns the correct length", () => {
490 Object
.getOwnPropertyDescriptor(
491 PropertyDescriptor
.prototype,
499 describe("[[GetOwnProperty]].get.name", () => {
500 it("[[Get]] returns the correct name", () => {
502 Object
.getOwnPropertyDescriptor(
503 PropertyDescriptor
.prototype,
506 "get isDataDescriptor",
512 describe("::isFullyPopulated", () => {
513 it("[[Get]] returns false for a generic descriptor", () => {
516 PropertyDescriptor
.prototype,
524 it("[[Get]] returns false for a non‐fully‐populated data descriptor", () => {
527 PropertyDescriptor
.prototype,
529 { value
: undefined },
535 it("[[Get]] returns true for a fully‐populated data descriptor", () => {
537 Reflect
.get(PropertyDescriptor
.prototype, "isFullyPopulated", {
547 it("[[Get]] returns false for a non‐fully‐populated accessor descriptor", () => {
550 PropertyDescriptor
.prototype,
558 it("[[Get]] returns true for a fully‐populated accessor descriptor", () => {
560 Reflect
.get(PropertyDescriptor
.prototype, "isFullyPopulated", {
570 describe("[[GetOwnProperty]].get.length", () => {
571 it("[[Get]] returns the correct length", () => {
573 Object
.getOwnPropertyDescriptor(
574 PropertyDescriptor
.prototype,
582 describe("[[GetOwnProperty]].get.name", () => {
583 it("[[Get]] returns the correct name", () => {
585 Object
.getOwnPropertyDescriptor(
586 PropertyDescriptor
.prototype,
589 "get isFullyPopulated",
595 describe("::isGenericDescriptor", () => {
596 it("[[Get]] returns true for a generic descriptor", () => {
599 PropertyDescriptor
.prototype,
600 "isGenericDescriptor",
607 it("[[Get]] returns true for a data descriptor", () => {
610 PropertyDescriptor
.prototype,
611 "isGenericDescriptor",
612 { value
: undefined },
618 it("[[Get]] returns false for an accessor descriptor", () => {
621 PropertyDescriptor
.prototype,
622 "isGenericDescriptor",
629 describe("[[GetOwnProperty]].get.length", () => {
630 it("[[Get]] returns the correct length", () => {
632 Object
.getOwnPropertyDescriptor(
633 PropertyDescriptor
.prototype,
634 "isGenericDescriptor",
641 describe("[[GetOwnProperty]].get.name", () => {
642 it("[[Get]] returns the correct name", () => {
644 Object
.getOwnPropertyDescriptor(
645 PropertyDescriptor
.prototype,
646 "isGenericDescriptor",
648 "get isGenericDescriptor",
654 describe("~configurable", () => {
655 it("[[DefineOwnProperty]] coerces to a boolean", () => {
656 const desc
= new PropertyDescriptor({});
657 Object
.defineProperty(desc
, "configurable", {});
658 assertStrictEquals(desc
.configurable
, false);
661 it("[[DefineOwnProperty]] throws for accessor properties", () => {
662 const desc
= new PropertyDescriptor({});
664 Object
.defineProperty(desc
, "configurable", { get: undefined })
668 it("[[Set]] coerces to a boolean", () => {
669 const desc
= new PropertyDescriptor({});
670 desc
.configurable
= undefined;
671 assertStrictEquals(desc
.configurable
, false);
674 it("[[Delete]] works", () => {
675 const desc
= new PropertyDescriptor({ configurable
: false });
676 delete desc
.configurable
;
677 assert(!("configurable" in desc
));
681 describe("~enumerable", () => {
682 it("[[DefineOwnProperty]] coerces to a boolean", () => {
683 const desc
= new PropertyDescriptor({});
684 Object
.defineProperty(desc
, "enumerable", {});
685 assertStrictEquals(desc
.enumerable
, false);
688 it("[[DefineOwnProperty]] throws for accessor properties", () => {
689 const desc
= new PropertyDescriptor({});
691 Object
.defineProperty(desc
, "enumerable", { get: undefined })
695 it("[[Set]] coerces to a boolean", () => {
696 const desc
= new PropertyDescriptor({});
697 desc
.enumerable
= undefined;
698 assertStrictEquals(desc
.enumerable
, false);
701 it("[[Delete]] works", () => {
702 const desc
= new PropertyDescriptor({ enumerable
: false });
703 delete desc
.enumerable
;
704 assert(!("enumerable" in desc
));
708 describe("~get", () => {
709 it("[[DefineOwnProperty]] works", () => {
710 const desc
= new PropertyDescriptor({});
711 Object
.defineProperty(desc
, "get", {});
712 assertStrictEquals(desc
.get, undefined);
715 it("[[DefineOwnProperty]] throws for accessor properties", () => {
716 const desc
= new PropertyDescriptor({});
718 Object
.defineProperty(desc
, "get", { get: undefined })
722 it("[[DefineOwnProperty]] throws if not callable or undefined", () => {
723 const desc
= new PropertyDescriptor({});
725 () => Object
.defineProperty(desc
, "get", { value
: null }),
729 it("[[DefineOwnProperty]] throws if a data property is defined", () => {
730 const desc
= new PropertyDescriptor({ value
: undefined });
731 assertThrows(() => Object
.defineProperty(desc
, "get", {}));
734 it("[[Set]] works", () => {
735 const desc
= new PropertyDescriptor({});
738 assertStrictEquals(desc
.get, fn
);
741 it("[[Set]] throws if not callable or undefined", () => {
742 const desc
= new PropertyDescriptor({});
743 assertThrows(() => desc
.get = null);
746 it("[[Set]] throws if a data property is defined", () => {
747 const desc
= new PropertyDescriptor({ value
: undefined });
748 assertThrows(() => desc
.get = undefined);
751 it("[[Delete]] works", () => {
752 const desc
= new PropertyDescriptor({ get: undefined });
754 assert(!("get" in desc
));
758 describe("~set", () => {
759 it("[[DefineOwnProperty]] works", () => {
760 const desc
= new PropertyDescriptor({});
761 Object
.defineProperty(desc
, "set", {});
762 assertStrictEquals(desc
.set, undefined);
765 it("[[DefineOwnProperty]] throws for accessor properties", () => {
766 const desc
= new PropertyDescriptor({});
768 Object
.defineProperty(desc
, "set", { get: undefined })
772 it("[[DefineOwnProperty]] throws if not callable or undefined", () => {
773 const desc
= new PropertyDescriptor({});
775 () => Object
.defineProperty(desc
, "set", { value
: null }),
779 it("[[DefineOwnProperty]] throws if a data property is defined", () => {
780 const desc
= new PropertyDescriptor({ value
: undefined });
781 assertThrows(() => Object
.defineProperty(desc
, "set", {}));
784 it("[[Set]] works", () => {
785 const desc
= new PropertyDescriptor({});
786 const fn
= (_
) => {};
788 assertStrictEquals(desc
.set, fn
);
791 it("[[Set]] throws if not callable or undefined", () => {
792 const desc
= new PropertyDescriptor({});
793 assertThrows(() => desc
.set = null);
796 it("[[Set]] throws if a data property is defined", () => {
797 const desc
= new PropertyDescriptor({ value
: undefined });
798 assertThrows(() => desc
.set = undefined);
801 it("[[Delete]] works", () => {
802 const desc
= new PropertyDescriptor({ set: undefined });
804 assert(!("set" in desc
));
808 describe("~value", () => {
809 it("[[DefineOwnProperty]] works", () => {
810 const desc
= new PropertyDescriptor({});
811 Object
.defineProperty(desc
, "value", {});
812 assertStrictEquals(desc
.value
, undefined);
815 it("[[DefineOwnProperty]] throws for accessor properties", () => {
816 const desc
= new PropertyDescriptor({});
818 Object
.defineProperty(desc
, "value", { get: undefined })
822 it("[[DefineOwnProperty]] throws if an accessor property is defined", () => {
823 const desc
= new PropertyDescriptor({ get: undefined });
824 assertThrows(() => Object
.defineProperty(desc
, "value", {}));
827 it("[[Set]] works", () => {
828 const desc
= new PropertyDescriptor({});
829 desc
.value
= "success";
830 assertStrictEquals(desc
.value
, "success");
833 it("[[Set]] throws if an accessor property is defined", () => {
834 const desc
= new PropertyDescriptor({ get: undefined });
835 assertThrows(() => desc
.value
= null);
838 it("[[Delete]] works", () => {
839 const desc
= new PropertyDescriptor({ value
: undefined });
841 assert(!("value" in desc
));
845 describe("~writable", () => {
846 it("[[DefineOwnProperty]] coerces to a boolean", () => {
847 const desc
= new PropertyDescriptor({});
848 Object
.defineProperty(desc
, "writable", {});
849 assertStrictEquals(desc
.writable
, false);
852 it("[[DefineOwnProperty]] throws for accessor properties", () => {
853 const desc
= new PropertyDescriptor({});
855 Object
.defineProperty(desc
, "writable", { get: undefined })
859 it("[[DefineOwnProperty]] throws if an accessor property is defined", () => {
860 const desc
= new PropertyDescriptor({ get: undefined });
861 assertThrows(() => Object
.defineProperty(desc
, "writable", {}));
864 it("[[Set]] coerces to a boolean", () => {
865 const desc
= new PropertyDescriptor({});
866 desc
.writable
= undefined;
867 assertStrictEquals(desc
.writable
, false);
870 it("[[Set]] throws if an accessor property is defined", () => {
871 const desc
= new PropertyDescriptor({ get: undefined });
872 assertThrows(() => desc
.writable
= false);
875 it("[[Delete]] works", () => {
876 const desc
= new PropertyDescriptor({ writable
: false });
877 delete desc
.writable
;
878 assert(!("writable" in desc
));
883 describe("defineOwnProperty", () => {
884 it("[[Call]] defines the property", () => {
886 defineOwnProperty(obj
, "etaoin", {});
887 assert("etaoin" in obj
);
890 it("[[Call]] returns the provided object", () => {
892 assertStrictEquals(defineOwnProperty(obj
, "etaoin", {}), obj
);
895 it("[[Construct]] throws an error", () => {
896 assertThrows(() => new defineOwnProperty(obj
, "etaoin", {}));
899 describe(".length", () => {
900 it("[[Get]] returns the correct length", () => {
901 assertStrictEquals(defineOwnProperty
.length
, 3);
905 describe(".name", () => {
906 it("[[Get]] returns the correct name", () => {
908 defineOwnProperty
.name
,
915 describe("defineOwnProperties", () => {
916 it("[[Call]] defines properties from the provided objects", () => {
918 defineOwnProperties(obj
, {
922 assert("etaoin" in obj
);
923 assert("shrdlu" in obj
);
924 assert("cmfwyp" in obj
);
927 it("[[Call]] overrides earlier declarations with later ones", () => {
928 const obj
= { etaoin
: undefined };
929 defineOwnProperties(obj
, {
930 etaoin
: { value
: "failure" },
932 etaoin
: { value
: "success" },
934 assertStrictEquals(obj
.etaoin
, "success");
937 it("[[Call]] returns the provided object", () => {
939 assertStrictEquals(defineOwnProperties(obj
), obj
);
942 it("[[Construct]] throws an error", () => {
943 assertThrows(() => new defineOwnProperties({}));
946 describe(".length", () => {
947 it("[[Get]] returns the correct length", () => {
948 assertStrictEquals(defineOwnProperties
.length
, 1);
952 describe(".name", () => {
953 it("[[Get]] returns the correct name", () => {
955 defineOwnProperties
.name
,
956 "defineOwnProperties",
962 describe("deleteOwnProperty", () => {
963 it("[[Call]] deletes the provided property on the provided object", () => {
964 const obj
= { failure
: undefined };
965 deleteOwnProperty(obj
, "failure");
966 assert(!("failure" in obj
));
969 it("[[Call]] does nothing if the property doesn’t exist", () => {
970 const obj
= Object
.freeze({});
971 deleteOwnProperty(obj
, "failure");
972 assert(!("failure" in obj
));
975 it("[[Call]] throws if the property can’t be deleted", () => {
976 const obj
= Object
.seal({ failure
: undefined });
977 assertThrows(() => deleteOwnProperty(obj
, "failure"));
980 it("[[Call]] returns the provided object", () => {
982 assertStrictEquals(deleteOwnProperty(obj
, ""), obj
);
985 it("[[Construct]] throws an error", () => {
986 assertThrows(() => new deleteOwnProperty({}, ""));
989 describe(".length", () => {
990 it("[[Get]] returns the correct length", () => {
991 assertStrictEquals(deleteOwnProperty
.length
, 2);
995 describe(".name", () => {
996 it("[[Get]] returns the correct name", () => {
997 assertStrictEquals(deleteOwnProperty
.name
, "deleteOwnProperty");
1002 describe("freeze", () => {
1003 it("[[Call]] freezes the object", () => {
1006 assert(Object
.isFrozen(obj
));
1009 it("[[Call]] returns the provided object", () => {
1011 assertStrictEquals(freeze(obj
), obj
);
1014 it("[[Construct]] throws an error", () => {
1015 assertThrows(() => new freeze({}));
1018 describe(".length", () => {
1019 it("[[Get]] returns the correct length", () => {
1020 assertStrictEquals(freeze
.length
, 1);
1024 describe(".name", () => {
1025 it("[[Get]] returns the correct name", () => {
1026 assertStrictEquals(freeze
.name
, "freeze");
1031 describe("frozenCopy", () => {
1032 it("[[Call]] returns a frozen object", () => {
1035 frozenCopy(Object
.create(null), {
1052 it("[[Call]] ignores non·enumerable properties", () => {
1055 Object
.create(null, {
1056 data
: { value
: undefined },
1057 accessor
: { get: undefined },
1064 it("[[Call]] preserves accessor properties", () => {
1065 const properties
= {
1067 configurable
: false,
1073 configurable
: false,
1079 configurable
: false,
1085 configurable
: false,
1092 Object
.getOwnPropertyDescriptors(
1093 frozenCopy(Object
.create(null, properties
)),
1099 it("[[Call]] does not copy properties on the prototype", () => {
1102 frozenCopy(Object
.create({ failure
: undefined }), {
1108 accessor
: { configurable
: true, get: undefined },
1113 it("[[Call]] uses the species of the constructor", () => {
1114 const species
= { prototype: {} };
1116 Object
.getPrototypeOf(
1117 frozenCopy({}, { [Symbol
.species
]: species
}),
1123 it("[[Call]] uses constructor if no species is defined", () => {
1124 const constructor = { [Symbol
.species
]: null, prototype: {} };
1126 Object
.getPrototypeOf(frozenCopy({}, constructor)),
1127 constructor.prototype,
1131 it("[[Call]] uses the constructor on the object if none is provided", () => {
1132 const constructor = { [Symbol
.species
]: null, prototype: {} };
1134 Object
.getPrototypeOf(frozenCopy({ constructor })),
1135 constructor.prototype,
1139 it("[[Call]] allows a null constructor", () => {
1141 Object
.getPrototypeOf(frozenCopy({}, null)),
1146 it("[[Construct]] throws an error", () => {
1147 assertThrows(() => new frozenCopy({}));
1150 describe(".length", () => {
1151 it("[[Get]] returns the correct length", () => {
1152 assertStrictEquals(frozenCopy
.length
, 1);
1156 describe(".name", () => {
1157 it("[[Get]] returns the correct name", () => {
1158 assertStrictEquals(frozenCopy
.name
, "frozenCopy");
1163 describe("getMethod", () => {
1164 it("[[Call]] gets a method", () => {
1165 const method
= () => {};
1166 assertStrictEquals(getMethod({ method
}, "method"), method
);
1169 it("[[Call]] works for values coercible to objects", () => {
1170 assertEquals(getMethod("", "toString"), String
.prototype.toString
);
1173 it("[[Call]] throws for null and undefined", () => {
1174 assertThrows(() => getMethod(null, "valueOf"));
1175 assertThrows(() => getMethod(undefined, "valueOf"));
1178 it("[[Call]] throws if the resulting value isn’t callable", () => {
1179 assertThrows(() => getMethod({ "failure": true }, "failure"));
1182 it("[[Construct]] throws an error", () => {
1183 assertThrows(() => new getMethod({ method() {} }, "method"));
1186 describe(".length", () => {
1187 it("[[Get]] returns the correct length", () => {
1188 assertStrictEquals(getMethod
.length
, 2);
1192 describe(".name", () => {
1193 it("[[Get]] returns the correct name", () => {
1194 assertStrictEquals(getMethod
.name
, "getMethod");
1199 describe("getOwnPropertyDescriptor", () => {
1200 it("[[Call]] gets the descriptor", () => {
1202 getOwnPropertyDescriptor({ success
: true }, "success"),
1212 it("[[Call]] returns undefined for non‐own properties", () => {
1214 getOwnPropertyDescriptor({}, "valueOf"),
1219 it("[[Construct]] throws an error", () => {
1220 assertThrows(() => new getOwnPropertyDescriptor({}, ""));
1223 describe(".length", () => {
1224 it("[[Get]] returns the correct length", () => {
1225 assertStrictEquals(getOwnPropertyDescriptor
.length
, 2);
1229 describe(".name", () => {
1230 it("[[Get]] returns the correct name", () => {
1232 getOwnPropertyDescriptor
.name
,
1233 "getOwnPropertyDescriptor",
1239 describe("getOwnPropertyDescriptors", () => {
1240 it("[[Call]] gets the descriptors", () => {
1242 getOwnPropertyDescriptors({ success
: true, etaoin
: "shrdlu" }),
1260 it("[[Construct]] throws an error", () => {
1261 assertThrows(() => new getOwnPropertyDescriptors({}));
1264 describe(".length", () => {
1265 it("[[Get]] returns the correct length", () => {
1266 assertStrictEquals(getOwnPropertyDescriptors
.length
, 1);
1270 describe(".name", () => {
1271 it("[[Get]] returns the correct name", () => {
1273 getOwnPropertyDescriptors
.name
,
1274 "getOwnPropertyDescriptors",
1280 describe("getOwnPropertyKeys", () => {
1281 it("[[Call]] gets own (but not inherited) property keys", () => {
1282 assertEquals(getOwnPropertyKeys({ success
: true }), ["success"]);
1285 it("[[Call]] works for values coercible to objects", () => {
1286 assertEquals(getOwnPropertyKeys("foo"), ["0", "1", "2", "length"]);
1289 it("[[Call]] throws for null and undefined", () => {
1290 assertThrows(() => getOwnPropertyKeys(null));
1291 assertThrows(() => getOwnPropertyKeys(undefined));
1294 it("[[Construct]] throws an error", () => {
1295 assertThrows(() => new getOwnPropertyKeys({}));
1298 describe(".length", () => {
1299 it("[[Get]] returns the correct length", () => {
1300 assertStrictEquals(getOwnPropertyKeys
.length
, 1);
1304 describe(".name", () => {
1305 it("[[Get]] returns the correct name", () => {
1307 getOwnPropertyKeys
.name
,
1308 "getOwnPropertyKeys",
1314 describe("getOwnPropertyStrings", () => {
1315 it("[[Call]] gets own string keys", () => {
1316 assertEquals(getOwnPropertyStrings({ success
: true }), [
1321 it("[[Call]] works for values coercible to objects", () => {
1322 assertEquals(getOwnPropertyStrings("foo"), [
1330 it("[[Call]] throws for null and undefined", () => {
1331 assertThrows(() => getOwnPropertyStrings(null));
1332 assertThrows(() => getOwnPropertyStrings(undefined));
1335 it("[[Construct]] throws an error", () => {
1336 assertThrows(() => new getOwnPropertyStrings({}));
1339 describe(".length", () => {
1340 it("[[Get]] returns the correct length", () => {
1341 assertStrictEquals(getOwnPropertyStrings
.length
, 1);
1345 describe(".name", () => {
1346 it("[[Get]] returns the correct name", () => {
1348 getOwnPropertyStrings
.name
,
1349 "getOwnPropertyStrings",
1355 describe("getOwnPropertySymbols", () => {
1356 it("[[Call]] gets own symbol keys", () => {
1357 const sym
= Symbol();
1358 assertEquals(getOwnPropertySymbols({ [sym
]: true }), [sym
]);
1361 it("[[Call]] works for values coercible to objects", () => {
1362 assertEquals(getOwnPropertySymbols("foo"), []);
1365 it("[[Call]] throws for null and undefined", () => {
1366 assertThrows(() => getOwnPropertySymbols(null));
1367 assertThrows(() => getOwnPropertySymbols(undefined));
1370 it("[[Construct]] throws an error", () => {
1371 assertThrows(() => new getOwnPropertySymbols({}));
1374 describe(".length", () => {
1375 it("[[Get]] returns the correct length", () => {
1376 assertStrictEquals(getOwnPropertySymbols
.length
, 1);
1380 describe(".name", () => {
1381 it("[[Get]] returns the correct name", () => {
1383 getOwnPropertySymbols
.name
,
1384 "getOwnPropertySymbols",
1390 describe("getPropertyValue", () => {
1391 it("[[Call]] gets property values on the provided object", () => {
1393 getPropertyValue({ success
: true }, "success"),
1398 it("[[Call]] works for values coercible to objects", () => {
1400 getPropertyValue("", "toString"),
1401 String
.prototype.toString
,
1405 it("[[Call]] throws for null and undefined", () => {
1406 assertThrows(() => getPropertyValue(null, "valueOf"));
1407 assertThrows(() => getPropertyValue(undefined, "valueOf"));
1410 it("[[Construct]] throws an error", () => {
1411 assertThrows(() => new getPropertyValue({}, "valueOf"));
1414 describe(".length", () => {
1415 it("[[Get]] returns the correct length", () => {
1416 assertStrictEquals(getPropertyValue
.length
, 2);
1420 describe(".name", () => {
1421 it("[[Get]] returns the correct name", () => {
1422 assertStrictEquals(getPropertyValue
.name
, "getPropertyValue");
1427 describe("getPrototype", () => {
1428 it("[[Call]] gets object prototypes", () => {
1429 assertStrictEquals(getPrototype({}), Object
.prototype);
1431 assertStrictEquals(getPrototype(Object
.create(proto
)), proto
);
1434 it("[[Call]] gets null prototypes", () => {
1435 assertStrictEquals(getPrototype(Object
.create(null)), null);
1438 it("[[Call]] gets prototypes for coercible primitives", () => {
1439 assertStrictEquals(getPrototype(1), Number
.prototype);
1440 assertStrictEquals(getPrototype(Symbol()), Symbol
.prototype);
1443 it("[[Call]] throws for null and undefined", () => {
1444 assertThrows(() => getPrototype(null));
1445 assertThrows(() => getPrototype(undefined));
1448 it("[[Construct]] throws an error", () => {
1449 assertThrows(() => new getPrototype({}));
1452 describe(".length", () => {
1453 it("[[Get]] returns the correct length", () => {
1454 assertStrictEquals(getPrototype
.length
, 1);
1458 describe(".name", () => {
1459 it("[[Get]] returns the correct name", () => {
1460 assertStrictEquals(getPrototype
.name
, "getPrototype");
1465 describe("hasProperty", () => {
1466 it("[[Call]] gets whether a property exists on the provided object", () => {
1468 hasProperty({ success
: "etaoin" }, "success"),
1471 assertStrictEquals(hasProperty({}, "hasOwnProperty"), true);
1474 it("[[Call]] works for values coercible to objects", () => {
1475 assertStrictEquals(hasProperty("", "length"), true);
1476 assertStrictEquals(hasProperty("", "toString"), true);
1479 it("[[Call]] throws for null and undefined", () => {
1480 assertThrows(() => hasProperty(null, "valueOf"));
1481 assertThrows(() => hasProperty(undefined, "valueOf"));
1484 it("[[Construct]] throws an error", () => {
1485 assertThrows(() => new hasProperty({}, "valueOf"));
1488 describe(".length", () => {
1489 it("[[Get]] returns the correct length", () => {
1490 assertStrictEquals(hasProperty
.length
, 2);
1494 describe(".name", () => {
1495 it("[[Get]] returns the correct name", () => {
1496 assertStrictEquals(hasProperty
.name
, "hasProperty");
1501 describe("hasOwnProperty", () => {
1502 it("[[Call]] gets whether an own property exists on the provided object", () => {
1504 hasOwnProperty({ success
: "etaoin" }, "success"),
1507 assertStrictEquals(hasOwnProperty({}, "hasOwnProperty"), false);
1510 it("[[Call]] works for values coercible to objects", () => {
1511 assertStrictEquals(hasOwnProperty("", "length"), true);
1512 assertStrictEquals(hasOwnProperty("", "toString"), false);
1515 it("[[Call]] throws for null and undefined", () => {
1516 assertThrows(() => hasOwnProperty(null, "valueOf"));
1517 assertThrows(() => hasOwnProperty(undefined, "valueOf"));
1520 it("[[Construct]] throws an error", () => {
1521 assertThrows(() => new hasOwnProperty({}, "valueOf"));
1524 describe(".length", () => {
1525 it("[[Get]] returns the correct length", () => {
1526 assertStrictEquals(hasOwnProperty
.length
, 2);
1530 describe(".name", () => {
1531 it("[[Get]] returns the correct name", () => {
1532 assertStrictEquals(hasOwnProperty
.name
, "hasOwnProperty");
1537 describe("isExtensibleObject", () => {
1538 it("[[Call]] returns true for extensible objects", () => {
1539 assertStrictEquals(isExtensibleObject({}), true);
1542 it("[[Call]] returns false for coercible primitives", () => {
1543 assertStrictEquals(isExtensibleObject(1), false);
1544 assertStrictEquals(isExtensibleObject(Symbol()), false);
1547 it("[[Call]] returns false for non·extensible objects", () => {
1549 isExtensibleObject(Object
.preventExtensions({})),
1554 it("[[Call]] returns false for null and undefined", () => {
1555 assertStrictEquals(isExtensibleObject(null), false);
1556 assertStrictEquals(isExtensibleObject(undefined), false);
1559 it("[[Construct]] throws an error", () => {
1560 assertThrows(() => new isExtensibleObject({}));
1563 describe(".length", () => {
1564 it("[[Get]] returns the correct length", () => {
1565 assertStrictEquals(isExtensibleObject
.length
, 1);
1569 describe(".name", () => {
1570 it("[[Get]] returns the correct name", () => {
1572 isExtensibleObject
.name
,
1573 "isExtensibleObject",
1579 describe("isUnfrozenObject", () => {
1580 it("[[Call]] returns true for unfrozen objects", () => {
1581 assertStrictEquals(isUnfrozenObject({}), true);
1584 it("[[Call]] returns false for coercible primitives", () => {
1585 assertStrictEquals(isUnfrozenObject(1), false);
1586 assertStrictEquals(isUnfrozenObject(Symbol()), false);
1589 it("[[Call]] returns false for frozen objects", () => {
1590 assertStrictEquals(isUnfrozenObject(Object
.freeze({})), false);
1593 it("[[Call]] returns false for null and undefined", () => {
1594 assertStrictEquals(isUnfrozenObject(null), false);
1595 assertStrictEquals(isUnfrozenObject(undefined), false);
1598 it("[[Construct]] throws an error", () => {
1599 assertThrows(() => new isUnfrozenObject({}));
1602 describe(".length", () => {
1603 it("[[Get]] returns the correct length", () => {
1604 assertStrictEquals(isUnfrozenObject
.length
, 1);
1608 describe(".name", () => {
1609 it("[[Get]] returns the correct name", () => {
1610 assertStrictEquals(isUnfrozenObject
.name
, "isUnfrozenObject");
1615 describe("isUnsealedObject", () => {
1616 it("[[Call]] returns true for unsealed objects", () => {
1617 assertStrictEquals(isUnsealedObject({}), true);
1620 it("[[Call]] returns false for coercible primitives", () => {
1621 assertStrictEquals(isUnsealedObject(1), false);
1622 assertStrictEquals(isUnsealedObject(Symbol()), false);
1625 it("[[Call]] returns false for sealed objects", () => {
1626 assertStrictEquals(isUnsealedObject(Object
.seal({})), false);
1629 it("[[Call]] returns false for null and undefined", () => {
1630 assertStrictEquals(isUnsealedObject(null), false);
1631 assertStrictEquals(isUnsealedObject(undefined), false);
1634 it("[[Construct]] throws an error", () => {
1635 assertThrows(() => new isUnsealedObject({}));
1638 describe(".length", () => {
1639 it("[[Get]] returns the correct length", () => {
1640 assertStrictEquals(isUnsealedObject
.length
, 1);
1644 describe(".name", () => {
1645 it("[[Get]] returns the correct name", () => {
1646 assertStrictEquals(isUnsealedObject
.name
, "isUnsealedObject");
1651 describe("namedEntries", () => {
1652 it("[[Call]] gets named entries", () => {
1653 assertEquals(namedEntries({ success
: true }), [["success", true]]);
1656 it("[[Call]] works for values coercible to objects", () => {
1657 assertEquals(namedEntries("foo"), [
1664 it("[[Call]] throws for null and undefined", () => {
1665 assertThrows(() => namedEntries(null));
1666 assertThrows(() => namedEntries(undefined));
1669 it("[[Construct]] throws an error", () => {
1670 assertThrows(() => new namedEntries({}));
1673 describe(".length", () => {
1674 it("[[Get]] returns the correct length", () => {
1675 assertStrictEquals(namedEntries
.length
, 1);
1679 describe(".name", () => {
1680 it("[[Get]] returns the correct name", () => {
1681 assertStrictEquals(namedEntries
.name
, "namedEntries");
1686 describe("namedKeys", () => {
1687 it("[[Call]] gets named keys", () => {
1688 assertEquals(namedKeys({ success
: true }), ["success"]);
1691 it("[[Call]] works for values coercible to objects", () => {
1692 assertEquals(namedKeys("foo"), [
1699 it("[[Call]] throws for null and undefined", () => {
1700 assertThrows(() => namedKeys(null));
1701 assertThrows(() => namedKeys(undefined));
1704 it("[[Construct]] throws an error", () => {
1705 assertThrows(() => new namedKeys({}));
1708 describe(".length", () => {
1709 it("[[Get]] returns the correct length", () => {
1710 assertStrictEquals(namedKeys
.length
, 1);
1714 describe(".name", () => {
1715 it("[[Get]] returns the correct name", () => {
1716 assertStrictEquals(namedKeys
.name
, "namedKeys");
1721 describe("namedValues", () => {
1722 it("[[Call]] gets named values", () => {
1723 assertEquals(namedValues({ success
: true }), [true]);
1726 it("[[Call]] works for values coercible to objects", () => {
1727 assertEquals(namedValues("foo"), [
1734 it("[[Call]] throws for null and undefined", () => {
1735 assertThrows(() => namedValues(null));
1736 assertThrows(() => namedValues(undefined));
1739 it("[[Construct]] throws an error", () => {
1740 assertThrows(() => new namedValues({}));
1743 describe(".length", () => {
1744 it("[[Get]] returns the correct length", () => {
1745 assertStrictEquals(namedValues
.length
, 1);
1749 describe(".name", () => {
1750 it("[[Get]] returns the correct name", () => {
1751 assertStrictEquals(namedValues
.name
, "namedValues");
1756 describe("objectCreate", () => {
1757 it("[[Call]] creates an object", () => {
1758 const obj
= objectCreate(null);
1759 assertStrictEquals(Object(obj
), obj
);
1762 it("[[Call]] correctly sets the prototype", () => {
1765 Object
.getPrototypeOf(objectCreate(proto
)),
1769 Object
.getPrototypeOf(objectCreate(null)),
1774 it("[[Call]] correctly sets own properties", () => {
1776 Object
.getOwnPropertyDescriptors(
1777 objectCreate(null, { success
: { value
: true } }),
1781 configurable
: false,
1790 it("[[Call]] throws for coercible primitives", () => {
1791 assertThrows(() => objectCreate(1));
1792 assertThrows(() => objectCreate(Symbol()));
1795 it("[[Call]] throws for undefined", () => {
1796 assertThrows(() => objectCreate(undefined));
1799 it("[[Construct]] throws an error", () => {
1800 assertThrows(() => new objectCreate({}));
1803 describe(".length", () => {
1804 it("[[Get]] returns the correct length", () => {
1805 assertStrictEquals(objectCreate
.length
, 2);
1809 describe(".name", () => {
1810 it("[[Get]] returns the correct name", () => {
1811 assertStrictEquals(objectCreate
.name
, "objectCreate");
1816 describe("objectFromEntries", () => {
1817 it("[[Call]] creates an object", () => {
1818 const obj
= objectFromEntries([]);
1819 assertStrictEquals(Object(obj
), obj
);
1822 it("[[Call]] correctly sets the prototype", () => {
1824 Object
.getPrototypeOf(objectFromEntries([])),
1829 it("[[Call]] correctly sets own properties", () => {
1831 Object
.entries(objectFromEntries([["success", true]])),
1832 [["success", true]],
1836 it("[[Call]] throws if the argument is not a nested arraylike", () => {
1837 assertThrows(() => objectFromEntries(1));
1838 assertThrows(() => objectFromEntries(Symbol()));
1839 assertThrows(() => objectFromEntries(null));
1840 assertThrows(() => objectFromEntries(undefined));
1841 assertThrows(() => objectFromEntries({}));
1842 assertThrows(() => objectFromEntries([undefined]));
1845 it("[[Construct]] throws an error", () => {
1846 assertThrows(() => new objectFromEntries([]));
1849 describe(".length", () => {
1850 it("[[Get]] returns the correct length", () => {
1851 assertStrictEquals(objectFromEntries
.length
, 1);
1855 describe(".name", () => {
1856 it("[[Get]] returns the correct name", () => {
1857 assertStrictEquals(objectFromEntries
.name
, "objectFromEntries");
1862 describe("preventExtensions", () => {
1863 it("[[Call]] prevents extensions on the object", () => {
1865 preventExtensions(obj
);
1866 assert(!Object
.isExtensible(obj
));
1869 it("[[Call]] returns the provided object", () => {
1871 assertStrictEquals(preventExtensions(obj
), obj
);
1874 it("[[Construct]] throws an error", () => {
1875 assertThrows(() => new preventExtensions({}));
1878 describe(".length", () => {
1879 it("[[Get]] returns the correct length", () => {
1880 assertStrictEquals(preventExtensions
.length
, 1);
1884 describe(".name", () => {
1885 it("[[Get]] returns the correct name", () => {
1886 assertStrictEquals(preventExtensions
.name
, "preventExtensions");
1891 describe("seal", () => {
1892 it("[[Call]] seals the object", () => {
1895 assert(Object
.isSealed(obj
));
1898 it("[[Call]] returns the provided object", () => {
1900 assertStrictEquals(seal(obj
), obj
);
1903 it("[[Construct]] throws an error", () => {
1904 assertThrows(() => new seal({}));
1907 describe(".length", () => {
1908 it("[[Get]] returns the correct length", () => {
1909 assertStrictEquals(seal
.length
, 1);
1913 describe(".name", () => {
1914 it("[[Get]] returns the correct name", () => {
1915 assertStrictEquals(seal
.name
, "seal");
1920 describe("setPropertyValue", () => {
1921 it("[[Call]] sets the provided property on the provided object", () => {
1923 setPropertyValue(obj
, "success", true);
1924 assertStrictEquals(obj
.success
, true);
1927 it("[[Call]] calls setters", () => {
1928 const setter
= spy((_
) => {});
1929 const obj
= Object
.create(null, { success
: { set: setter
} });
1930 setPropertyValue(obj
, "success", true);
1931 assertSpyCalls(setter
, 1);
1932 assertSpyCall(setter
, 0, {
1938 it("[[Call]] walks the prototype chain", () => {
1939 const setter
= spy((_
) => {});
1940 const obj
= Object
.create(
1941 Object
.create(null, { success
: { set: setter
} }),
1943 setPropertyValue(obj
, "success", true);
1944 assertSpyCalls(setter
, 1);
1945 assertSpyCall(setter
, 0, {
1951 it("[[Call]] uses the provided receiver", () => {
1952 const setter
= spy((_
) => {});
1953 const obj
= Object
.create(null, { success
: { set: setter
} });
1954 const receiver
= {};
1955 setPropertyValue(obj
, "success", true, receiver
);
1956 assertSpyCalls(setter
, 1);
1957 assertSpyCall(setter
, 0, {
1963 it("[[Call]] throws if the property can’t be set", () => {
1964 const obj
= Object
.freeze({ failure
: undefined });
1965 assertThrows(() => setPropertyValue(obj
, "failure", true));
1968 it("[[Call]] returns the provided object", () => {
1970 assertStrictEquals(setPropertyValue(obj
, "", undefined), obj
);
1973 it("[[Construct]] throws an error", () => {
1974 assertThrows(() => new setPropertyValue({}, "", undefined));
1977 describe(".length", () => {
1978 it("[[Get]] returns the correct length", () => {
1979 assertStrictEquals(setPropertyValue
.length
, 3);
1983 describe(".name", () => {
1984 it("[[Get]] returns the correct name", () => {
1985 assertStrictEquals(setPropertyValue
.name
, "setPropertyValue");
1990 describe("setPropertyValues", () => {
1991 it("[[Call]] sets the provided properties on the provided object", () => {
1993 setPropertyValues(obj
, { success
: true, all
: "good" });
1994 assertStrictEquals(obj
.success
, true);
1995 assertStrictEquals(obj
.all
, "good");
1998 it("[[Call]] can take multiple objects", () => {
2002 { success
: false, all
: "good" },
2005 assertStrictEquals(obj
.success
, true);
2006 assertStrictEquals(obj
.all
, "good");
2009 it("[[Call]] ignores nullish arguments", () => {
2011 setPropertyValues(obj
, null, undefined, { success
: true });
2012 assertStrictEquals(obj
.success
, true);
2015 it("[[Call]] calls setters", () => {
2016 const setter
= spy((_
) => {});
2017 const obj
= Object
.create(null, { success
: { set: setter
} });
2018 setPropertyValues(obj
, { success
: true });
2019 assertSpyCalls(setter
, 1);
2020 assertSpyCall(setter
, 0, {
2026 it("[[Call]] calls setters multiple times if property appears more than once", () => {
2027 const setter
= spy((_
) => {});
2028 const obj
= Object
.create(null, { success
: { set: setter
} });
2029 setPropertyValues(obj
, { success
: false }, { success
: true });
2030 assertSpyCalls(setter
, 2);
2031 assertSpyCall(setter
, 0, {
2035 assertSpyCall(setter
, 1, {
2041 it("[[Call]] walks the prototype chain", () => {
2042 const setter
= spy((_
) => {});
2043 const obj
= Object
.create(
2044 Object
.create(null, { success
: { set: setter
} }),
2046 setPropertyValues(obj
, { success
: true });
2047 assertSpyCalls(setter
, 1);
2048 assertSpyCall(setter
, 0, {
2054 it("[[Call]] throws if the property can’t be set", () => {
2055 const obj
= Object
.freeze({ failure
: undefined });
2056 assertThrows(() => setPropertyValues(obj
, { failure
: true }));
2059 it("[[Call]] returns the provided object", () => {
2061 assertStrictEquals(setPropertyValues(obj
, { "": undefined }), obj
);
2064 it("[[Construct]] throws an error", () => {
2065 assertThrows(() => new setPropertyValues(obj
, { "": undefined }));
2068 describe(".length", () => {
2069 it("[[Get]] returns the correct length", () => {
2070 assertStrictEquals(setPropertyValues
.length
, 2);
2074 describe(".name", () => {
2075 it("[[Get]] returns the correct name", () => {
2076 assertStrictEquals(setPropertyValues
.name
, "setPropertyValues");
2081 describe("setPrototype", () => {
2082 it("[[Call]] sets object prototypes", () => {
2085 setPrototype(obj
, proto
);
2086 assertStrictEquals(Object
.getPrototypeOf(obj
), proto
);
2089 it("[[Call]] sets null prototypes", () => {
2091 setPrototype(obj
, null);
2092 assertStrictEquals(Object
.getPrototypeOf(obj
), null);
2095 it("[[Call]] can set coercible primitives to their same prototype", () => {
2096 setPrototype(1, Number
.prototype);
2097 setPrototype(Symbol(), Symbol
.prototype);
2100 it("[[Call]] throws when setting coercible primitives to a different prototype", () => {
2101 assertThrows(() => setPrototype(1, Object
.prototype));
2102 assertThrows(() => setPrototype(Symbol(), Object
.prototype));
2105 it("[[Call]] throws for null and undefined", () => {
2106 assertThrows(() => setPrototype(null, Object
.prototype));
2107 assertThrows(() => setPrototype(undefined, Object
.prototype));
2110 it("[[Call]] returns the provided value", () => {
2112 assertStrictEquals(setPrototype(obj
, null), obj
);
2113 assertStrictEquals(setPrototype(1, Number
.prototype), 1);
2116 it("[[Construct]] throws an error", () => {
2117 assertThrows(() => new setPrototype({}, null));
2120 describe(".length", () => {
2121 it("[[Get]] returns the correct length", () => {
2122 assertStrictEquals(setPrototype
.length
, 2);
2126 describe(".name", () => {
2127 it("[[Get]] returns the correct name", () => {
2128 assertStrictEquals(setPrototype
.name
, "setPrototype");
2133 describe("toObject", () => {
2134 it("returns the input for objects", () => {
2136 assertStrictEquals(toObject(obj
), obj
);
2139 it("throws for nullish values", () => {
2140 assertThrows(() => toObject(null));
2141 assertThrows(() => toObject(void {}));
2144 it("returns a wrapper object for other primitives", () => {
2145 const sym
= Symbol();
2146 assertStrictEquals(typeof toObject(sym
), "object");
2147 assertStrictEquals(toObject(sym
).valueOf(), sym
);
2150 it("[[Construct]] throws an error", () => {
2151 assertThrows(() => new toObject({}));
2154 describe(".length", () => {
2155 it("[[Get]] returns the correct length", () => {
2156 assertStrictEquals(toObject
.length
, 1);
2160 describe(".name", () => {
2161 it("[[Get]] returns the correct name", () => {
2162 assertStrictEquals(toObject
.name
, "toObject");
2167 describe("toPropertyKey", () => {
2168 it("returns a string or symbol", () => {
2169 const sym
= Symbol();
2170 assertStrictEquals(toPropertyKey(sym
), sym
);
2172 toPropertyKey(new String("success")),
2177 it("favours the `toString` representation", () => {
2191 it("[[Construct]] throws an error", () => {
2192 assertThrows(() => new toPropertyKey(""));
2195 describe(".length", () => {
2196 it("[[Get]] returns the correct length", () => {
2197 assertStrictEquals(toPropertyKey
.length
, 1);
2201 describe(".name", () => {
2202 it("[[Get]] returns the correct name", () => {
2203 assertStrictEquals(toPropertyKey
.name
, "toPropertyKey");