X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/ecf679353a1fb5fde431eca37c70515b64eb3d05..6e6d4e3261c1c943fe44fa9e381bcf8bf1441fd6:/string.test.js diff --git a/string.test.js b/string.test.js index 52e848c..95c715e 100644 --- a/string.test.js +++ b/string.test.js @@ -1,7 +1,7 @@ // ♓🌟 Piscēs ∷ string.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 @@ -95,17 +95,17 @@ describe("Matcher", () => { it("[[Call]] calls the constraint if the match succeeds", () => { const constraint = spy((_) => true); - const matcher = new Matcher(".*", undefined, constraint); - matcher.exec({ + const matcher = new Matcher("(.).*", undefined, constraint); + const result = matcher.exec({ toString() { return "etaoin"; }, }); assertSpyCalls(constraint, 1); - assertSpyCall(constraint, 0, { - args: ["etaoin", matcher], - self: undefined, - }); + assertStrictEquals(constraint.calls[0].args[0], "etaoin"); + assertEquals([...constraint.calls[0].args[1]], ["etaoin", "e"]); + assertStrictEquals(constraint.calls[0].args[2], matcher); + assertStrictEquals(constraint.calls[0].self, undefined); }); it("[[Call]] does not call the constraint if the match fails", () => { @@ -184,6 +184,12 @@ describe("Matcher", () => { }); }); + describe("::toString", () => { + it("[[Get]] does not throw an error", () => { + new Matcher(/(?:)/u).toString(); + }); + }); + describe("::unicode", () => { it("[[Get]] returns true when the unicode flag is present", () => { assertStrictEquals(new Matcher(/(?:)/u).unicode, true); @@ -204,13 +210,13 @@ describe("Matcher", () => { it("[[Call]] calls the constraint if the match succeeds", () => { const constraint = spy((_) => true); - const matcher = new Matcher(".*", undefined, constraint); + const matcher = new Matcher("(.).*", undefined, constraint); matcher("etaoin"); assertSpyCalls(constraint, 1); - assertSpyCall(constraint, 0, { - args: ["etaoin", matcher], - self: undefined, - }); + assertStrictEquals(constraint.calls[0].args[0], "etaoin"); + assertEquals([...constraint.calls[0].args[1]], ["etaoin", "e"]); + assertStrictEquals(constraint.calls[0].args[2], matcher); + assertStrictEquals(constraint.calls[0].self, undefined); }); it("[[Call]] does not call the constraint if the match fails", () => {