@@ -129,29 +129,35 @@ defmodule Regex.BinaryTest do
129
129
end
130
130
131
131
test :escape do
132
- assert escaping ( " . ", ". ")
133
- refute escaping (" . ", " x ")
132
+ assert matches_escaped? ( ". ")
133
+ refute matches_escaped? (" . ", " x ")
134
134
135
- assert escaping(" [ \w ] ", "[ \w] ")
136
- refute escaping (" [ \w] ", " x")
135
+ assert matches_escaped?( " [ \w] ")
136
+ refute matches_escaped? (" [ \w] ", " x")
137
137
138
- assert escaping(" \\ ", "\\ ")
138
+ assert matches_escaped?( " \\ ")
139
139
140
- assert escaping (" \\ xff ", " \\ xff ")
141
- refute escaping (" \\ xff ", " \xff ")
140
+ assert matches_escaped? (" \\xff ", " \\ xff ")
141
+ refute matches_escaped? (" \\ xff ", " \xff ")
142
142
143
- assert escaping(" ( ", "( ")
144
- assert escaping(" ( ) " , "()")
145
- assert escaping ( "(?:foo)" , "(?:foo)" )
143
+ assert matches_escaped?( " ( ")
144
+ assert matches_escaped?( " ( ) ")
145
+ assert matches_escaped? ( "(?:foo)" )
146
146
147
- assert escaping( "\\ A \\ z ", " \\ A \\ z ")
148
- assert escaping(" x ", " x " )
149
- assert escaping ( " x x " , " x x " ) # unicode spaces here
150
- assert escaping( "# lol", "# lol")
147
+ assert matches_escaped? ( "\\ A \\ z" )
148
+ assert matches_escaped? ( " x " )
149
+ assert matches_escaped? ( " x x " ) # unicode spaces here
150
+ assert matches_escaped? ( "# lol" )
151
+
152
+ assert matches_escaped? ( "\\ A.^$*+?()[{\\ | \t \n \xff \\ z #hello\x{202F} \x{205F} " )
153
+ end
154
+
155
+ defp matches_escaped? ( string ) do
156
+ matches_escaped? ( string , string )
151
157
end
152
158
153
- defp escaping ( string , match ) do
154
- Regex . match? % r /#{Regex.escape(string)}/xu , match
159
+ defp matches_escaped? ( string, match) do
160
+ Regex. match? % r /#{Regex.escape(string)}/usimx , match
155
161
end
156
162
end
157
163
0 commit comments