@@ -6,18 +6,60 @@ defmodule KernelTest do
66 test "=~/2" do
77 assert ( "abcd" =~ ~r/ c(d)/ ) == true
88 assert ( "abcd" =~ ~r/ e/ ) == false
9+ assert ( "abcd" =~ ~R/ c(d)/ ) == true
10+ assert ( "abcd" =~ ~R/ e/ ) == false
911
1012 string = "^ab+cd*$"
1113 assert ( string =~ "ab+" ) == true
1214 assert ( string =~ "bb" ) == false
1315
16+ assert ( "abcd" =~ ~r/ / ) == true
17+ assert ( "abcd" =~ ~R/ / ) == true
18+ assert ( "abcd" =~ "" ) == true
19+
20+ assert ( "" =~ ~r/ / ) == true
21+ assert ( "" =~ ~R/ / ) == true
22+ assert ( "" =~ "" ) == true
23+
24+ assert ( "" =~ "abcd" ) == false
25+ assert ( "" =~ ~r/ abcd/ ) == false
26+ assert ( "" =~ ~R/ abcd/ ) == false
27+
1428 assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
1529 1234 =~ "hello"
1630 end
1731
1832 assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
1933 1234 =~ ~r" hello"
2034 end
35+
36+ assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
37+ 1234 =~ ~R" hello"
38+ end
39+
40+ assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
41+ ~r" hello" =~ "hello"
42+ end
43+
44+ assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
45+ ~r" hello" =~ ~r" hello"
46+ end
47+
48+ assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
49+ :abcd =~ ~r/ /
50+ end
51+
52+ assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
53+ :abcd =~ ""
54+ end
55+
56+ assert_raise FunctionClauseError , "no function clause matching in Regex.match?/2" , fn ->
57+ "abcd" =~ nil
58+ end
59+
60+ assert_raise FunctionClauseError , "no function clause matching in Regex.match?/2" , fn ->
61+ "abcd" =~ :abcd
62+ end
2163 end
2264
2365 test "^" do
0 commit comments