byebug 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/GUIDE.md +2 -2
  4. data/LICENSE +3 -3
  5. data/README.md +5 -4
  6. data/byebug.gemspec +1 -1
  7. data/ext/byebug/byebug.c +20 -19
  8. data/lib/byebug.rb +2 -53
  9. data/lib/byebug/command.rb +9 -109
  10. data/lib/byebug/commands/breakpoints.rb +1 -1
  11. data/lib/byebug/commands/control.rb +20 -21
  12. data/lib/byebug/commands/display.rb +2 -3
  13. data/lib/byebug/commands/eval.rb +6 -16
  14. data/lib/byebug/commands/finish.rb +1 -1
  15. data/lib/byebug/commands/frame.rb +9 -9
  16. data/lib/byebug/commands/help.rb +2 -3
  17. data/lib/byebug/commands/history.rb +28 -0
  18. data/lib/byebug/commands/info.rb +3 -3
  19. data/lib/byebug/commands/list.rb +2 -13
  20. data/lib/byebug/commands/method.rb +5 -45
  21. data/lib/byebug/commands/reload.rb +1 -12
  22. data/lib/byebug/commands/repl.rb +6 -15
  23. data/lib/byebug/commands/save.rb +2 -7
  24. data/lib/byebug/commands/set.rb +45 -116
  25. data/lib/byebug/commands/show.rb +22 -126
  26. data/lib/byebug/commands/stepping.rb +1 -1
  27. data/lib/byebug/commands/trace.rb +14 -25
  28. data/lib/byebug/commands/variables.rb +3 -41
  29. data/lib/byebug/helper.rb +11 -42
  30. data/lib/byebug/history.rb +5 -13
  31. data/lib/byebug/processors/command_processor.rb +6 -6
  32. data/lib/byebug/setting.rb +82 -0
  33. data/lib/byebug/settings/autoeval.rb +20 -0
  34. data/lib/byebug/settings/autoirb.rb +19 -0
  35. data/lib/byebug/settings/autolist.rb +19 -0
  36. data/lib/byebug/settings/autoreload.rb +11 -0
  37. data/lib/byebug/settings/autosave.rb +11 -0
  38. data/lib/byebug/settings/basename.rb +7 -0
  39. data/lib/byebug/settings/callstyle.rb +15 -0
  40. data/lib/byebug/settings/forcestep.rb +11 -0
  41. data/lib/byebug/settings/fullpath.rb +11 -0
  42. data/lib/byebug/settings/histfile.rb +16 -0
  43. data/lib/byebug/settings/histsize.rb +18 -0
  44. data/lib/byebug/settings/linetrace.rb +15 -0
  45. data/lib/byebug/settings/listsize.rb +15 -0
  46. data/lib/byebug/settings/post_mortem.rb +15 -0
  47. data/lib/byebug/settings/stack_on_error.rb +7 -0
  48. data/lib/byebug/settings/testing.rb +7 -0
  49. data/lib/byebug/settings/tracing_plus.rb +7 -0
  50. data/lib/byebug/settings/verbose.rb +7 -0
  51. data/lib/byebug/settings/width.rb +29 -0
  52. data/lib/byebug/version.rb +1 -1
  53. data/test/breakpoints_test.rb +345 -324
  54. data/test/conditions_test.rb +61 -48
  55. data/test/continue_test.rb +38 -27
  56. data/test/debugger_alias_test.rb +5 -3
  57. data/test/display_test.rb +103 -92
  58. data/test/edit_test.rb +42 -34
  59. data/test/eval_test.rb +91 -75
  60. data/test/finish_test.rb +51 -40
  61. data/test/frame_test.rb +197 -184
  62. data/test/help_test.rb +47 -38
  63. data/test/history_test.rb +54 -0
  64. data/test/info_test.rb +306 -293
  65. data/test/interrupt_test.rb +44 -38
  66. data/test/kill_test.rb +40 -31
  67. data/test/list_test.rb +166 -133
  68. data/test/method_test.rb +67 -60
  69. data/test/post_mortem_test.rb +56 -48
  70. data/test/quit_test.rb +44 -35
  71. data/test/reload_test.rb +36 -24
  72. data/test/repl_test.rb +57 -47
  73. data/test/restart_test.rb +56 -69
  74. data/test/save_test.rb +62 -53
  75. data/test/set_test.rb +140 -118
  76. data/test/show_test.rb +68 -201
  77. data/test/source_test.rb +39 -29
  78. data/test/stepping_test.rb +163 -136
  79. data/test/support/test_dsl.rb +9 -11
  80. data/test/test_helper.rb +2 -7
  81. data/test/thread_test.rb +121 -107
  82. data/test/trace_test.rb +86 -83
  83. data/test/variables_test.rb +104 -98
  84. metadata +27 -86
  85. data/test/examples/breakpoint.rb +0 -6
  86. data/test/examples/breakpoint_deep.rb +0 -4
  87. data/test/examples/conditions.rb +0 -4
  88. data/test/examples/continue.rb +0 -5
  89. data/test/examples/display.rb +0 -5
  90. data/test/examples/edit.rb +0 -4
  91. data/test/examples/eval.rb +0 -4
  92. data/test/examples/finish.rb +0 -3
  93. data/test/examples/frame.rb +0 -4
  94. data/test/examples/frame_deep.rb +0 -1
  95. data/test/examples/gcd.rb +0 -15
  96. data/test/examples/hanoi.rb +0 -34
  97. data/test/examples/help.rb +0 -1
  98. data/test/examples/info.rb +0 -6
  99. data/test/examples/info2.rb +0 -3
  100. data/test/examples/interrupt.rb +0 -8
  101. data/test/examples/kill.rb +0 -2
  102. data/test/examples/list.rb +0 -23
  103. data/test/examples/method.rb +0 -4
  104. data/test/examples/post_mortem.rb +0 -4
  105. data/test/examples/primes.rb +0 -25
  106. data/test/examples/quit.rb +0 -2
  107. data/test/examples/reload.rb +0 -6
  108. data/test/examples/repl.rb +0 -6
  109. data/test/examples/restart.rb +0 -6
  110. data/test/examples/save.rb +0 -3
  111. data/test/examples/set.rb +0 -3
  112. data/test/examples/settings.rb +0 -1
  113. data/test/examples/show.rb +0 -1
  114. data/test/examples/source.rb +0 -3
  115. data/test/examples/stepping.rb +0 -8
  116. data/test/examples/stepping_raise_from_c_method.rb +0 -3
  117. data/test/examples/stepping_raise_from_ruby_method.rb +0 -3
  118. data/test/examples/test-triangle.rb +0 -14
  119. data/test/examples/thread.rb +0 -5
  120. data/test/examples/tmate.rb +0 -10
  121. data/test/examples/trace.rb +0 -8
  122. data/test/examples/tri3.rb +0 -6
  123. data/test/examples/triangle.rb +0 -13
  124. data/test/examples/variables.rb +0 -4
  125. data/test/timeout_test.rb +0 -9
