From 4cd21fd7cb787fdcceb9374e3d6418e05a316328 Mon Sep 17 00:00:00 2001 From: guns Date: Sun, 9 Feb 2014 20:06:55 -0600 Subject: [PATCH] Add missing call to escape Before this, (string-pattern "foo?") erroneously returned "foo??". --- src/cljx/frak.cljx | 2 +- test/frak_test.clj | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cljx/frak.cljx b/src/cljx/frak.cljx index 0e255cc..d435889 100644 --- a/src/cljx/frak.cljx +++ b/src/cljx/frak.cljx @@ -139,7 +139,7 @@ (if (and (:terminal? child) (not (seq (:children child)))) (render-trie - (update-in child [:char] #(str % "?")) ) + (update-in child [:char] #(str (escape %) "?"))) (re-group (render-trie child) terminal?))))) (defmethod render-trie ::single-child-non-terminal diff --git a/test/frak_test.clj b/test/frak_test.clj index 3edacbd..c0bf8e5 100644 --- a/test/frak_test.clj +++ b/test/frak_test.clj @@ -59,6 +59,9 @@ (is (= "b(?:i[pt]|at)" (string-pattern ["bat" "bip" "bit"] nil))) + (is (= "foo\\??" + (string-pattern ["foo" "foo?"]))) + (are [words] (every? #(re-matches (pattern words) %) words) ["achy" "achylia" "achylous" "achymia" "achymous"] ["aching" "achingly"])) -- 2.25.1