@@ -39,53 +39,53 @@ defmodule IEx.HelpersTest do
39
39
end
40
40
41
41
test "sets up a breakpoint with capture syntax" do
42
- assert break! ( URI . decode_query ( ) / 2 ) == 1
43
- assert IEx.Pry . breaks ( ) == [ { 1 , URI , { :decode_query , 2 } , 1 } ]
42
+ assert break! ( PryExampleModule . two ( ) / 2 ) == 1
43
+ assert IEx.Pry . breaks ( ) == [ { 1 , PryExampleModule , { :two , 2 } , 1 } ]
44
44
end
45
45
46
46
test "sets up a breakpoint with call syntax" do
47
- assert break! ( URI . decode_query ( _ , % { } ) ) == 1
48
- assert IEx.Pry . breaks ( ) == [ { 1 , URI , { :decode_query , 2 } , 1 } ]
47
+ assert break! ( PryExampleModule . two ( _ , % { } ) ) == 1
48
+ assert IEx.Pry . breaks ( ) == [ { 1 , PryExampleModule , { :two , 2 } , 1 } ]
49
49
end
50
50
51
51
test "sets up a breakpoint with guards syntax" do
52
- assert break! ( URI . decode_query ( _ , map ) when is_map ( map ) ) == 1
53
- assert IEx.Pry . breaks ( ) == [ { 1 , URI , { :decode_query , 2 } , 1 } ]
52
+ assert break! ( PryExampleModule . two ( _ , map ) when is_map ( map ) ) == 1
53
+ assert IEx.Pry . breaks ( ) == [ { 1 , PryExampleModule , { :two , 2 } , 1 } ]
54
54
end
55
55
56
56
test "sets up a breakpoint on the given module" do
57
- assert break! ( URI , :decode_query , 2 ) == 1
58
- assert IEx.Pry . breaks ( ) == [ { 1 , URI , { :decode_query , 2 } , 1 } ]
57
+ assert break! ( PryExampleModule , :two , 2 ) == 1
58
+ assert IEx.Pry . breaks ( ) == [ { 1 , PryExampleModule , { :two , 2 } , 1 } ]
59
59
end
60
60
61
61
test "resets breaks on the given ID" do
62
- assert break! ( URI , :decode_query , 2 ) == 1
62
+ assert break! ( PryExampleModule , :two , 2 ) == 1
63
63
assert reset_break ( 1 ) == :ok
64
- assert IEx.Pry . breaks ( ) == [ { 1 , URI , { :decode_query , 2 } , 0 } ]
64
+ assert IEx.Pry . breaks ( ) == [ { 1 , PryExampleModule , { :two , 2 } , 0 } ]
65
65
end
66
66
67
67
test "resets breaks on the given module" do
68
- assert break! ( URI , :decode_query , 2 ) == 1
69
- assert reset_break ( URI , :decode_query , 2 ) == :ok
70
- assert IEx.Pry . breaks ( ) == [ { 1 , URI , { :decode_query , 2 } , 0 } ]
68
+ assert break! ( PryExampleModule , :two , 2 ) == 1
69
+ assert reset_break ( PryExampleModule , :two , 2 ) == :ok
70
+ assert IEx.Pry . breaks ( ) == [ { 1 , PryExampleModule , { :two , 2 } , 0 } ]
71
71
end
72
72
73
73
test "removes breaks in the given module" do
74
- assert break! ( URI . decode_query ( ) / 2 ) == 1
75
- assert remove_breaks ( URI ) == :ok
74
+ assert break! ( PryExampleModule . two ( ) / 2 ) == 1
75
+ assert remove_breaks ( PryExampleModule ) == :ok
76
76
assert IEx.Pry . breaks ( ) == [ ]
77
77
end
78
78
79
79
test "removes breaks on all modules" do
80
- assert break! ( URI . decode_query ( ) / 2 ) == 1
80
+ assert break! ( PryExampleModule . two ( ) / 2 ) == 1
81
81
assert remove_breaks ( ) == :ok
82
82
assert IEx.Pry . breaks ( ) == [ ]
83
83
end
84
84
85
85
test "errors when setting up a breakpoint with invalid guard" do
86
86
assert capture_io ( :stderr , fn ->
87
87
assert_raise CompileError , fn ->
88
- break! ( URI . decode_query ( _ , map ) when is_whatever ( map ) )
88
+ break! ( PryExampleModule . two ( _ , map ) when is_whatever ( map ) )
89
89
end
90
90
end ) =~ "cannot find or invoke local is_whatever/1"
91
91
end
@@ -98,44 +98,44 @@ defmodule IEx.HelpersTest do
98
98
99
99
test "errors when setting up a break for unknown function" do
100
100
assert_raise RuntimeError ,
101
- "could not set breakpoint, unknown function/macro URI .unknown/2" ,
102
- fn -> break! ( URI , :unknown , 2 ) end
101
+ "could not set breakpoint, unknown function/macro #{ inspect ( PryExampleModule ) } .unknown/2" ,
102
+ fn -> break! ( PryExampleModule , :unknown , 2 ) end
103
103
end
104
104
105
105
test "errors for non-Elixir modules" do
106
106
assert_raise RuntimeError ,
107
- "could not set breakpoint, module :elixir was not written in Elixir" ,
108
- fn -> break! ( :elixir , :unknown , 2 ) end
107
+ "could not set breakpoint, module :maps was not written in Elixir" ,
108
+ fn -> break! ( :maps , :unknown , 2 ) end
109
109
end
110
110
111
111
test "prints table with breaks" do
112
- break! ( URI , :decode_query , 2 )
112
+ break! ( PryExampleModule , :two , 2 )
113
113
114
114
assert capture_io ( fn -> breaks ( ) end ) == """
115
115
116
- ID Module.function/arity Pending stops
117
- ---- ----------------------- ---------------
118
- 1 URI.decode_query/2 1
116
+ ID Module.function/arity Pending stops
117
+ ---- ------------------------ ---------------
118
+ 1 PryExampleModule.two/2 1
119
119
120
120
"""
121
121
122
- assert capture_io ( fn -> URI . decode_query ( "foo=bar" , % { } ) end ) != ""
122
+ assert capture_io ( fn -> PryExampleModule . two ( "foo=bar" , % { } ) end ) != ""
123
123
124
124
assert capture_io ( fn -> breaks ( ) end ) == """
125
125
126
- ID Module.function/arity Pending stops
127
- ---- ----------------------- ---------------
128
- 1 URI.decode_query/2 0
126
+ ID Module.function/arity Pending stops
127
+ ---- ------------------------ ---------------
128
+ 1 PryExampleModule.two/2 0
129
129
130
130
"""
131
131
132
- assert capture_io ( fn -> URI . decode_query ( "foo=bar" , % { } ) end ) == ""
132
+ assert capture_io ( fn -> PryExampleModule . two ( "foo=bar" , % { } ) end ) == ""
133
133
134
134
assert capture_io ( fn -> breaks ( ) end ) == """
135
135
136
- ID Module.function/arity Pending stops
137
- ---- ----------------------- ---------------
138
- 1 URI.decode_query/2 0
136
+ ID Module.function/arity Pending stops
137
+ ---- ------------------------ ---------------
138
+ 1 PryExampleModule.two/2 0
139
139
140
140
"""
141
141
end
@@ -152,6 +152,7 @@ defmodule IEx.HelpersTest do
152
152
@ lists_erl Application . app_dir ( :stdlib , "src/lists.erl" )
153
153
@ httpc_erl "src/http_client/httpc.erl"
154
154
@ editor System . get_env ( "ELIXIR_EDITOR" )
155
+ @ example_module_path "lib/iex/test/test_helper.exs"
155
156
156
157
test "opens __FILE__ and __LINE__" do
157
158
System . put_env ( "ELIXIR_EDITOR" , "echo __LINE__:__FILE__" )
@@ -163,7 +164,8 @@ defmodule IEx.HelpersTest do
163
164
end
164
165
165
166
test "opens Elixir module" do
166
- assert capture_iex ( "open(IEx.Helpers)" ) |> maybe_trim_quotes ( ) =~ ~r/ #{ @ iex_helpers } :5$/
167
+ assert capture_iex ( "open(HelperExampleModule)" ) |> maybe_trim_quotes ( ) =~
168
+ ~r/ #{ @ example_module_path } :\d +$/
167
169
end
168
170
169
171
test "opens function" do
@@ -176,16 +178,19 @@ defmodule IEx.HelpersTest do
176
178
end
177
179
178
180
test "opens module.function" do
179
- assert capture_iex ( "open(IEx.Helpers.b)" ) |> maybe_trim_quotes ( ) =~ ~r/ #{ @ iex_helpers } :\d +$/
180
- assert capture_iex ( "open(IEx.Helpers.h)" ) |> maybe_trim_quotes ( ) =~ ~r/ #{ @ iex_helpers } :\d +$/
181
+ assert capture_iex ( "open(HelperExampleModule.fun)" ) |> maybe_trim_quotes ( ) =~
182
+ ~r/ #{ @ example_module_path } :\d +$/
183
+
184
+ assert capture_iex ( "open(HelperExampleModule.macro)" ) |> maybe_trim_quotes ( ) =~
185
+ ~r/ #{ @ example_module_path } :\d +$/
181
186
end
182
187
183
188
test "opens module.function/arity" do
184
- assert capture_iex ( "open(IEx.Helpers.b /1)" ) |> maybe_trim_quotes ( ) =~
185
- ~r/ #{ @ iex_helpers } :\d +$/
189
+ assert capture_iex ( "open(HelperExampleModule.fun /1)" ) |> maybe_trim_quotes ( ) =~
190
+ ~r/ #{ @ example_module_path } :\d +$/
186
191
187
- assert capture_iex ( "open(IEx.Helpers.h/0 )" ) |> maybe_trim_quotes ( ) =~
188
- ~r/ #{ @ iex_helpers } :\d +$/
192
+ assert capture_iex ( "open(HelperExampleModule.macro/1 )" ) |> maybe_trim_quotes ( ) =~
193
+ ~r/ #{ @ example_module_path } :\d +$/
189
194
end
190
195
191
196
test "opens Erlang module" do
@@ -1440,11 +1445,13 @@ defmodule IEx.HelpersTest do
1440
1445
@ tag :capture_log
1441
1446
test "loads a given module on the given nodes" do
1442
1447
assert nl ( [ node ( ) ] , :lists ) == { :ok , [ { :nonode@nohost , :error , :sticky_directory } ] }
1443
- assert nl ( [ node ( ) ] , Enum ) == { :ok , [ { :nonode@nohost , :loaded , Enum } ] }
1448
+
1449
+ assert nl ( [ node ( ) ] , HelperExampleModule ) ==
1450
+ { :ok , [ { :nonode@nohost , :loaded , HelperExampleModule } ] }
1444
1451
1445
1452
assert nl ( :nonexistent_module ) == { :error , :nofile }
1446
1453
1447
- assert nl ( [ :nosuchnode@badhost ] , Enum ) ==
1454
+ assert nl ( [ :nosuchnode@badhost ] , HelperExampleModule ) ==
1448
1455
{ :ok , [ { :nosuchnode@badhost , :badrpc , :noconnection } ] }
1449
1456
end
1450
1457
end
0 commit comments