1 // ♓🌟 Piscēs ∷ string.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/>.
19 } from "./dev-deps.js";
23 canonicalNumericIndexString
,
30 getFirstSubstringIndex
,
31 getLastSubstringIndex
,
37 splitOnAsciiWhitespace
,
57 stripAndCollapseAsciiWhitespace
,
58 stripLeadingAndTrailingAsciiWhitespace
,
64 describe("Matcher", () => {
65 it("[[Call]] throws an error", () => {
66 assertThrows(() => Matcher(""));
69 it("[[Construct]] accepts a string first argument", () => {
70 assert(new Matcher(""));
73 it("[[Construct]] accepts a unicode regular expression first argument", () => {
74 assert(new Matcher(/(?:)/u));
77 it("[[Construct]] throws with a non·unicode regular expression first argument", () => {
78 assertThrows(() => new Matcher(/(?:)/));
81 it("[[Construct]] creates a callable object", () => {
82 assertStrictEquals(typeof new Matcher(""), "function");
85 it("[[Construct]] creates a new Matcher", () => {
87 Object
.getPrototypeOf(new Matcher("")),
92 it("[[Construct]] creates an object which inherits from RegExp", () => {
93 assert(new Matcher("") instanceof RegExp
);
96 it("[[Construct]] throws when provided with a noncallable, non·null third argument", () => {
97 assertThrows(() => new Matcher("", undefined, "failure"));
100 describe(".length", () => {
101 it("[[Get]] returns the correct length", () => {
102 assertStrictEquals(Matcher
.length
, 1);
106 describe(".name", () => {
107 it("[[Get]] returns the correct name", () => {
108 assertStrictEquals(Matcher
.name
, "Matcher");
112 describe("::dotAll", () => {
113 it("[[Get]] returns true when the dotAll flag is present", () => {
114 assertStrictEquals(new Matcher(/(?:)/su).dotAll
, true);
117 it("[[Get]] returns false when the dotAll flag is not present", () => {
118 assertStrictEquals(new Matcher(/(?:)/u).dotAll
, false);
121 describe(".length", () => {
122 it("[[Get]] returns the correct length", () => {
124 Object
.getOwnPropertyDescriptor(
133 describe(".name", () => {
134 it("[[Get]] returns the correct name", () => {
136 Object
.getOwnPropertyDescriptor(
146 describe("::exec", () => {
147 it("[[Call]] returns the match object given a complete match", () => {
149 [...new Matcher(/.(?<wow>(?:.(?=.))*)(.)?/u).exec("success")],
150 ["success", "ucces", "s"],
154 /.(?<wow>(?:.(?=.))*)(.)?/u,
156 ($) => $ === "success",
158 ["success", "ucces", "s"],
162 it("[[Call]] calls the constraint if the match succeeds", () => {
163 const constraint
= spy((_
) => true);
164 const matcher
= new Matcher("(.).*", undefined, constraint
);
165 const result
= matcher
.exec({
170 assertEquals([...result
], ["etaoin", "e"]);
171 assertSpyCalls(constraint
, 1);
172 assertStrictEquals(constraint
.calls
[0].args
[0], "etaoin");
173 assertEquals([...constraint
.calls
[0].args
[1]], ["etaoin", "e"]);
174 assertStrictEquals(constraint
.calls
[0].args
[2], matcher
);
175 assertStrictEquals(constraint
.calls
[0].self
, undefined);
178 it("[[Call]] does not call the constraint if the match fails", () => {
179 const constraint
= spy((_
) => true);
180 const matcher
= new Matcher("", undefined, constraint
);
181 matcher
.exec("failure");
182 assertSpyCalls(constraint
, 0);
185 it("[[Call]] returns null given a partial match", () => {
186 assertStrictEquals(new Matcher("").exec("failure"), null);
189 it("[[Call]] returns null if the constraint fails", () => {
191 new Matcher(".*", undefined, () => false).exec(""),
196 describe(".length", () => {
197 it("[[Get]] returns the correct length", () => {
198 assertStrictEquals(Matcher
.prototype.exec
.length
, 1);
202 describe(".name", () => {
203 it("[[Get]] returns the correct name", () => {
204 assertStrictEquals(Matcher
.prototype.exec
.name
, "exec");
209 describe("::global", () => {
210 it("[[Get]] returns true when the global flag is present", () => {
211 assertStrictEquals(new Matcher(/(?:)/gu).global
, true);
214 it("[[Get]] returns false when the global flag is not present", () => {
215 assertStrictEquals(new Matcher(/(?:)/u).global
, false);
218 describe(".length", () => {
219 it("[[Get]] returns the correct length", () => {
221 Object
.getOwnPropertyDescriptor(
230 describe(".name", () => {
231 it("[[Get]] returns the correct name", () => {
233 Object
.getOwnPropertyDescriptor(
243 describe("::hasIndices", () => {
244 it("[[Get]] returns true when the hasIndices flag is present", () => {
245 assertStrictEquals(new Matcher(/(?:)/du).hasIndices
, true);
248 it("[[Get]] returns false when the hasIndices flag is not present", () => {
249 assertStrictEquals(new Matcher(/(?:)/u).hasIndices
, false);
252 describe(".length", () => {
253 it("[[Get]] returns the correct length", () => {
255 Object
.getOwnPropertyDescriptor(
264 describe(".name", () => {
265 it("[[Get]] returns the correct name", () => {
267 Object
.getOwnPropertyDescriptor(
277 describe("::ignoreCase", () => {
278 it("[[Get]] returns true when the ignoreCase flag is present", () => {
279 assertStrictEquals(new Matcher(/(?:)/iu).ignoreCase
, true);
282 it("[[Get]] returns false when the ignoreCase flag is not present", () => {
283 assertStrictEquals(new Matcher(/(?:)/u).ignoreCase
, false);
286 describe(".length", () => {
287 it("[[Get]] returns the correct length", () => {
289 Object
.getOwnPropertyDescriptor(
298 describe(".name", () => {
299 it("[[Get]] returns the correct name", () => {
301 Object
.getOwnPropertyDescriptor(
311 describe("::multiline", () => {
312 it("[[Get]] returns true when the multiline flag is present", () => {
313 assertStrictEquals(new Matcher(/(?:)/mu).multiline
, true);
316 it("[[Get]] returns false when the multiline flag is not present", () => {
317 assertStrictEquals(new Matcher(/(?:)/u).multiline
, false);
320 describe(".length", () => {
321 it("[[Get]] returns the correct length", () => {
323 Object
.getOwnPropertyDescriptor(
332 describe(".name", () => {
333 it("[[Get]] returns the correct name", () => {
335 Object
.getOwnPropertyDescriptor(
345 describe("::source", () => {
346 it("[[Get]] returns the RegExp source", () => {
347 assertStrictEquals(new Matcher("").source
, "(?:)");
348 assertStrictEquals(new Matcher(/.*/su).source
, ".*");
351 describe(".length", () => {
352 it("[[Get]] returns the correct length", () => {
354 Object
.getOwnPropertyDescriptor(
363 describe(".name", () => {
364 it("[[Get]] returns the correct name", () => {
366 Object
.getOwnPropertyDescriptor(
376 describe("::sticky", () => {
377 it("[[Get]] returns true when the sticky flag is present", () => {
378 assertStrictEquals(new Matcher(/(?:)/uy).sticky
, true);
381 it("[[Get]] returns false when the sticky flag is not present", () => {
382 assertStrictEquals(new Matcher(/(?:)/u).sticky
, false);
385 describe(".length", () => {
386 it("[[Get]] returns the correct length", () => {
388 Object
.getOwnPropertyDescriptor(
397 describe(".name", () => {
398 it("[[Get]] returns the correct name", () => {
400 Object
.getOwnPropertyDescriptor(
410 describe("::toString", () => {
411 it("[[Call]] returns the string source", () => {
412 assertStrictEquals(new Matcher(/(?:)/u).toString(), "/(?:)/u");
416 describe("::unicode", () => {
417 it("[[Get]] returns true when the unicode flag is present", () => {
418 assertStrictEquals(new Matcher(/(?:)/u).unicode
, true);
421 describe(".length", () => {
422 it("[[Get]] returns the correct length", () => {
424 Object
.getOwnPropertyDescriptor(
433 describe(".name", () => {
434 it("[[Get]] returns the correct name", () => {
436 Object
.getOwnPropertyDescriptor(
446 describe("~", () => {
447 it("[[Call]] returns true for a complete match", () => {
448 assertStrictEquals(new Matcher("")(""), true);
449 assertStrictEquals(new Matcher(/.*/su)("success\nyay"), true);
451 new Matcher(/.*/su, undefined, ($) => $ === "success")(
458 it("[[Call]] calls the constraint if the match succeeds", () => {
459 const constraint
= spy((_
) => true);
460 const matcher
= new Matcher("(.).*", undefined, constraint
);
462 assertSpyCalls(constraint
, 1);
463 assertStrictEquals(constraint
.calls
[0].args
[0], "etaoin");
464 assertEquals([...constraint
.calls
[0].args
[1]], ["etaoin", "e"]);
465 assertStrictEquals(constraint
.calls
[0].args
[2], matcher
);
466 assertStrictEquals(constraint
.calls
[0].self
, undefined);
469 it("[[Call]] does not call the constraint if the match fails", () => {
470 const constraint
= spy((_
) => true);
471 const matcher
= new Matcher("", undefined, constraint
);
473 assertSpyCalls(constraint
, 0);
476 it("[[Call]] returns false for a partial match", () => {
477 assertStrictEquals(new Matcher("")("failure"), false);
478 assertStrictEquals(new Matcher(/.*/u)("failure\nno"), false);
481 it("[[Call]] returns false if the constraint fails", () => {
483 new Matcher(".*", undefined, () => false)(""),
489 describe("~lastIndex", () => {
490 it("[[Get]] returns zero", () => {
491 assertStrictEquals(new Matcher("").lastIndex
, 0);
494 it("[[Set]] fails", () => {
495 assertThrows(() => (new Matcher("").lastIndex
= 1));
499 describe("~length", () => {
500 it("[[Get]] returns one", () => {
501 assertStrictEquals(new Matcher("").length
, 1);
505 describe("~name", () => {
506 it("[[Get]] wraps the stringified regular expression if no name was provided", () => {
507 assertStrictEquals(new Matcher("").name
, "Matcher(/(?:)/u)");
509 new Matcher(/.*/gsu).name
,
514 it("[[Get]] uses the provided name if one was provided", () => {
515 assertStrictEquals(new Matcher("", "success").name
, "success");
520 describe("asciiLowercase", () => {
521 it("[[Call]] lowercases (just) A·S·C·I·I letters", () => {
522 assertStrictEquals(asciiLowercase("aBſÆss FtɁɂß"), "abſÆss ftɁɂß");
525 it("[[Construct]] throws an error", () => {
526 assertThrows(() => new asciiLowercase(""));
529 describe(".length", () => {
530 it("[[Get]] returns the correct length", () => {
531 assertStrictEquals(asciiLowercase
.length
, 1);
535 describe(".name", () => {
536 it("[[Get]] returns the correct name", () => {
537 assertStrictEquals(asciiLowercase
.name
, "asciiLowercase");
542 describe("asciiUppercase", () => {
543 it("[[Call]] uppercases (just) A·S·C·I·I letters", () => {
544 assertStrictEquals(asciiUppercase("aBſÆss FtɁɂß"), "ABſÆSS FTɁɂß");
547 it("[[Construct]] throws an error", () => {
548 assertThrows(() => new asciiUppercase(""));
551 describe(".length", () => {
552 it("[[Get]] returns the correct length", () => {
553 assertStrictEquals(asciiUppercase
.length
, 1);
557 describe(".name", () => {
558 it("[[Get]] returns the correct name", () => {
559 assertStrictEquals(asciiUppercase
.name
, "asciiUppercase");
564 describe("canonicalNumericIndexString", () => {
565 it("[[Call]] returns undefined for nonstrings", () => {
566 assertStrictEquals(canonicalNumericIndexString(1), void {});
569 it("[[Call]] returns undefined for noncanonical strings", () => {
570 assertStrictEquals(canonicalNumericIndexString(""), void {});
571 assertStrictEquals(canonicalNumericIndexString("01"), void {});
573 canonicalNumericIndexString("9007199254740993"),
578 it('[[Call]] returns -0 for "-0"', () => {
579 assertStrictEquals(canonicalNumericIndexString("-0"), -0);
582 it("[[Call]] returns the corresponding number for canonical strings", () => {
583 assertStrictEquals(canonicalNumericIndexString("0"), 0);
584 assertStrictEquals(canonicalNumericIndexString("-0.25"), -0.25);
586 canonicalNumericIndexString("9007199254740992"),
589 assertStrictEquals(canonicalNumericIndexString("NaN"), 0 / 0);
590 assertStrictEquals(canonicalNumericIndexString("Infinity"), 1 / 0);
592 canonicalNumericIndexString("-Infinity"),
597 it("[[Construct]] throws an error", () => {
598 assertThrows(() => new canonicalNumericIndexString(""));
601 describe(".length", () => {
602 it("[[Get]] returns the correct length", () => {
603 assertStrictEquals(canonicalNumericIndexString
.length
, 1);
607 describe(".name", () => {
608 it("[[Get]] returns the correct name", () => {
610 canonicalNumericIndexString
.name
,
611 "canonicalNumericIndexString",
617 describe("characters", () => {
618 it("[[Call]] returns an iterable", () => {
620 typeof characters("")[Symbol
.iterator
],
625 it("[[Call]] returns an iterator", () => {
626 assertStrictEquals(typeof characters("").next
, "function");
629 it("[[Call]] returns a string character iterator", () => {
631 characters("")[Symbol
.toStringTag
],
632 "String Character Iterator",
636 it("[[Call]] iterates over the characters", () => {
638 ...characters("Ii🎙\uDFFF\uDD96\uD83C\uD800🆗☺"),
652 it("[[Construct]] throws an error", () => {
653 assertThrows(() => new characters(""));
656 describe(".length", () => {
657 it("[[Get]] returns the correct length", () => {
658 assertStrictEquals(characters
.length
, 1);
662 describe(".name", () => {
663 it("[[Get]] returns the correct name", () => {
664 assertStrictEquals(characters
.name
, "characters");
669 describe("codeUnits", () => {
670 it("[[Call]] returns an iterable", () => {
672 typeof codeUnits("")[Symbol
.iterator
],
677 it("[[Call]] returns an iterator", () => {
678 assertStrictEquals(typeof codeUnits("").next
, "function");
681 it("[[Call]] returns a string code unit iterator", () => {
683 codeUnits("")[Symbol
.toStringTag
],
684 "String Code Unit Iterator",
688 it("[[Call]] iterates over the code units", () => {
690 ...codeUnits("Ii🎙\uDFFF\uDD96\uD83C\uD800🆗☺"),
706 it("[[Construct]] throws an error", () => {
707 assertThrows(() => new codeUnits(""));
710 describe(".length", () => {
711 it("[[Get]] returns the correct length", () => {
712 assertStrictEquals(codeUnits
.length
, 1);
716 describe(".name", () => {
717 it("[[Get]] returns the correct name", () => {
718 assertStrictEquals(codeUnits
.name
, "codeUnits");
723 describe("codepoints", () => {
724 it("[[Call]] returns an iterable", () => {
726 typeof codepoints("")[Symbol
.iterator
],
731 it("[[Call]] returns an iterator", () => {
732 assertStrictEquals(typeof codepoints("").next
, "function");
735 it("[[Call]] returns a string codepoint iterator", () => {
737 codepoints("")[Symbol
.toStringTag
],
738 "String Codepoint Iterator",
742 it("[[Call]] iterates over the codepoints", () => {
744 ...codepoints("Ii🎙\uDFFF\uDD96\uD83C\uD800🆗☺"),
758 it("[[Construct]] throws an error", () => {
759 assertThrows(() => new codepoints(""));
762 describe(".length", () => {
763 it("[[Get]] returns the correct length", () => {
764 assertStrictEquals(codepoints
.length
, 1);
768 describe(".name", () => {
769 it("[[Get]] returns the correct name", () => {
770 assertStrictEquals(codepoints
.name
, "codepoints");
775 describe("getCharacter", () => {
776 it("[[Call]] returns the character at the provided position", () => {
777 assertStrictEquals(getCharacter("Ii🎙🆗☺", 4), "🆗");
780 it("[[Call]] returns a low surrogate if the provided position splits a character", () => {
781 assertStrictEquals(getCharacter("Ii🎙🆗☺", 5), "\uDD97");
784 it("[[Call]] returns undefined for an out‐of‐bounds index", () => {
785 assertStrictEquals(getCharacter("Ii🎙🆗☺", -1), undefined);
786 assertStrictEquals(getCharacter("Ii🎙🆗☺", 7), undefined);
789 it("[[Construct]] throws an error", () => {
790 assertThrows(() => new getCharacter("a", 0));
793 describe(".length", () => {
794 it("[[Get]] returns the correct length", () => {
795 assertStrictEquals(getCharacter
.length
, 2);
799 describe(".name", () => {
800 it("[[Get]] returns the correct name", () => {
801 assertStrictEquals(getCharacter
.name
, "getCharacter");
806 describe("getCodeUnit", () => {
807 it("[[Call]] returns the code unit at the provided position", () => {
808 assertStrictEquals(getCodeUnit("Ii🎙🆗☺", 4), 0xD83C);
811 it("[[Call]] returns a low surrogate if the provided position splits a character", () => {
812 assertStrictEquals(getCodeUnit("Ii🎙🆗☺", 5), 0xDD97);
815 it("[[Call]] returns undefined for an out‐of‐bounds index", () => {
816 assertStrictEquals(getCodeUnit("Ii🎙🆗☺", -1), undefined);
817 assertStrictEquals(getCodeUnit("Ii🎙🆗☺", 7), undefined);
820 it("[[Construct]] throws an error", () => {
821 assertThrows(() => new getCodeUnit("a", 0));
824 describe(".length", () => {
825 it("[[Get]] returns the correct length", () => {
826 assertStrictEquals(getCodeUnit
.length
, 2);
830 describe(".name", () => {
831 it("[[Get]] returns the correct name", () => {
832 assertStrictEquals(getCodeUnit
.name
, "getCodeUnit");
837 describe("getCodepoint", () => {
838 it("[[Call]] returns the character at the provided position", () => {
839 assertStrictEquals(getCodepoint("Ii🎙🆗☺", 4), 0x1F197);
842 it("[[Call]] returns a low surrogate if the provided position splits a character", () => {
843 assertStrictEquals(getCodepoint("Ii🎙🆗☺", 5), 0xDD97);
846 it("[[Call]] returns undefined for an out‐of‐bounds index", () => {
847 assertStrictEquals(getCodepoint("Ii🎙🆗☺", -1), undefined);
848 assertStrictEquals(getCodepoint("Ii🎙🆗☺", 7), undefined);
851 it("[[Construct]] throws an error", () => {
852 assertThrows(() => new getCodepoint("a", 0));
855 describe(".length", () => {
856 it("[[Get]] returns the correct length", () => {
857 assertStrictEquals(getCodepoint
.length
, 2);
861 describe(".name", () => {
862 it("[[Get]] returns the correct name", () => {
863 assertStrictEquals(getCodepoint
.name
, "getCodepoint");
868 describe("getFirstSubstringIndex", () => {
869 it("[[Call]] returns the index of the first match", () => {
870 assertStrictEquals(getFirstSubstringIndex("Ii🎙🆗☺🆗", "🆗"), 4);
873 it("[[Call]] returns −1 if no match is found", () => {
874 assertStrictEquals(getFirstSubstringIndex("Ii🎙🆗☺🆗", "🆗🆖"), -1);
877 it("[[Call]] returns 0 when provided with an empty string", () => {
878 assertStrictEquals(getFirstSubstringIndex("Ii🎙🆗☺🆗", ""), 0);
881 it("[[Construct]] throws an error", () => {
882 assertThrows(() => new getFirstSubstringIndex("", ""));
885 describe(".length", () => {
886 it("[[Get]] returns the correct length", () => {
887 assertStrictEquals(getFirstSubstringIndex
.length
, 2);
891 describe(".name", () => {
892 it("[[Get]] returns the correct name", () => {
894 getFirstSubstringIndex
.name
,
895 "getFirstSubstringIndex",
901 describe("getLastSubstringIndex", () => {
902 it("[[Call]] returns the index of the first match", () => {
903 assertStrictEquals(getLastSubstringIndex("Ii🎙🆗☺🆗", "🆗"), 7);
906 it("[[Call]] returns −1 if no match is found", () => {
907 assertStrictEquals(getLastSubstringIndex("Ii🎙🆗☺🆗", "🆖🆗"), -1);
910 it("[[Call]] returns the length when provided with an empty string", () => {
912 getLastSubstringIndex("Ii🎙🆗☺🆗", ""),
917 it("[[Construct]] throws an error", () => {
918 assertThrows(() => new getLastSubstringIndex("", ""));
921 describe(".length", () => {
922 it("[[Get]] returns the correct length", () => {
923 assertStrictEquals(getLastSubstringIndex
.length
, 2);
927 describe(".name", () => {
928 it("[[Get]] returns the correct name", () => {
930 getLastSubstringIndex
.name
,
931 "getLastSubstringIndex",
937 describe("isIntegerIndexString", () => {
938 it("[[Call]] returns false for nonstrings", () => {
939 assertStrictEquals(isIntegerIndexString(1), false);
942 it("[[Call]] returns false for noncanonical strings", () => {
943 assertStrictEquals(isIntegerIndexString(""), false);
944 assertStrictEquals(isIntegerIndexString("01"), false);
946 isIntegerIndexString("9007199254740993"),
951 it("[[Call]] returns false for nonfinite numbers", () => {
952 assertStrictEquals(isIntegerIndexString("NaN"), false);
953 assertStrictEquals(isIntegerIndexString("Infinity"), false);
954 assertStrictEquals(isIntegerIndexString("-Infinity"), false);
957 it("[[Call]] returns false for negative numbers", () => {
958 assertStrictEquals(isIntegerIndexString("-0"), false);
959 assertStrictEquals(isIntegerIndexString("-1"), false);
962 it("[[Call]] returns false for nonintegers", () => {
963 assertStrictEquals(isIntegerIndexString("0.25"), false);
964 assertStrictEquals(isIntegerIndexString("1.1"), false);
967 it("[[Call]] returns false for numbers greater than or equal to 2 ** 53", () => {
969 isIntegerIndexString("9007199254740992"),
974 it("[[Call]] returns true for safe canonical integer strings", () => {
975 assertStrictEquals(isIntegerIndexString("0"), true);
976 assertStrictEquals(isIntegerIndexString("9007199254740991"), true);
980 describe("join", () => {
981 it("[[Call]] joins the provided iterator with the provided separartor", () => {
982 assertStrictEquals(join([1, 2, 3, 4].values(), "☂"), "1☂2☂3☂4");
985 it('[[Call]] uses "," if no separator is provided', () => {
986 assertStrictEquals(join([1, 2, 3, 4].values()), "1,2,3,4");
989 it("[[Call]] uses the empty sting for nullish values", () => {
991 join([null, , null, undefined].values(), "☂"),
996 it("[[Construct]] throws an error", () => {
997 assertThrows(() => new join([]));
1000 describe(".length", () => {
1001 it("[[Get]] returns the correct length", () => {
1002 assertStrictEquals(join
.length
, 2);
1006 describe(".name", () => {
1007 it("[[Get]] returns the correct name", () => {
1008 assertStrictEquals(join
.name
, "join");
1013 describe("rawString", () => {
1014 it("[[Call]] acts like String.raw", () => {
1015 assertStrictEquals(rawString
`\nraw${" string"}`, "\\nraw string");
1018 it("[[Construct]] throws an error", () => {
1019 assertThrows(() => new rawString(["string"]));
1022 describe(".length", () => {
1023 it("[[Get]] returns the correct length", () => {
1024 assertStrictEquals(rawString
.length
, 1);
1028 describe(".name", () => {
1029 it("[[Get]] returns the correct name", () => {
1030 assertStrictEquals(rawString
.name
, "rawString");
1035 describe("scalarValues", () => {
1036 it("[[Call]] returns an iterable", () => {
1038 typeof scalarValues("")[Symbol
.iterator
],
1043 it("[[Call]] returns an iterator", () => {
1044 assertStrictEquals(typeof scalarValues("").next
, "function");
1047 it("[[Call]] returns a string scalar value iterator", () => {
1049 scalarValues("")[Symbol
.toStringTag
],
1050 "String Scalar Value Iterator",
1054 it("[[Call]] iterates over the scalar values", () => {
1056 ...scalarValues("Ii🎙\uDFFF\uDD96\uD83C\uD800🆗☺"),
1070 it("[[Construct]] throws an error", () => {
1071 assertThrows(() => new scalarValues(""));
1074 describe(".length", () => {
1075 it("[[Get]] returns the correct length", () => {
1076 assertStrictEquals(scalarValues
.length
, 1);
1080 describe(".name", () => {
1081 it("[[Get]] returns the correct name", () => {
1082 assertStrictEquals(scalarValues
.name
, "scalarValues");
1087 describe("splitOnAsciiWhitespace", () => {
1088 it("[[Call]] splits on sequences of spaces", () => {
1090 splitOnAsciiWhitespace("🅰️ 🅱️ 🆎 🅾️"),
1091 ["🅰️", "🅱️", "🆎", "🅾️"],
1095 it("[[Call]] splits on sequences of tabs", () => {
1097 splitOnAsciiWhitespace("🅰️\t\t\t🅱️\t🆎\t\t🅾️"),
1098 ["🅰️", "🅱️", "🆎", "🅾️"],
1102 it("[[Call]] splits on sequences of carriage returns", () => {
1104 splitOnAsciiWhitespace("🅰️\r\r\r🅱️\r🆎\r\r🅾️"),
1105 ["🅰️", "🅱️", "🆎", "🅾️"],
1109 it("[[Call]] splits on sequences of newlines", () => {
1111 splitOnAsciiWhitespace("🅰️\r\r\r🅱️\r🆎\r\r🅾️"),
1112 ["🅰️", "🅱️", "🆎", "🅾️"],
1116 it("[[Call]] splits on sequences of form feeds", () => {
1118 splitOnAsciiWhitespace("🅰️\f\f\f🅱️\f🆎\f\f🅾️"),
1119 ["🅰️", "🅱️", "🆎", "🅾️"],
1123 it("[[Call]] splits on mixed whitespace", () => {
1125 splitOnAsciiWhitespace("🅰️\f \t\n🅱️\r\n\r🆎\n\f🅾️"),
1126 ["🅰️", "🅱️", "🆎", "🅾️"],
1130 it("[[Call]] returns an array of just the empty string for the empty string", () => {
1131 assertEquals(splitOnAsciiWhitespace(""), [""]);
1134 it("[[Call]] returns a single token if there are no spaces", () => {
1135 assertEquals(splitOnAsciiWhitespace("abcd"), ["abcd"]);
1138 it("[[Call]] does not split on other kinds of whitespace", () => {
1140 splitOnAsciiWhitespace("a\u202F\u205F\xa0\v\0\bb"),
1141 ["a\u202F\u205F\xa0\v\0\bb"],
1145 it("[[Call]] trims leading and trailing whitespace", () => {
1147 splitOnAsciiWhitespace(
1148 "\f\r\n\r\n \n\t🅰️\f \t\n🅱️\r🆎\n\f🅾️\n\f",
1150 ["🅰️", "🅱️", "🆎", "🅾️"],
1154 it("[[Construct]] throws an error", () => {
1155 assertThrows(() => new splitOnAsciiWhitespace(""));
1158 describe(".length", () => {
1159 it("[[Get]] returns the correct length", () => {
1160 assertStrictEquals(splitOnAsciiWhitespace
.length
, 1);
1164 describe(".name", () => {
1165 it("[[Get]] returns the correct name", () => {
1167 splitOnAsciiWhitespace
.name
,
1168 "splitOnAsciiWhitespace",
1174 describe("splitOnCommas", () => {
1175 it("[[Call]] splits on commas", () => {
1177 splitOnCommas("🅰️,🅱️,🆎,🅾️"),
1178 ["🅰️", "🅱️", "🆎", "🅾️"],
1182 it("[[Call]] returns an array of just the empty string for the empty string", () => {
1183 assertEquals(splitOnCommas(""), [""]);
1186 it("[[Call]] returns a single token if there are no commas", () => {
1187 assertEquals(splitOnCommas("abcd"), ["abcd"]);
1190 it("[[Call]] splits into empty strings if there are only commas", () => {
1191 assertEquals(splitOnCommas(",,,"), ["", "", "", ""]);
1194 it("[[Call]] trims leading and trailing whitespace", () => {
1196 splitOnCommas("\f\r\n\r\n \n\t🅰️,🅱️,🆎,🅾️\n\f"),
1197 ["🅰️", "🅱️", "🆎", "🅾️"],
1200 splitOnCommas("\f\r\n\r\n \n\t,,,\n\f"),
1205 it("[[Call]] removes whitespace from the split tokens", () => {
1208 "\f\r\n\r\n \n\t🅰️\f , \t\n🅱️,\r\n\r🆎\n\f,🅾️\n\f",
1210 ["🅰️", "🅱️", "🆎", "🅾️"],
1213 splitOnCommas("\f\r\n\r\n \n\t\f , \t\n,\r\n\r\n\f,\n\f"),
1218 it("[[Construct]] throws an error", () => {
1219 assertThrows(() => new splitOnCommas(""));
1222 describe(".length", () => {
1223 it("[[Get]] returns the correct length", () => {
1224 assertStrictEquals(splitOnCommas
.length
, 1);
1228 describe(".name", () => {
1229 it("[[Get]] returns the correct name", () => {
1230 assertStrictEquals(splitOnCommas
.name
, "splitOnCommas");
1235 describe("stringCatenate", () => {
1236 it("[[Call]] catenates the values", () => {
1237 assertStrictEquals(stringCatenate("the", " values"), "the values");
1240 it("[[Call]] returns an empty string when called with no values", () => {
1241 assertStrictEquals(stringCatenate(), "");
1244 it('[[Call]] uses "undefined" when explicitly provided undefined', () => {
1246 stringCatenate(undefined, undefined),
1247 "undefinedundefined",
1251 it('[[Call]] uses "null" when provided null', () => {
1252 assertStrictEquals(stringCatenate(null, null), "nullnull");
1255 it("[[Construct]] throws an error", () => {
1256 assertThrows(() => new stringCatenate());
1259 describe(".length", () => {
1260 it("[[Get]] returns the correct length", () => {
1261 assertStrictEquals(stringCatenate
.length
, 2);
1265 describe(".name", () => {
1266 it("[[Get]] returns the correct name", () => {
1267 assertStrictEquals(stringCatenate
.name
, "stringCatenate");
1272 describe("stringEndsWith", () => {
1273 it("[[Call]] returns whether the string ends with the thing", () => {
1275 stringEndsWith("very success", " success"),
1278 assertStrictEquals(stringEndsWith("very fail", " success"), false);
1281 it("[[Call]] accepts an offset", () => {
1283 stringEndsWith("very successful", " success", 12),
1288 it("[[Call]] returns true for an empty string test", () => {
1289 assertStrictEquals(stringEndsWith("", ""), true);
1292 it("[[Construct]] throws an error", () => {
1293 assertThrows(() => new stringEndsWith("", ""));
1296 describe(".length", () => {
1297 it("[[Get]] returns the correct length", () => {
1298 assertStrictEquals(stringEndsWith
.length
, 2);
1302 describe(".name", () => {
1303 it("[[Get]] returns the correct name", () => {
1304 assertStrictEquals(stringEndsWith
.name
, "stringEndsWith");
1309 describe("stringFromCodeUnits", () => {
1310 it("[[Call]] makes the string", () => {
1312 stringFromCodeUnits(0xD83C, 0xDD97),
1317 it("[[Call]] throws with non‐integral arguments", () => {
1318 assertThrows(() => stringFromCodeUnits(NaN
));
1319 assertThrows(() => stringFromCodeUnits(Infinity
));
1320 assertThrows(() => stringFromCodeUnits(0.1));
1323 it("[[Call]] throws with arguments out of range", () => {
1324 assertThrows(() => stringFromCodeUnits(-1));
1325 assertThrows(() => stringFromCodeUnits(0x10000));
1328 it("[[Construct]] throws an error", () => {
1329 assertThrows(() => new stringFromCodeUnits([]));
1332 describe(".length", () => {
1333 it("[[Get]] returns the correct length", () => {
1334 assertStrictEquals(stringFromCodeUnits
.length
, 1);
1338 describe(".name", () => {
1339 it("[[Get]] returns the correct name", () => {
1341 stringFromCodeUnits
.name
,
1342 "stringFromCodeUnits",
1348 describe("stringFromCodepoints", () => {
1349 it("[[Call]] makes the string", () => {
1350 assertStrictEquals(stringFromCodepoints(0x1F197), "🆗");
1353 it("[[Call]] throws with non‐integral arguments", () => {
1354 assertThrows(() => stringFromCodepoints(NaN
));
1355 assertThrows(() => stringFromCodepoints(Infinity
));
1356 assertThrows(() => stringFromCodepoints(0.1));
1359 it("[[Call]] throws with arguments out of range", () => {
1360 assertThrows(() => stringFromCodepoints(-1));
1361 assertThrows(() => stringFromCodepoints(0x110000));
1364 it("[[Construct]] throws an error", () => {
1365 assertThrows(() => new stringFromCodepoints([]));
1368 describe(".length", () => {
1369 it("[[Get]] returns the correct length", () => {
1370 assertStrictEquals(stringFromCodepoints
.length
, 1);
1374 describe(".name", () => {
1375 it("[[Get]] returns the correct name", () => {
1377 stringFromCodepoints
.name
,
1378 "stringFromCodepoints",
1384 describe("stringIncludes", () => {
1385 it("[[Call]] returns whether the string includes the thing", () => {
1387 stringIncludes("very success full", " success "),
1391 stringIncludes("very fail full", " success "),
1396 it("[[Call]] accepts an offset", () => {
1398 stringIncludes("maybe success full", " success ", 4),
1402 stringIncludes("maybe success full", " success ", 5),
1406 stringIncludes("maybe success full", " success ", 6),
1411 it("[[Call]] returns true for an empty string test", () => {
1412 assertStrictEquals(stringIncludes("", ""), true);
1415 it("[[Construct]] throws an error", () => {
1416 assertThrows(() => new stringIncludes("", ""));
1419 describe(".length", () => {
1420 it("[[Get]] returns the correct length", () => {
1421 assertStrictEquals(stringIncludes
.length
, 2);
1425 describe(".name", () => {
1426 it("[[Get]] returns the correct name", () => {
1427 assertStrictEquals(stringIncludes
.name
, "stringIncludes");
1432 describe("stringMatch", () => {
1433 it("[[Call]] does the match akin to String::match", () => {
1435 [...stringMatch("very success full", /([sc]+[ue]?)+/)],
1439 [...stringMatch("very success full", /([sc]+)[ue]?/g)],
1440 ["su", "cce", "ss"],
1444 it("[[Construct]] throws an error", () => {
1445 assertThrows(() => new stringMatch("", /(?:)/));
1448 describe(".length", () => {
1449 it("[[Get]] returns the correct length", () => {
1450 assertStrictEquals(stringMatch
.length
, 2);
1454 describe(".name", () => {
1455 it("[[Get]] returns the correct name", () => {
1456 assertStrictEquals(stringMatch
.name
, "stringMatch");
1461 describe("stringMatchAll", () => {
1462 it("[[Call]] does the match akin to String::matchAll", () => {
1464 [...stringMatchAll("very success full", /([sc]+)[ue]?/g)].map((
1467 [["su", "s"], ["cce", "cc"], ["ss", "ss"]],
1471 it("[[Construct]] throws an error", () => {
1472 assertThrows(() => new stringMatchAll("", /(?:)/g));
1475 describe(".length", () => {
1476 it("[[Get]] returns the correct length", () => {
1477 assertStrictEquals(stringMatchAll
.length
, 2);
1481 describe(".name", () => {
1482 it("[[Get]] returns the correct name", () => {
1483 assertStrictEquals(stringMatchAll
.name
, "stringMatchAll");
1488 describe("stringNormalize", () => {
1489 it("[[Call]] normalizes the string properly", () => {
1490 assertStrictEquals(stringNormalize("ẛ", "NFC"), "\u1E9B");
1491 assertStrictEquals(stringNormalize("ẛ", "NFD"), "\u017F\u0307");
1492 assertStrictEquals(stringNormalize("ẛ", "NFKC"), "\u1E61");
1493 assertStrictEquals(stringNormalize("ẛ", "NFKD"), "\u0073\u0307");
1496 it("[[Call]] assumes NFC", () => {
1497 assertStrictEquals(stringNormalize("\u017F\u0307"), "\u1E9B");
1500 it("[[Call]] throws with an invalid form", () => {
1501 assertThrows(() => stringNormalize("", "NFB"));
1504 it("[[Construct]] throws an error", () => {
1505 assertThrows(() => new stringNormalize("", "NFC"));
1508 describe(".length", () => {
1509 it("[[Get]] returns the correct length", () => {
1510 assertStrictEquals(stringNormalize
.length
, 1);
1514 describe(".name", () => {
1515 it("[[Get]] returns the correct name", () => {
1516 assertStrictEquals(stringNormalize
.name
, "stringNormalize");
1521 describe("stringPadEnd", () => {
1522 it("[[Call]] pads the end of the string", () => {
1523 assertStrictEquals(stringPadEnd("xx", 3), "xx ");
1524 assertStrictEquals(stringPadEnd("xx", 3, "o"), "xxo");
1525 assertStrictEquals(stringPadEnd("", 3, "xo"), "xox");
1526 assertStrictEquals(stringPadEnd("xx", 3, ""), "xx");
1529 it("[[Construct]] throws an error", () => {
1530 assertThrows(() => new stringPadEnd("", 1));
1533 describe(".length", () => {
1534 it("[[Get]] returns the correct length", () => {
1535 assertStrictEquals(stringPadEnd
.length
, 2);
1539 describe(".name", () => {
1540 it("[[Get]] returns the correct name", () => {
1541 assertStrictEquals(stringPadEnd
.name
, "stringPadEnd");
1546 describe("stringPadStart", () => {
1547 it("[[Call]] pads the start of the string", () => {
1548 assertStrictEquals(stringPadStart("xx", 3), " xx");
1549 assertStrictEquals(stringPadStart("xx", 3, "o"), "oxx");
1550 assertStrictEquals(stringPadStart("", 3, "xo"), "xox");
1551 assertStrictEquals(stringPadStart("xx", 3, ""), "xx");
1554 it("[[Construct]] throws an error", () => {
1555 assertThrows(() => new stringPadStart("", 1));
1558 describe(".length", () => {
1559 it("[[Get]] returns the correct length", () => {
1560 assertStrictEquals(stringPadStart
.length
, 2);
1564 describe(".name", () => {
1565 it("[[Get]] returns the correct name", () => {
1566 assertStrictEquals(stringPadStart
.name
, "stringPadStart");
1571 describe("stringRepeat", () => {
1572 it("[[Call]] repeats the string", () => {
1573 assertStrictEquals(stringRepeat("xx", 3), "xxxxxx");
1574 assertStrictEquals(stringRepeat("", 3), "");
1575 assertStrictEquals(stringRepeat("xx", 0), "");
1578 it("[[Call]] throws for negative repititions", () => {
1579 assertThrows(() => stringRepeat("", -1));
1582 it("[[Call]] throws for infinite repititions", () => {
1583 assertThrows(() => stringRepeat("", Infinity
));
1586 it("[[Construct]] throws an error", () => {
1587 assertThrows(() => new stringRepeat("", 1));
1590 describe(".length", () => {
1591 it("[[Get]] returns the correct length", () => {
1592 assertStrictEquals(stringRepeat
.length
, 2);
1596 describe(".name", () => {
1597 it("[[Get]] returns the correct name", () => {
1598 assertStrictEquals(stringRepeat
.name
, "stringRepeat");
1603 describe("stringReplace", () => {
1604 it("[[Call]] does the replacement akin to String::replace", () => {
1606 stringReplace("it’s a failure", "failure", "success"),
1611 "very success full",
1619 "very success full",
1622 `${$s[0].length}`.repeat($s
[1].length
) +
1623 $s
[0].substring($s
[1].length
),
1625 "very 2u33e22 full",
1629 it("[[Construct]] throws an error", () => {
1630 assertThrows(() => new stringReplace("", /(?:)/, ""));
1633 describe(".length", () => {
1634 it("[[Get]] returns the correct length", () => {
1635 assertStrictEquals(stringReplace
.length
, 3);
1639 describe(".name", () => {
1640 it("[[Get]] returns the correct name", () => {
1641 assertStrictEquals(stringReplace
.name
, "stringReplace");
1646 describe("stringReplaceAll", () => {
1647 it("[[Call]] does the match akin to String::replaceAll", () => {
1649 stringReplaceAll("it’s a failure failure", "failure", "success"),
1650 "it’s a success success",
1654 "very success full",
1657 `${$s[0].length}`.repeat($s
[1].length
) +
1658 $s
[0].substring($s
[1].length
),
1660 "very 2u33e22 full",
1664 it("[[Construct]] throws an error", () => {
1665 assertThrows(() => new stringReplaceAll("", /(?:)/g));
1668 describe(".length", () => {
1669 it("[[Get]] returns the correct length", () => {
1670 assertStrictEquals(stringReplaceAll
.length
, 3);
1674 describe(".name", () => {
1675 it("[[Get]] returns the correct name", () => {
1676 assertStrictEquals(stringReplaceAll
.name
, "stringReplaceAll");
1681 describe("stringSearch", () => {
1682 it("[[Call]] does the search akin to String::search", () => {
1684 stringSearch("very success full", /([sc]+)[ue]?/),
1688 stringSearch("very fail full", /([sc]+)[ue]?/),
1693 it("[[Construct]] throws an error", () => {
1694 assertThrows(() => new stringSearch("", /(?:)/));
1697 describe(".length", () => {
1698 it("[[Get]] returns the correct length", () => {
1699 assertStrictEquals(stringSearch
.length
, 2);
1703 describe(".name", () => {
1704 it("[[Get]] returns the correct name", () => {
1705 assertStrictEquals(stringSearch
.name
, "stringSearch");
1710 describe("stringSlice", () => {
1711 it("[[Call]] slices the string akin to String::search", () => {
1713 stringSlice("very success full", 5, 12),
1717 stringSlice("very success full", -12, -5),
1722 it("[[Construct]] throws an error", () => {
1723 assertThrows(() => new stringSlice("", 0, 0));
1726 describe(".length", () => {
1727 it("[[Get]] returns the correct length", () => {
1728 assertStrictEquals(stringSlice
.length
, 3);
1732 describe(".name", () => {
1733 it("[[Get]] returns the correct name", () => {
1734 assertStrictEquals(stringSlice
.name
, "stringSlice");
1739 describe("stringSplit", () => {
1740 it("[[Call]] splits the string akin to String::split", () => {
1741 assertEquals(stringSplit("success", ""), [
1750 assertEquals(stringSplit("success", /(?<=[aeiou])(?=[^aeiou])/), [
1755 assertEquals(stringSplit("success", "failure"), ["success"]);
1758 it("[[Call]] recognizes a limit", () => {
1759 assertEquals(stringSplit("success", "", 4), ["s", "u", "c", "c"]);
1762 it("[[Construct]] throws an error", () => {
1763 assertThrows(() => new stringSplit("", ""));
1766 describe(".length", () => {
1767 it("[[Get]] returns the correct length", () => {
1768 assertStrictEquals(stringSplit
.length
, 3);
1772 describe(".name", () => {
1773 it("[[Get]] returns the correct name", () => {
1774 assertStrictEquals(stringSplit
.name
, "stringSplit");
1779 describe("stringStartsWith", () => {
1780 it("[[Call]] returns whether the string starts with the thing", () => {
1782 stringStartsWith("success is had", "success "),
1786 stringStartsWith("no success is had", "success "),
1791 it("[[Call]] accepts an offset", () => {
1793 stringStartsWith("much success is had", "success ", 5),
1798 it("[[Call]] returns true for an empty string test", () => {
1799 assertStrictEquals(stringEndsWith("", ""), true);
1802 it("[[Construct]] throws an error", () => {
1803 assertThrows(() => new stringStartsWith("", ""));
1806 describe(".length", () => {
1807 it("[[Get]] returns the correct length", () => {
1808 assertStrictEquals(stringStartsWith
.length
, 2);
1812 describe(".name", () => {
1813 it("[[Get]] returns the correct name", () => {
1814 assertStrictEquals(stringStartsWith
.name
, "stringStartsWith");
1819 describe("stringStartsWith", () => {
1820 it("[[Call]] returns the string value of a string literal", () => {
1821 assertStrictEquals(stringValue("success"), "success");
1824 it("[[Call]] returns the string value of a string object", () => {
1825 const string
= new String("success");
1826 Object
.defineProperties(string
, {
1827 toString
: { value
: () => "failure" },
1828 valueOf
: { value
: () => "failure" },
1830 assertStrictEquals(stringValue(string
), "success");
1833 it("[[Call]] throws for non‐strings", () => {
1834 assertThrows(() => stringValue(Object
.create(String
.prototype)));
1837 it("[[Construct]] throws an error", () => {
1838 assertThrows(() => new stringValue(""));
1841 describe(".length", () => {
1842 it("[[Get]] returns the correct length", () => {
1843 assertStrictEquals(stringValue
.length
, 1);
1847 describe(".name", () => {
1848 it("[[Get]] returns the correct name", () => {
1849 assertStrictEquals(stringValue
.name
, "stringValue");
1854 describe("stripAndCollapseAsciiWhitespace", () => {
1855 it("[[Call]] collapses mixed inner whitespace", () => {
1857 stripAndCollapseAsciiWhitespace("🅰️\f \t\n🅱️\r\n\r🆎\n\f🅾️"),
1862 it("[[Call]] trims leading and trailing whitespace", () => {
1864 stripAndCollapseAsciiWhitespace(
1865 "\f\r\n\r\n \n\t\f 🅰️\f \t\n🅱️\r\n\r🆎\n\f🅾️\n\f",
1871 it("[[Call]] returns the empty string for strings of whitespace", () => {
1873 stripAndCollapseAsciiWhitespace("\f\r\n\r\n \n\t\f \n\f"),
1878 it("[[Call]] does not collapse other kinds of whitespace", () => {
1880 stripAndCollapseAsciiWhitespace("a\u202F\u205F\xa0\v\0\bb"),
1881 "a\u202F\u205F\xa0\v\0\bb",
1885 it("[[Construct]] throws an error", () => {
1886 assertThrows(() => new stripAndCollapseAsciiWhitespace(""));
1889 describe(".length", () => {
1890 it("[[Get]] returns the correct length", () => {
1891 assertStrictEquals(stripAndCollapseAsciiWhitespace
.length
, 1);
1895 describe(".name", () => {
1896 it("[[Get]] returns the correct name", () => {
1898 stripAndCollapseAsciiWhitespace
.name
,
1899 "stripAndCollapseAsciiWhitespace",
1905 describe("stripLeadingAndTrailingAsciiWhitespace", () => {
1906 it("[[Call]] trims leading and trailing whitespace", () => {
1908 stripLeadingAndTrailingAsciiWhitespace(
1909 "\f\r\n\r\n \n\t\f 🅰️🅱️🆎🅾️\n\f",
1915 it("[[Call]] returns the empty string for strings of whitespace", () => {
1917 stripLeadingAndTrailingAsciiWhitespace("\f\r\n\r\n \n\t\f \n\f"),
1922 it("[[Call]] does not trim other kinds of whitespace", () => {
1924 stripLeadingAndTrailingAsciiWhitespace(
1925 "\v\u202F\u205Fx\0\b\xa0",
1927 "\v\u202F\u205Fx\0\b\xa0",
1931 it("[[Call]] does not adjust inner whitespace", () => {
1933 stripLeadingAndTrailingAsciiWhitespace("a b"),
1938 it("[[Construct]] throws an error", () => {
1939 assertThrows(() => new stripLeadingAndTrailingAsciiWhitespace(""));
1942 describe(".length", () => {
1943 it("[[Get]] returns the correct length", () => {
1945 stripLeadingAndTrailingAsciiWhitespace
.length
,
1951 describe(".name", () => {
1952 it("[[Get]] returns the correct name", () => {
1954 stripLeadingAndTrailingAsciiWhitespace
.name
,
1955 "stripLeadingAndTrailingAsciiWhitespace",
1961 describe("substring", () => {
1962 it("[[Call]] returns the substring", () => {
1964 substring("success", 0),
1968 substring("very success full", 5, 12),
1973 it("[[Construct]] throws an error", () => {
1974 assertThrows(() => new substring("", 0));
1977 describe(".length", () => {
1978 it("[[Get]] returns the correct length", () => {
1979 assertStrictEquals(substring
.length
, 3);
1983 describe(".name", () => {
1984 it("[[Get]] returns the correct name", () => {
1985 assertStrictEquals(substring
.name
, "substring");
1990 describe("toScalarValueString", () => {
1991 it("[[Call]] replaces invalid values", () => {
1993 toScalarValueString("Ii🎙\uDFFF\uDD96\uD83C\uD800🆗☺"),
1994 "Ii🎙\uFFFD\uFFFD\uFFFD\uFFFD🆗☺",
1998 it("[[Construct]] throws an error", () => {
1999 assertThrows(() => new toScalarValueString(""));
2002 describe(".length", () => {
2003 it("[[Get]] returns the correct length", () => {
2004 assertStrictEquals(toScalarValueString
.length
, 1);
2008 describe(".name", () => {
2009 it("[[Get]] returns the correct name", () => {
2011 toScalarValueString
.name
,
2012 "toScalarValueString",
2018 describe("toString", () => {
2019 it("[[Call]] converts to a string", () => {
2030 it("[[Call]] throws when provided a symbol", () => {
2031 assertThrows(() => toString(Symbol()));
2034 it("[[Construct]] throws an error", () => {
2035 assertThrows(() => new toString(""));
2038 describe(".length", () => {
2039 it("[[Get]] returns the correct length", () => {
2040 assertStrictEquals(toString
.length
, 1);
2044 describe(".name", () => {
2045 it("[[Get]] returns the correct name", () => {
2046 assertStrictEquals(toString
.name
, "toString");