+ assertEquals(
+ [...new Matcher(
+ /.(?<wow>(?:.(?=.))*)(.)?/u,
+ undefined,
+ ($) => $ === "success",
+ ).exec("success")],
+ ["success", "ucces", "s"],
+ );
+ });
+
+ it("[[Call]] calls the constraint if the match succeeds", () => {
+ const constraint = spy((_) => true);
+ const matcher = new Matcher(".*", undefined, constraint);
+ matcher.exec({
+ toString() {
+ return "etaoin";
+ },
+ });
+ assertSpyCalls(constraint, 1);
+ assertSpyCall(constraint, 0, {
+ args: ["etaoin", matcher],
+ self: undefined,
+ });
+ });
+
+ it("[[Call]] does not call the constraint if the match fails", () => {
+ const constraint = spy((_) => true);
+ const matcher = new Matcher("", undefined, constraint);
+ matcher.exec("failure");
+ assertSpyCalls(constraint, 0);