@@ -1,230 +1,97 @@
1
- class TestShow < TestDsl::TestCase
2
- describe 'args' do
3
- temporary_change_hash Byebug.settings, :argv, %w{foo bar}
4
-
5
- describe 'default behaviour' do
6
- it 'must show args' do
7
- enter 'show args'
8
- debug_file 'show'
9
- check_output_includes 'Argument list to give program being debugged ' \
10
- 'when it is started is "foo bar".'
1
+ module ShowTest
2
+ class ShowTestCase < TestDsl::TestCase
3
+ before do
4
+ @example = -> do
5
+ byebug
11
6
  end
12
7
  end
13
8
 
14
- describe 'when BYEBUG_SCRIPT is defined' do
15
- temporary_change_const Byebug, 'BYEBUG_SCRIPT', 'bla'
9
+ [:autoeval, :autolist, :autoreload, :autosave, :basename, :forcestep,
10
+ :fullpath, :post_mortem, :stack_on_error, :testing, :linetrace,
11
+ :tracing_plus].each do |setting|
12
+ describe "showing disabled boolean setting #{setting}" do
13
+ temporary_change_hash Byebug::Setting, setting, false
16
14
 
17
- it 'must not show the first arg' do
18
- enter 'show args'
19
- debug_file 'show'
20
- check_output_includes 'Argument list to give program being debugged ' \
21
- 'when it is started is "bar".'
15
+ it 'must show default value' do
16
+ enter "show #{setting}"
17
+ debug_proc(@example)
18
+ check_output_includes "#{setting} is off"
19
+ end
22
20
  end
