+ describe("~is[[.name]]", () => {
+ it("[[GetOwnProperty]] defines the appropriate method", () => {
+ assertNotStrictEquals(
+ Object.getOwnPropertyDescriptor(
+ createProxyConstructor({}),
+ "isProxy",
+ ),
+ undefined,
+ );
+ assertNotStrictEquals(
+ Object.getOwnPropertyDescriptor(
+ createProxyConstructor({}, function Base() {}),
+ "isBaseProxy",
+ ),
+ undefined,
+ );
+ assertNotStrictEquals(
+ Object.getOwnPropertyDescriptor(
+ createProxyConstructor({}, function Bad() {}, undefined, {
+ name: "⸺",
+ }),
+ "is⸺",
+ ),
+ undefined,
+ );
+ });
+
+ it("[[GetOwnProperty]] has the correct descriptor", () => {
+ const proxyConstructor = createProxyConstructor({});
+ assertEquals(
+ Object.getOwnPropertyDescriptor(
+ proxyConstructor,
+ "isProxy",
+ ),
+ {
+ configurable: true,
+ enumerable: false,
+ value: proxyConstructor.isProxy,
+ writable: true,
+ },
+ );
+ });
+
+ it("[[Call]] returns true for created proxies", () => {
+ const proxyConstructor = createProxyConstructor({});
+ const proxy = new proxyConstructor();
+ assertStrictEquals(
+ proxyConstructor.isProxy(proxy),
+ true,
+ );
+ });
+
+ it("[[Call]] returns false for nonproxies", () => {
+ const constructor = function Base() {};
+ const proxyConstructor = createProxyConstructor({}, constructor);
+ assertStrictEquals(
+ proxyConstructor.isBaseProxy(new constructor()),
+ false,
+ );
+ });
+
+ it("[[Construct]] throws an error", () => {
+ const proxyConstructor = createProxyConstructor({});
+ assertThrows(() => new proxyConstructor.isProxy({}));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ const proxyConstructor = createProxyConstructor({});
+ assertStrictEquals(proxyConstructor.isProxy.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ const proxyConstructor = createProxyConstructor({});
+ assertStrictEquals(proxyConstructor.isProxy.name, "isProxy");
+ const otherProxyConstructor = createProxyConstructor(
+ {},
+ function Base() {},
+ );
+ assertStrictEquals(
+ otherProxyConstructor.isBaseProxy.name,
+ "isBaseProxy",
+ );
+ });
+ });
+ });
+