summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
e144b30)
Also test to ensure that getters and setters are not constructable.
// ♓🌟 Piscēs ∷ function.test.js
// ====================================================================
//
// ♓🌟 Piscēs ∷ function.test.js
// ====================================================================
//
-// Copyright © 2022 Lady [@ Lady’s Computer].
+// Copyright © 2022–2023 Lady [@ Lady’s Computer].
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
import {
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
import {
assertEquals,
assertStrictEquals,
describe,
assertEquals,
assertStrictEquals,
describe,
describe("isCallable", () => {
it("[[Call]] returns true for ordinary functions", () => {
describe("isCallable", () => {
it("[[Call]] returns true for ordinary functions", () => {
- assert(isCallable(function () {}));
+ assertStrictEquals(isCallable(function () {}), true);
});
it("[[Call]] returns true for arrow functions", () => {
});
it("[[Call]] returns true for arrow functions", () => {
- assert(isCallable(() => {}));
+ assertStrictEquals(isCallable(() => {}), true);
});
it("[[Call]] returns true for generator functions", () => {
});
it("[[Call]] returns true for generator functions", () => {
- assert(isCallable(function* () {}));
+ assertStrictEquals(isCallable(function* () {}), true);
});
it("[[Call]] returns true for classes", () => {
});
it("[[Call]] returns true for classes", () => {
- assert(isCallable(class {}));
+ assertStrictEquals(isCallable(class {}), true);
});
it("[[Call]] returns true for builtin functions", () => {
});
it("[[Call]] returns true for builtin functions", () => {
- assert(isCallable(Math.ceil));
+ assertStrictEquals(isCallable(Math.ceil), true);
+ });
+
+ it("[[Call]] returns true for getters", () => {
+ assertStrictEquals(
+ isCallable(
+ Object.getOwnPropertyDescriptor({
+ get foo() {
+ return undefined;
+ },
+ }, "foo").get,
+ ),
+ true,
+ );
+ });
+
+ it("[[Call]] returns true for setters", () => {
+ assertStrictEquals(
+ isCallable(
+ Object.getOwnPropertyDescriptor({
+ set foo($) {
+ /* do nothing */
+ },
+ }, "foo").set,
+ ),
+ true,
+ );
});
it("[[Call]] returns false for null", () => {
});
it("[[Call]] returns false for null", () => {
- assert(!isCallable(null));
+ assertStrictEquals(isCallable(null), false);
});
it("[[Call]] returns false for objects", () => {
});
it("[[Call]] returns false for objects", () => {
- assert(!isCallable({}));
+ assertStrictEquals(isCallable({}), false);
});
});
describe("isConstructor", () => {
it("[[Call]] returns true for ordinary functions", () => {
});
});
describe("isConstructor", () => {
it("[[Call]] returns true for ordinary functions", () => {
- assert(isConstructor(function () {}));
+ assertStrictEquals(isConstructor(function () {}), true);
});
it("[[Call]] returns false for arrow functions", () => {
});
it("[[Call]] returns false for arrow functions", () => {
- assert(!isConstructor(() => {}));
+ assertStrictEquals(isConstructor(() => {}), false);
});
it("[[Call]] returns false for generator functions", () => {
});
it("[[Call]] returns false for generator functions", () => {
- assert(!isConstructor(function* () {}));
+ assertStrictEquals(isConstructor(function* () {}), false);
});
it("[[Call]] returns true for classes", () => {
});
it("[[Call]] returns true for classes", () => {
- assert(isConstructor(class {}));
+ assertStrictEquals(isConstructor(class {}), true);
});
it("[[Call]] returns false for builtin functions", () => {
});
it("[[Call]] returns false for builtin functions", () => {
- assert(!isConstructor(Math.ceil));
+ assertStrictEquals(isConstructor(Math.ceil), false);
+ });
+
+ it("[[Call]] returns false for getters", () => {
+ assertStrictEquals(
+ isConstructor(
+ Object.getOwnPropertyDescriptor({
+ get foo() {
+ return undefined;
+ },
+ }, "foo").get,
+ ),
+ false,
+ );
+ });
+
+ it("[[Call]] returns false for setters", () => {
+ assertStrictEquals(
+ isConstructor(
+ Object.getOwnPropertyDescriptor({
+ set foo($) {
+ /* do nothing */
+ },
+ }, "foo").set,
+ ),
+ false,
+ );
});
it("[[Call]] returns false for null", () => {
});
it("[[Call]] returns false for null", () => {
- assert(!isConstructor(null));
+ assertStrictEquals(isConstructor(null), false);
});
it("[[Call]] returns false for objects", () => {
});
it("[[Call]] returns false for objects", () => {
- assert(!isConstructor({}));
+ assertStrictEquals(isConstructor({}), false);
ordinaryHasInstance(
constructor,
new class extends constructor {}(),
),
ordinaryHasInstance(
constructor,
new class extends constructor {}(),
),