+describe("getOwnPropertyValue", () => {
+ it("[[Call]] gets the own property value", () => {
+ assertStrictEquals(
+ getOwnPropertyValue({ success: true }, "success"),
+ true,
+ );
+ });
+
+ it("[[Call]] returns undefined for non‐own properties", () => {
+ assertStrictEquals(
+ getOwnPropertyValue(Object.create({ success: true }), "success"),
+ undefined,
+ );
+ });
+
+ it("[[Call]] works for values coercible to objects", () => {
+ assertStrictEquals(getOwnPropertyValue("foo", "length"), 3);
+ });
+
+ it("[[Call]] uses the provided receiver", () => {
+ const target = {};
+ assertStrictEquals(
+ getOwnPropertyValue(
+ {
+ get success() {
+ return this;
+ },
+ },
+ "success",
+ target,
+ ),
+ target,
+ );
+ });
+
+ it("[[Call]] throws for null and undefined", () => {
+ assertThrows(() => getOwnPropertyValue(null));
+ assertThrows(() => getOwnPropertyValue(undefined));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new getOwnPropertyValue({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(getOwnPropertyValue.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ getOwnPropertyValue.name,
+ "getOwnPropertyValue",
+ );
+ });
+ });
+});
+
+describe("getOwnPropertyValues", () => {
+ it("[[Call]] gets own (but not inherited) property values", () => {
+ assertEquals(getOwnPropertyValues({ success: true }), [true]);
+ });
+
+ it("[[Call]] works for values coercible to objects", () => {
+ assertEquals(
+ getOwnPropertyValues("foo"),
+ ["f", "o", "o", 3],
+ );
+ });
+
+ it("[[Call]] uses the provided receiver", () => {
+ const target = {};
+ assertEquals(
+ getOwnPropertyValues({
+ get success() {
+ return this;
+ },
+ }, target),
+ [target],
+ );
+ });
+
+ it("[[Call]] throws for null and undefined", () => {
+ assertThrows(() => getOwnPropertyValues(null));
+ assertThrows(() => getOwnPropertyValues(undefined));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new getOwnPropertyValues({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(getOwnPropertyValues.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ getOwnPropertyValues.name,
+ "getOwnPropertyValues",
+ );
+ });
+ });
+});
+