@@ -6,18 +6,60 @@ defmodule KernelTest do
6
6
test "=~/2" do
7
7
assert ( "abcd" =~ ~r/ c(d)/ ) == true
8
8
assert ( "abcd" =~ ~r/ e/ ) == false
9
+ assert ( "abcd" =~ ~R/ c(d)/ ) == true
10
+ assert ( "abcd" =~ ~R/ e/ ) == false
9
11
10
12
string = "^ab+cd*$"
11
13
assert ( string =~ "ab+" ) == true
12
14
assert ( string =~ "bb" ) == false
13
15
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
+
14
28
assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
15
29
1234 =~ "hello"
16
30
end
17
31
18
32
assert_raise FunctionClauseError , "no function clause matching in Kernel.=~/2" , fn ->
19
33
1234 =~ ~r" hello"
20
34
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
21
63
end
22
64
23
65
test "^" do
0 commit comments