23
- end
24
- end
25
-
26
- describe 'autolist' do
27
- it 'must show default value' do
28
- enter 'show autolist'
29
- debug_file 'show'
30
- check_output_includes 'autolist is on.'
31
- end
32
- end
33
-
34
- describe 'autoeval' do
35
- it 'must show default value' do
36
- enter 'show autoeval'
37
- debug_file 'show'
38
- check_output_includes 'autoeval is on.'
39
- end
40
- end
41
-
42
- describe 'autoreload' do
43
- it 'must show default value' do
44
- enter 'show autoreload'
45
- debug_file 'show'
46
- check_output_includes 'autoreload is on.'
47
- end
48
- end
49
-
50
- describe 'autoirb' do
51
- before { Byebug::IrbCommand.any_instance.stubs(:execute) }
52
-
53
- it 'must show default value' do
54
- enter 'show autoirb'
55
- debug_file 'show'
56
- check_output_includes 'autoirb is off.'
57
- end
58
- end
59
-
60
- describe 'basename' do
61
- it 'must show default value' do
62
- enter 'show basename'
63
- debug_file 'show'
64
- check_output_includes 'basename is off.'
65
- end
66
- end
67
-
68
- describe 'callstyle' do
69
- it 'must show default value' do
70
- enter 'show callstyle'
71
- debug_file 'show'
72
- check_output_includes 'Frame call-display style is long.'
73
- end
74
- end
75
-
76
- describe 'forcestep' do
77
- it 'must show default value' do
78
- enter 'show forcestep'
79
- debug_file 'show'
80
- check_output_includes 'force-stepping is off.'
81
- end
82
- end
83
-
84
- describe 'fullpath' do
85
- it 'must show default value' do
86
- enter 'show fullpath'
87
- debug_file 'show'
88
- check_output_includes 'Displaying frame\'s full file names is on.'
89
- end
90
- end
91
-
92
- describe 'linetrace' do
93
- it 'must show default value' do
94
- enter 'show linetrace'
95
- debug_file 'show'
96
- check_output_includes 'line tracing is off.'
97
- end
98
- end
99
-
100
- describe 'linetrace_plus' do
101
- it 'must show default value' do
102
- enter 'show linetrace_plus'
103
- debug_file 'show'
104
- check_output_includes 'line tracing style is different consecutive lines.'
105
- end
106
- end
107
21
 
108
- describe 'listsize' do
109
- it 'must show listsize' do
110
- enter 'show listsize'
111
- debug_file 'show'
112
- check_output_includes 'Number of source lines to list is 10.'
113
- end
114
- end
22
+ describe "showing enabled boolean setting #{setting}" do
23
+ temporary_change_hash Byebug::Setting, setting, true
115
24
 
