Skip to content

Commit

Permalink
Support large unicode characters in bracket classes
Browse files Browse the repository at this point in the history
This is an oversight from several commits ago, as I didn't
know these could show up there.
  • Loading branch information
gfredericks committed Aug 11, 2019
1 parent fa86db4 commit 5978a37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/com/gfredericks/test/chuck/regexes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
{:type :large-unicode-character
:code-point code-point}))

(defn ^:private large-unicode-character->string
[code-point]
(str (Character/highSurrogate code-point)
(Character/lowSurrogate code-point)))

(defn analyze
[parsed-regex]
(insta/transform
Expand Down Expand Up @@ -478,6 +483,10 @@
[m]
(charsets/singleton (str (:character m))))

(defmethod compile-class :large-unicode-character
[m]
(charsets/singleton (large-unicode-character->string (:code-point m))))

(defmulti analyzed->generator :type)

(defmethod analyzed->generator :default
Expand Down Expand Up @@ -510,8 +519,7 @@

(defmethod analyzed->generator :large-unicode-character
[{:keys [code-point]}]
(gen/return (str (Character/highSurrogate code-point)
(Character/lowSurrogate code-point))))
(gen/return (large-unicode-character->string code-point)))

(defmethod analyzed->generator :repetition
[{:keys [elements bounds]}]
Expand Down
2 changes: 1 addition & 1 deletion test/com/gfredericks/test/chuck/regexes_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@

;; tests strange behavior in the QE-unquoter related to initial
;; digits
"\\c\\Q0"])
"\\c\\Q0" "[^\\x{2f498}]"])

(defspec generator-regression-spec (times 1000)
;; TODO: make a prop in test.chuck that's like for
Expand Down

0 comments on commit 5978a37

Please sign in to comment.