]>
Lady’s Gitweb - Pisces/blob - symbol.test.js
1 // SPDX-FileCopyrightText: 2023, 2025 Lady <https://www.ladys.computer/about/#lady>
2 // SPDX-License-Identifier: MPL-2.0
4 * ⁌ ♓🧩 Piscēs ∷ symbol.test.js
6 * Copyright © 2023, 2025 Lady [@ Ladys Computer].
8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
18 } from "./dev-deps.js";
25 describe("getSymbolDescription", () => {
26 it("[[Call]] returns undefined when the symbol has no description", () => {
27 assertStrictEquals(getSymbolDescription(Symbol()), undefined);
30 it("[[Call]] returns the empty string when the symbol has an empty description", () => {
31 assertStrictEquals(getSymbolDescription(Symbol("")), "");
34 it("[[Call]] returns the description", () => {
36 getSymbolDescription(Symbol("etaoin")),
41 it("[[Construct]] throws an error", () => {
42 assertThrows(() => new getSymbolDescription(Symbol()));
45 describe(".length", () => {
46 it("[[Get]] returns the correct length", () => {
47 assertStrictEquals(getSymbolDescription
.length
, 1);
51 describe(".name", () => {
52 it("[[Get]] returns the correct name", () => {
54 getSymbolDescription
.name
,
55 "getSymbolDescription",
61 describe("symbolToString", () => {
62 it('[[Call]] returns "Symbol()" when the symbol has no description', () => {
63 assertStrictEquals(symbolToString(Symbol()), "Symbol()");
66 it('[[Call]] returns "Symbol()" when the symbol has an empty description', () => {
67 assertStrictEquals(symbolToString(Symbol("")), "Symbol()");
70 it('[[Call]] returns "Symbol()" wrapping the description', () => {
72 symbolToString(Symbol("etaoin")),
77 it("[[Construct]] throws an error", () => {
78 assertThrows(() => new symbolToString(Symbol()));
81 describe(".length", () => {
82 it("[[Get]] returns the correct length", () => {
83 assertStrictEquals(symbolToString
.length
, 1);
87 describe(".name", () => {
88 it("[[Get]] returns the correct name", () => {
97 describe("symbolValue", () => {
98 it("[[Call]] returns the value of a symbol", () => {
99 const symbol
= Symbol();
100 assertStrictEquals(symbolValue(symbol
), symbol
);
103 it("[[Call]] returns the value of a symbol wrapper", () => {
104 const symbol
= Symbol();
105 assertStrictEquals(symbolValue(new Object(symbol
)), symbol
);
108 it("[[Call]] returns the value of a symbol subclass", () => {
109 class SymbolExtension
extends Symbol
{
110 constructor(symbol
) {
111 return Object
.setPrototypeOf(
113 SymbolExtension
.prototype,
117 const symbol
= Symbol();
119 symbolValue(new SymbolExtension(symbol
)),
124 it("[[Construct]] throws an error", () => {
125 assertThrows(() => new symbolValue(Symbol()));
128 describe(".length", () => {
129 it("[[Get]] returns the correct length", () => {
130 assertStrictEquals(symbolValue
.length
, 1);
134 describe(".name", () => {
135 it("[[Get]] returns the correct name", () => {
This page took 0.511211 seconds and 5 git commands to generate.