116
- describe 'stack_on_error' do
117
- it 'must show stack_on_error' do
118
- enter 'show stack_on_error'
119
- debug_file 'show'
120
- check_output_includes 'Displaying stack trace is off.'
121
- end
122
- end
123
-
124
- describe 'version' do
125
- it 'must show version' do
126
- enter 'show version'
127
- debug_file 'show'
128
- check_output_includes "Byebug #{Byebug::VERSION}"
129
- end
130
- end
131
-
132
- describe 'width' do
133
- let(:cols) { `stty size`.scan(/\d+/)[1].to_i }
134
-
135
- it 'must show default width' do
136
- enter 'show width'
137
- debug_file 'show'
138
- check_output_includes "Width is #{cols}."
139
- end
140
- end
141
-
142
- describe 'unknown command' do
143
- it 'must show a message' do
144
- enter 'show bla'
145
- debug_file 'show'
146
- check_output_includes 'Unknown show command bla'
25
+ it 'must show default value' do
26
+ enter "show #{setting}"
27
+ debug_proc(@example)
28
+ check_output_includes "#{setting} is on"
29
+ end
30
+ end
147
31
  end
148
- end
149
32
 
150
- describe 'autosave' do
151
- it 'must show default value' do
152
- enter 'show autosave'
153
- debug_file 'show'
154
- check_output_includes 'Saving history is on.'
33
+ describe 'callstyle' do
34
+ it 'must show default value' do
35
+ enter 'show callstyle'
36
+ debug_proc(@example)
37
+ check_output_includes 'Frame display callstyle is :long'
38
+ end
155
39
  end
156
- end
157
40
 
158
- describe 'histfile' do
159
- before { @filename = Byebug::History::DEFAULT_FILE }
160
-
161
- it 'must show history filename' do
162
- enter 'show histfile'
163
- debug_file 'show'
164
- check_output_includes "The command history file is \"#{@filename}\""
41
+ describe 'listsize' do
42
+ it 'must show listsize' do
43
+ enter 'show listsize'
44
+ debug_proc(@example)
45
+ check_output_includes 'Number of source lines to list is 10'
46
+ end
165
47
  end
166
- end
167
48
 
168
- describe 'histsize' do
169
- before { @max_size = Byebug::History::DEFAULT_MAX_SIZE }
49
+ describe 'width' do
50
+ let(:cols) { `stty size`.scan(/\d+/)[1].to_i }
170
51
 
171
- it "must show history's max size" do
172
- enter 'show histsize'
173
- debug_file 'show'
174
- check_output_includes "Byebug history's maximum size is #{@max_size}"
52
+ it 'must show default width' do
53
+ enter 'show width'
54
+ debug_proc(@example)
55
+ check_output_includes "Maximum width of byebug's output is #{cols}"
56
+ end
175
57
  end
176
- end
177
-
178
- describe 'commands' do
179
- temporary_change_const Readline, 'HISTORY', %w(aaa bbb ccc ddd)
180
58
 
181
- describe 'with history disabled' do
182
- temporary_change_hash Byebug.settings, :autosave, false
183
-
184
- it 'must not show records from readline' do
185
- enter 'show commands'
186
- debug_file 'show'
187
- check_output_includes "Not currently saving history. " \
188
- 'Enable it with "set autosave"'
59
+ describe 'unknown command' do
60
+ it 'must show a message' do
61
+ enter 'show bla'
62
+ debug_proc(@example)
63
+ check_output_includes 'Unknown setting :bla'
189
64
  end
190
65
  end
191
66
 
192
- describe 'with history enabled' do
193
- temporary_change_hash Byebug.settings, :autosave, true
67
+ describe 'histfile' do
68
+ before { @filename = Byebug::Setting[:histfile] }
194
69
 
195
- describe 'show records' do
196
- it 'displays last max_size records from readline history' do
197
- enter 'set histsize 3', 'show commands'
198
- debug_file 'show'
199
- check_output_includes(/2 bbb\n 3 ccc\n 4 ddd/)
200
- check_output_doesnt_include(/1 aaa/)
201
- end
70
+ it 'must show history filename' do
71
+ enter 'show histfile'
72
+ debug_proc(@example)
73
+ check_output_includes "The command history file is #{@filename}"
202
74
  end
