@@ -7,39 +7,6 @@ Code.require_file("test_helper.exs", __DIR__)
77defmodule RegexTest do
88 use ExUnit.Case , async: true
99
10- @ re_21_3_little % Regex {
11- re_pattern:
12- { :re_pattern , 1 , 0 , 0 ,
13- << 69 , 82 , 67 , 80 , 94 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 17 , 0 , 0 , 0 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ,
14- 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 ,
15- 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 ,
16- 0 , 7 , 0 , 1 , 29 , 100 , 119 , 0 , 5 , 29 , 101 , 120 , 0 , 12 , 120 , 0 , 20 , 0 >> } ,
17- re_version: { "8.42 2018-03-20" , :little } ,
18- source: "c(?<foo>d|e)"
19- }
20-
21- @ re_21_3_big % Regex {
22- re_pattern:
23- { :re_pattern , 1 , 0 , 0 ,
24- << 80 , 67 , 82 , 69 , 0 , 0 , 0 , 86 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 17 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ,
25- 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 ,
26- 0 , 0 , 0 , 0 , 0 , 0 , 1 , 102 , 111 , 111 , 0 , 131 , 0 , 20 , 29 , 99 , 133 , 0 , 7 , 0 , 1 , 29 , 100 , 119 ,
27- 0 , 5 , 29 , 101 , 120 , 0 , 12 , 120 , 0 , 20 , 0 >> } ,
28- re_version: { "8.42 2018-03-20" , :big } ,
29- source: "c(?<foo>d|e)"
30- }
31-
32- @ re_19_3_little % Regex {
33- re_pattern:
34- { :re_pattern , 1 , 0 , 0 ,
35- << 69 , 82 , 67 , 80 , 94 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 17 , 0 , 0 , 0 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ,
36- 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 ,
37- 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 ,
38- 0 , 7 , 0 , 1 , 29 , 100 , 113 , 0 , 5 , 29 , 101 , 114 , 0 , 12 , 114 , 0 , 20 , 0 >> } ,
39- re_version: { "8.33 2013-05-29" , :little } ,
40- source: "c(?<foo>d|e)"
41- }
42-
4310 doctest Regex
4411
4512 test "multiline" do
@@ -72,16 +39,9 @@ defmodule RegexTest do
7239 test "literal source" do
7340 assert Regex . source ( Regex . compile! ( "foo" ) ) == "foo"
7441 assert Regex . source ( ~r" foo" ) == "foo"
75- assert Regex . re_pattern ( Regex . compile! ( "foo" ) ) == Regex . re_pattern ( ~r" foo" )
7642
7743 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 "
7844 assert Regex . source ( ~r< \a \b \d \e \f \n \r \s \t \v > ) == "\\ a\\ b\\ d\\ e\\ f\\ n\\ r\\ s\\ t\\ v"
79-
80- assert Regex . re_pattern ( Regex . compile! ( "\a \b \d \e \f \n \r \s \t \v " ) ) ==
81- Regex . re_pattern ( ~r" \x07 \x08 \x7F \x1B \x0C \x0A \x0D \x20 \x09 \x0B " )
82-
83- assert Regex . re_pattern ( Regex . compile! ( "\\ a\\ b\\ d\e \f \\ n\\ r\\ s\\ t\\ v" ) ) ==
84- Regex . re_pattern ( ~r" \a \b \d \e \f \n \r \s \t \v " )
8545 end
8646
8747 test "Unicode" do
@@ -120,16 +80,6 @@ defmodule RegexTest do
12080 end
12181 end
12282
123- test "recompile/1" do
124- new_regex = ~r/ foo/
125- { :ok , % Regex { } } = Regex . recompile ( new_regex )
126- assert % Regex { } = Regex . recompile! ( new_regex )
127-
128- old_regex = Map . delete ( ~r/ foo/ , :re_version )
129- { :ok , % Regex { } } = Regex . recompile ( old_regex )
130- assert % Regex { } = Regex . recompile! ( old_regex )
131- end
132-
13383 test "opts/1" do
13484 assert Regex . opts ( Regex . compile! ( "foo" , "i" ) ) == [ :caseless ]
13585 assert Regex . opts ( Regex . compile! ( "foo" , [ :ucp ] ) ) == [ :ucp ]
@@ -183,16 +133,6 @@ defmodule RegexTest do
183133 assert Regex . run ( ~r" bar" , "foobar" , offset: 2 , return: :index ) == [ { 3 , 3 } ]
184134 end
185135
186- test "run/3 with regexes compiled in different systems" do
187- assert Regex . run ( @ re_21_3_little , "abcd abce" , capture: :all_names ) == [ "d" ]
188- assert Regex . run ( @ re_21_3_big , "abcd abce" , capture: :all_names ) == [ "d" ]
189- assert Regex . run ( @ re_19_3_little , "abcd abce" , capture: :all_names ) == [ "d" ]
190- end
191-
192- test "run/3 with regexes with options compiled in different systems" do
193- assert Regex . run ( % { ~r/ foo/ i | re_version: "bad version" } , "FOO" ) == [ "FOO" ]
194- end
195-
196136 test "scan/2" do
197137 assert Regex . scan ( ~r" c(d|e)" , "abcd abce" ) == [ [ "cd" , "d" ] , [ "ce" , "e" ] ]
198138 assert Regex . scan ( ~r" c(?:d|e)" , "abcd abce" ) == [ [ "cd" ] , [ "ce" ] ]
@@ -211,16 +151,6 @@ defmodule RegexTest do
211151 assert Regex . scan ( ~r" ^foo" , "foobar" , offset: 1 ) == [ ]
212152 end
213153
214- test "scan/2 with regexes compiled in different systems" do
215- assert Regex . scan ( @ re_21_3_little , "abcd abce" , capture: :all_names ) == [ [ "d" ] , [ "e" ] ]
216- assert Regex . scan ( @ re_21_3_big , "abcd abce" , capture: :all_names ) == [ [ "d" ] , [ "e" ] ]
217- assert Regex . scan ( @ re_19_3_little , "abcd abce" , capture: :all_names ) == [ [ "d" ] , [ "e" ] ]
218- end
219-
220- test "scan/2 with regexes with options compiled in different systems" do
221- assert Regex . scan ( % { ~r/ foo/ i | re_version: "bad version" } , "FOO" ) == [ [ "FOO" ] ]
222- end
223-
224154 test "split/2,3" do
225155 assert Regex . split ( ~r" ," , "" ) == [ "" ]
226156 assert Regex . split ( ~r" ," , "" , trim: true ) == [ ]
0 commit comments