@@ -3,39 +3,6 @@ Code.require_file("test_helper.exs", __DIR__)
33defmodule RegexTest do
44 use ExUnit.Case , async: true
55
6- @ re_21_3_little % Regex {
7- re_pattern:
8- { :re_pattern , 1 , 0 , 0 ,
9- << 69 , 82 , 67 , 80 , 94 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 17 , 0 , 0 , 0 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ,
10- 255 , 99 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 64 , 0 , 6 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
11- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 102 , 111 , 111 , 0 , 131 , 0 , 20 , 29 , 99 , 133 ,
12- 0 , 7 , 0 , 1 , 29 , 100 , 119 , 0 , 5 , 29 , 101 , 120 , 0 , 12 , 120 , 0 , 20 , 0 >> } ,
13- re_version: { "8.42 2018-03-20" , :little } ,
14- source: "c(?<foo>d|e)"
15- }
16-
17- @ re_21_3_big % Regex {
18- re_pattern:
19- { :re_pattern , 1 , 0 , 0 ,
20- << 80 , 67 , 82 , 69 , 0 , 0 , 0 , 86 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 17 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ,
21- 255 , 0 , 99 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 56 , 0 , 6 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
22- 0 , 0 , 0 , 0 , 0 , 0 , 1 , 102 , 111 , 111 , 0 , 131 , 0 , 20 , 29 , 99 , 133 , 0 , 7 , 0 , 1 , 29 , 100 , 119 ,
23- 0 , 5 , 29 , 101 , 120 , 0 , 12 , 120 , 0 , 20 , 0 >> } ,
24- re_version: { "8.42 2018-03-20" , :big } ,
25- source: "c(?<foo>d|e)"
26- }
27-
28- @ re_19_3_little % Regex {
29- re_pattern:
30- { :re_pattern , 1 , 0 , 0 ,
31- << 69 , 82 , 67 , 80 , 94 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 17 , 0 , 0 , 0 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ,
32- 255 , 99 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 64 , 0 , 6 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
33- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 102 , 111 , 111 , 0 , 125 , 0 , 20 , 29 , 99 , 127 ,
34- 0 , 7 , 0 , 1 , 29 , 100 , 113 , 0 , 5 , 29 , 101 , 114 , 0 , 12 , 114 , 0 , 20 , 0 >> } ,
35- re_version: { "8.33 2013-05-29" , :little } ,
36- source: "c(?<foo>d|e)"
37- }
38-
396 doctest Regex
407
418 test "multiline" do
@@ -68,16 +35,9 @@ defmodule RegexTest do
6835 test "literal source" do
6936 assert Regex . source ( Regex . compile! ( "foo" ) ) == "foo"
7037 assert Regex . source ( ~r" foo" ) == "foo"
71- assert Regex . re_pattern ( Regex . compile! ( "foo" ) ) == Regex . re_pattern ( ~r" foo" )
7238
7339 assert Regex . source ( Regex . compile! ( "\a \b \d \e \f \n \r \s \t \v " ) ) == "\a \b \d \e \f \n \r \s \t \v "
7440 assert Regex . source ( ~r< \a \b \d \e \f \n \r \s \t \v > ) == "\\ a\\ b\\ d\\ e\\ f\\ n\\ r\\ s\\ t\\ v"
75-
76- assert Regex . re_pattern ( Regex . compile! ( "\a \b \d \e \f \n \r \s \t \v " ) ) ==
77- Regex . re_pattern ( ~r" \x07 \x08 \x7F \x1B \x0C \x0A \x0D \x20 \x09 \x0B " )
78-
79- assert Regex . re_pattern ( Regex . compile! ( "\\ a\\ b\\ d\e \f \\ n\\ r\\ s\\ t\\ v" ) ) ==
80- Regex . re_pattern ( ~r" \a \b \d \e \f \n \r \s \t \v " )
8141 end
8242
8343 test "Unicode" do
@@ -116,16 +76,6 @@ defmodule RegexTest do
11676 end
11777 end
11878
119- test "recompile/1" do
120- new_regex = ~r/ foo/
121- { :ok , % Regex { } } = Regex . recompile ( new_regex )
122- assert % Regex { } = Regex . recompile! ( new_regex )
123-
124- old_regex = Map . delete ( ~r/ foo/ , :re_version )
125- { :ok , % Regex { } } = Regex . recompile ( old_regex )
126- assert % Regex { } = Regex . recompile! ( old_regex )
127- end
128-
12979 test "opts/1" do
13080 assert Regex . opts ( Regex . compile! ( "foo" , "i" ) ) == [ :caseless ]
13181 assert Regex . opts ( Regex . compile! ( "foo" , [ :ucp ] ) ) == [ :ucp ]
@@ -179,16 +129,6 @@ defmodule RegexTest do
179129 assert Regex . run ( ~r" bar" , "foobar" , offset: 2 , return: :index ) == [ { 3 , 3 } ]
180130 end
181131
182- test "run/3 with regexes compiled in different systems" do
183- assert Regex . run ( @ re_21_3_little , "abcd abce" , capture: :all_names ) == [ "d" ]
184- assert Regex . run ( @ re_21_3_big , "abcd abce" , capture: :all_names ) == [ "d" ]
185- assert Regex . run ( @ re_19_3_little , "abcd abce" , capture: :all_names ) == [ "d" ]
186- end
187-
188- test "run/3 with regexes with options compiled in different systems" do
189- assert Regex . run ( % { ~r/ foo/ i | re_version: "bad version" } , "FOO" ) == [ "FOO" ]
190- end
191-
192132 test "scan/2" do
193133 assert Regex . scan ( ~r" c(d|e)" , "abcd abce" ) == [ [ "cd" , "d" ] , [ "ce" , "e" ] ]
194134 assert Regex . scan ( ~r" c(?:d|e)" , "abcd abce" ) == [ [ "cd" ] , [ "ce" ] ]
@@ -207,16 +147,6 @@ defmodule RegexTest do
207147 assert Regex . scan ( ~r" ^foo" , "foobar" , offset: 1 ) == [ ]
208148 end
209149
210- test "scan/2 with regexes compiled in different systems" do
211- assert Regex . scan ( @ re_21_3_little , "abcd abce" , capture: :all_names ) == [ [ "d" ] , [ "e" ] ]
212- assert Regex . scan ( @ re_21_3_big , "abcd abce" , capture: :all_names ) == [ [ "d" ] , [ "e" ] ]
213- assert Regex . scan ( @ re_19_3_little , "abcd abce" , capture: :all_names ) == [ [ "d" ] , [ "e" ] ]
214- end
215-
216- test "scan/2 with regexes with options compiled in different systems" do
217- assert Regex . scan ( % { ~r/ foo/ i | re_version: "bad version" } , "FOO" ) == [ [ "FOO" ] ]
218- end
219-
220150 test "split/2,3" do
221151 assert Regex . split ( ~r" ," , "" ) == [ "" ]
222152 assert Regex . split ( ~r" ," , "" , trim: true ) == [ ]
0 commit comments