75
+ end
203
76
 
204
- describe 'max records' do
205
- it 'displays whole history if max_size is bigger than Readline::HISTORY' do
206
- enter 'set histsize 7', 'show commands'
207
- debug_file 'show'
208
- check_output_includes(/1 aaa\n 2 bbb\n 3 ccc\n 4 ddd/)
209
- end
210
- end
77
+ describe 'histsize' do
78
+ before { @max_size = Byebug::Setting[:histsize] }
211
79
 
212
- describe 'with specified size' do
213
- it 'displays the specified number of entries most recent first' do
214
- enter 'show commands 2'
215
- debug_file 'show'
216
- check_output_includes(/3 ccc\n 4 ddd/)
217
- check_output_doesnt_include(/1 aaa\n 2 bbb/)
218
- end
80
+ it "must show history's max size" do
81
+ enter 'show histsize'
82
+ debug_proc(@example)
83
+ check_output_includes \
84
+ "Maximum size of byebug's command history is #{@max_size}"
219
85
  end
220
86
  end
221
- end
222
87
 
223
- describe 'Help' do
224
- it 'must show help when typing just "show"' do
225
- enter 'show', 'cont'
226
- debug_file 'show'
227
- check_output_includes(/List of "show" subcommands:/)
88
+ describe 'Help' do
89
+ it 'must show help when typing just "show"' do
90
+ enter 'show', 'cont'
91
+ debug_proc(@example)
92
+ check_output_includes(/Generic command for showing byebug settings./)
93
+ check_output_includes(/List of settings supported in byebug/)
94
+ end
228
95
  end
229
96
  end
230
97
  end
@@ -1,39 +1,49 @@
1
- class TestSource < TestDsl::TestCase
2
- let(:filename) { 'source_example.txt' }
1
+ module SourceTest
2
+ class SourceTestCase < TestDsl::TestCase
3
+ let(:filename) { 'source_example.txt' }
3
4
 
4
- before { File.open(filename, 'w') do |f|
5
- f.puts 'break 2'
6
- f.puts 'break 3 if true'
7
- end }
5
+ before do
6
+ @example = -> do
7
+ byebug
8
+ a = 2
9
+ a = 3
10
+ end
8
11
 
9
- after { FileUtils.rm(filename) }
12
+ File.open(filename, 'w') do |f|
13
+ f.puts 'break 2'
14
+ f.puts 'break 3 if true'
15
+ end
16
+ end
17
+
18
+ after { FileUtils.rm(filename) }
10
19
 
11
- it 'must run commands from file' do
12
- enter "source #{filename}"
13
- debug_file 'source' do
14
- Byebug.breakpoints[0].pos.must_equal 2
15
- Byebug.breakpoints[1].pos.must_equal 3
16
- Byebug.breakpoints[1].expr.must_equal 'true'
20
+ it 'must run commands from file' do
21
+ enter "source #{filename}"
22
+ debug_proc(@example) do
23
+ Byebug.breakpoints[0].pos.must_equal 2
24
+ Byebug.breakpoints[1].pos.must_equal 3
25
+ Byebug.breakpoints[1].expr.must_equal 'true'
26
+ end
17
27
  end
18
- end
19
28
 
20
- it 'must be able to use shortcut' do
21
- enter "so #{filename}"
22
- debug_file('source') { Byebug.breakpoints[0].pos.must_equal 2 }
23
- end
29
+ it 'must be able to use shortcut' do
30
+ enter "so #{filename}"
31
+ debug_proc(@example) { Byebug.breakpoints[0].pos.must_equal 2 }
32
+ end
24
33
 
25
- it 'must show an error if file is not found' do
26
- enter 'source blabla'
27
- debug_file 'source'
28
- check_error_includes(/File ".*blabla" not found/)
29
- end
34
+ it 'must show an error if file is not found' do
35
+ enter 'source blabla'
36
+ debug_proc(@example)
37
+ check_error_includes(/File ".*blabla" not found/)
38
+ end
30
39
 
31
- describe 'Help' do
32
- it 'must show help when used without arguments' do
33
- enter 'source'
34
- debug_file 'source'
35
- check_output_includes \
36
- "source FILE\texecutes a file containing byebug commands"
40
+ describe 'Help' do
41
+ it 'must show help when used without arguments' do
42
+ enter 'source'
43
+ debug_proc(@example)
44
+ check_output_includes \
45
+ "source FILE\texecutes a file containing byebug commands"
46
+ end
37
47
  end
38
48
  end
39
49
  end
@@ -1,183 +1,210 @@
1
- class SteppingExample
2
- def self.a(num)
3
- num += 2
4
- b(num)
5
- end
6
-
7
- def self.b(num)
8
- v2 = 5 if 1 == num ; [1, 2, v2].map { |t| t.to_f }
9
- c(num)
10
- end
11
-
12
- def self.c(num)
13
- num += 4
14
- num
15
- end
16
- end
17
-
18
- class SteppingRaiseFromRubyMethodExample
19
- def a
20
- b
21
- rescue
22
- 1
23
- end
24
-
25
- def b
26
- c
27
- end
28
-
29
- def c
30
- raise 'bang'
31
- end
32
- end
33
-
34
- class SteppingRaiseFromCMethodExample
35
- def a
36
- b
37
- rescue NameError
38
- 1
39
- end
1
+ module SteppingTest
2
+ class Example
3
+ def self.a(num)
4
+ num += 2
5
+ b(num)
6
+ end
40
7
 
41
- def b
42
- c
43
- end
8
+ def self.b(num)
9
+ v2 = 5 if 1 == num ; [1, 2, v2].map { |t| t.to_f }
10
+ c(num)
11
+ end
44
12
 
45
- def c
46
- d
13
+ def self.c(num)
14
+ num += 4
15
+ num
16
+ end
47
17
  end
48
- end
49
-
50
- class TestStepping < TestDsl::TestCase
51
18
 
52
- describe 'Next Command' do
19
+ class SteppingTestCase < TestDsl::TestCase
20
+ before do
21
+ @example = -> do
22
+ byebug
53
23
 
54
- describe 'method call behaviour' do
55
- before { enter "break #{__FILE__}:8", 'cont' }
56
-
57
- it 'must leave on the same line by default' do
58
- enter 'next'
59
- debug_file('stepping') { state.line.must_equal 8 }
60
- end
61
-
62
- it 'must go to the next line if forced by "plus" sign' do
63
- enter 'next+'
64
- debug_file('stepping') { state.line.must_equal 9 }
65
- end
24
+ ex = Example.a(7)
25
+ 2.times do
26
+ ex += 1
27
+ end
66
28
 
67
- it 'must leave on the same line if forced by "minus" sign' do
68
- enter 'next-'
69
- debug_file('stepping') { state.line.must_equal 8 }
29
+ Example.b(ex)
70
30
  end
31
+ end
71
32
 
72
- describe 'when forcestep is set' do
73
- temporary_change_hash Byebug.settings, :forcestep, true
33
+ describe 'Next Command' do
34
+ describe 'method call behaviour' do
35
+ before { enter 'break 9', 'cont' }
74
36
 
75
- it 'must go to the next line' do
37
+ it 'must leave on the same line by default' do
76
38
  enter 'next'
77
- debug_file('stepping') { state.line.must_equal 9 }
39
+ debug_proc(@example) { state.line.must_equal 9 }
78
40
  end
79
41
 
80
- it 'must go to the next line (by shortcut)' do
81
- enter 'n'
82
- debug_file('stepping') { state.line.must_equal 9 }
42
+ it 'must go to the next line if forced by "plus" sign' do
43
+ enter 'next+'
44
+ debug_proc(@example) { state.line.must_equal 10 }
83
45
  end
84
46
 
85
- it 'must go the specified number of lines forward by default' do
86
- enter 'next 2'
87
- debug_file('stepping') { state.line.must_equal 4 }
47
+ it 'must leave on the same line if forced by "minus" sign' do
48
+ enter 'next-'
49
+ debug_proc(@example) { state.line.must_equal 9 }
88
50
  end
89
51
 
90
- it 'must inform when not staying in the same frame' do
91
- enter 'next 2'
92
- debug_file('stepping')
93
- check_output_includes \
94
- 'Next went up a frame because previous frame finished'
95
- end
52
+ describe 'when forcestep is set' do
53
+ temporary_change_hash Byebug::Setting, :forcestep, true
96
54
 
55
+ it 'must go to the next line' do
56
+ enter 'next'
57
+ debug_proc(@example) { state.line.must_equal 10 }
58
+ end
97
59
 
98
- it 'must ignore it if "minus" is specified' do
99
- enter 'next-'
100
- debug_file('stepping') { state.line.must_equal 8 }
101
- end
102
- end
103
- end
60
+ it 'must go to the next line (by shortcut)' do
61
+ enter 'n'
62
+ debug_proc(@example) { state.line.must_equal 10 }
63
+ end
104
64
 
105
- describe 'block behaviour' do
106
- before { enter 'break 4', 'cont' }
65
+ it 'must go the specified number of lines forward by default' do
66
+ enter 'next 2'
67
+ debug_proc(@example) { state.line.must_equal 25 }
68
+ end
107
69
 
108
- it 'must step over blocks' do
109
- enter 'next'
110
- debug_file('stepping') { state.line.must_equal 8 }
111
- end
112
- end
70
+ it 'must inform when not staying in the same frame' do
71
+ enter 'next 2'
72
+ debug_proc(@example)
73
+ check_output_includes \
74
+ 'Next went up a frame because previous frame finished'
75
+ end
113
76
 
114
- describe 'raise/rescue behaviour' do
115
- describe 'from c method' do
116
- before { enter "break #{__FILE__}:36", 'cont' }
117
77
 
118
- it 'must step over rescue' do
119
- enter 'next'
120
- debug_file('stepping_raise_from_c_method') { state.line.must_equal 38 }
78
+ it 'must ignore it if "minus" is specified' do
79
+ enter 'next-'
80
+ debug_proc(@example) { state.line.must_equal 9 }
81
+ end
121
82
  end
122
83
  end
123
84
 
124
- describe 'from ruby method' do
125
- before { enter "break #{__FILE__}:20", 'cont' }
85
+ describe 'block behaviour' do
86
+ before { enter 'break 57', 'cont' }
126
87
 
127
- it 'must step over rescue' do
88
+ it 'must step over blocks' do
128
89
  enter 'next'
129
- debug_file('stepping_raise_from_ruby_method') { state.line.must_equal 22 }
90
+ debug_proc(@example) { state.line.must_equal 24 }
130
91
  end
131
92
  end
132
- end
133
- end
134
-
135
- describe 'Step Command' do
136
-
137
- describe 'method call behaviour' do
138
- before { enter "break #{__FILE__}:8", 'cont' }
139
93
 
140
- it 'must leave on the same line if forced by a setting' do
141
- enter 'step'
142
- debug_file('stepping') { state.line.must_equal 8 }
143
- end
94
+ describe 'raise/rescue behaviour' do
95
+ describe 'from c method' do
96
+ before do
97
+ @example_raise = -> do
98
+ byebug
99
+
100
+ class RaiseFromCMethodExample
101
+ def a
102
+ b
103
+ rescue NameError
104
+ 1
105
+ end
106
+
107
+ def b
108
+ c
109
+ end
110
+
111
+ def c
112
+ d
113
+ end
114
+ end
115
+
116
+ RaiseFromCMethodExample.new.a
117
+ end
118
+ enter 'break 102', 'cont'
119
+ end
120
+
121
+ it 'must step over rescue' do
122
+ enter 'next'
123
+ debug_proc(@example_raise) { state.line.must_equal 104 }
124
+ end
125
+ end
144
126
 
145
- it 'must go to the step line if forced to do that by "plus" sign' do
146
- enter 'step+'
147
- debug_file('stepping') { state.line.must_equal 9 }
127
+ describe 'from ruby method' do
128
+ before do
129
+ @example_raise = -> do
130
+ byebug
131
+
132
+ class RaiseFromRubyMethodExample
133
+ def a
134
+ b
135
+ rescue
136
+ 1
137
+ end
138
+
139
+ def b
140
+ c
141
+ end
142
+
143
+ def c
144
+ raise 'bang'
145
+ end
146
+ end
147
+
148
+ RaiseFromRubyMethodExample.new.a
149
+ end
150
+ enter 'break 134', 'cont'
151
+ end
152
+
153
+ it 'must step over rescue' do
154
+ enter 'next'
155
+ debug_proc(@example_raise) { state.line.must_equal 136 }
156
+ end
157
+ end
148
158
  end
159
+ end
149
160
 
150
- it 'must leave on the same line if forced to do that by "minus" sign' do
151
- enter 'step-'
152
- debug_file('stepping') { state.line.must_equal 8 }
153
- end
161
+ describe 'Step Command' do
154
162
 
155
- describe 'when forcestep is set' do
156
- temporary_change_hash Byebug.settings, :forcestep, true
163
+ describe 'method call behaviour' do
164
+ before { enter 'break 9', 'cont' }
157
165
 
158
- it 'must go to the step line if forced by a setting' do
166
+ it 'must leave on the same line if forced by a setting' do
159
167
  enter 'step'
160
- debug_file('stepping') { state.line.must_equal 9 }
168
+ debug_proc(@example) { state.line.must_equal 9 }
161
169
  end
162
170
 
163
- it 'must go to the next line if forced by a setting (by shortcut)' do
164
- enter 's'
165
- debug_file('stepping') { state.line.must_equal 9 }
171
+ it 'must go to the step line if forced to do that by "plus" sign' do
172
+ enter 'step+'
173
+ debug_proc(@example) { state.line.must_equal 10 }
166
174
  end
167
175
 
168
- it 'must go the specified number of lines forward by default' do
169
- enter 'step 2'
170
- debug_file('stepping') { state.line.must_equal 13 }
176
+ it 'must leave on the same line if forced to do that by "minus" sign' do
177
+ enter 'step-'
178
+ debug_proc(@example) { state.line.must_equal 9 }
179
+ end
180
+
181
+ describe 'when forcestep is set' do
182
+ temporary_change_hash Byebug::Setting, :forcestep, true
183
+
184
+ it 'must go to the step line if forced by a setting' do
185
+ enter 'step'
186
+ debug_proc(@example) { state.line.must_equal 10 }
187
+ end
188
+
189
+ it 'must go to the next line if forced by a setting (by shortcut)' do
190
+ enter 's'
191
+ debug_proc(@example) { state.line.must_equal 10 }
192
+ end
193
+
194
+ it 'must go the specified number of lines forward by default' do
195
+ enter 'step 2'
196
+ debug_proc(@example) { state.line.must_equal 14 }
197
+ end
171
198
  end
172
199
  end
173
- end
174
200
 
175
- describe 'block behaviour' do
176
- before { enter 'break 4', 'cont' }
201
+ describe 'block behaviour' do
202
+ before { enter 'break 25', 'cont' }
177
203
 
178
- it 'must step into blocks' do
179
- enter 'step'
180
- debug_file('stepping') { state.line.must_equal 5 }
204
+ it 'must step into blocks' do
205
+ enter 'step'
206
+ debug_proc(@example) { state.line.must_equal 26 }
207
+ end
181
208
  end
182
209
  end
183
210
  end