byebug 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +125 -99
  4. data/CONTRIBUTING.md +4 -6
  5. data/GUIDE.md +42 -20
  6. data/Gemfile +5 -3
  7. data/README.md +2 -3
  8. data/Rakefile +11 -7
  9. data/bin/byebug +2 -252
  10. data/byebug.gemspec +7 -4
  11. data/ext/byebug/byebug.c +17 -18
  12. data/ext/byebug/byebug.h +4 -5
  13. data/ext/byebug/context.c +37 -39
  14. data/ext/byebug/threads.c +39 -18
  15. data/lib/byebug.rb +2 -110
  16. data/lib/byebug/attacher.rb +23 -0
  17. data/lib/byebug/breakpoint.rb +60 -0
  18. data/lib/byebug/command.rb +62 -70
  19. data/lib/byebug/commands/break.rb +24 -24
  20. data/lib/byebug/commands/catchpoint.rb +18 -10
  21. data/lib/byebug/commands/condition.rb +18 -17
  22. data/lib/byebug/commands/continue.rb +17 -9
  23. data/lib/byebug/commands/delete.rb +19 -13
  24. data/lib/byebug/commands/display.rb +19 -53
  25. data/lib/byebug/commands/edit.rb +7 -4
  26. data/lib/byebug/commands/enable_disable.rb +130 -0
  27. data/lib/byebug/commands/eval.rb +40 -22
  28. data/lib/byebug/commands/finish.rb +13 -4
  29. data/lib/byebug/commands/frame.rb +65 -45
  30. data/lib/byebug/commands/help.rb +17 -18
  31. data/lib/byebug/commands/history.rb +14 -8
  32. data/lib/byebug/commands/info.rb +160 -182
  33. data/lib/byebug/commands/interrupt.rb +4 -1
  34. data/lib/byebug/commands/irb.rb +30 -0
  35. data/lib/byebug/commands/kill.rb +7 -8
  36. data/lib/byebug/commands/list.rb +71 -66
  37. data/lib/byebug/commands/method.rb +14 -6
  38. data/lib/byebug/commands/pry.rb +35 -0
  39. data/lib/byebug/commands/quit.rb +9 -6
  40. data/lib/byebug/commands/reload.rb +5 -2
  41. data/lib/byebug/commands/restart.rb +13 -9
  42. data/lib/byebug/commands/save.rb +17 -17
  43. data/lib/byebug/commands/set.rb +16 -15
  44. data/lib/byebug/commands/show.rb +10 -11
  45. data/lib/byebug/commands/source.rb +11 -5
  46. data/lib/byebug/commands/stepping.rb +38 -24
  47. data/lib/byebug/commands/threads.rb +45 -31
  48. data/lib/byebug/commands/trace.rb +22 -9
  49. data/lib/byebug/commands/undisplay.rb +45 -0
  50. data/lib/byebug/commands/variables.rb +83 -27
  51. data/lib/byebug/context.rb +25 -22
  52. data/lib/byebug/core.rb +82 -0
  53. data/lib/byebug/helper.rb +37 -28
  54. data/lib/byebug/history.rb +8 -4
  55. data/lib/byebug/interface.rb +12 -17
  56. data/lib/byebug/interfaces/local_interface.rb +11 -8
  57. data/lib/byebug/interfaces/remote_interface.rb +11 -8
  58. data/lib/byebug/interfaces/script_interface.rb +9 -6
  59. data/lib/byebug/options.rb +46 -0
  60. data/lib/byebug/processor.rb +7 -1
  61. data/lib/byebug/processors/command_processor.rb +135 -125
  62. data/lib/byebug/processors/control_command_processor.rb +23 -23
  63. data/lib/byebug/remote.rb +17 -26
  64. data/lib/byebug/runner.rb +100 -0
  65. data/lib/byebug/setting.rb +33 -8
  66. data/lib/byebug/settings/autoeval.rb +5 -15
  67. data/lib/byebug/settings/autoirb.rb +4 -1
  68. data/lib/byebug/settings/autolist.rb +5 -2
  69. data/lib/byebug/settings/autoreload.rb +5 -2
  70. data/lib/byebug/settings/autosave.rb +6 -2
  71. data/lib/byebug/settings/basename.rb +7 -2
  72. data/lib/byebug/settings/callstyle.rb +4 -1
  73. data/lib/byebug/settings/forcestep.rb +6 -3
  74. data/lib/byebug/settings/fullpath.rb +5 -2
  75. data/lib/byebug/settings/histfile.rb +5 -3
  76. data/lib/byebug/settings/histsize.rb +5 -3
  77. data/lib/byebug/settings/linetrace.rb +4 -1
  78. data/lib/byebug/settings/listsize.rb +5 -1
  79. data/lib/byebug/settings/post_mortem.rb +21 -13
  80. data/lib/byebug/settings/stack_on_error.rb +6 -2
  81. data/lib/byebug/settings/testing.rb +6 -1
  82. data/lib/byebug/settings/tracing_plus.rb +5 -1
  83. data/lib/byebug/settings/verbose.rb +13 -2
  84. data/lib/byebug/settings/width.rb +4 -1
  85. data/lib/byebug/version.rb +1 -1
  86. data/test/{break_test.rb → commands/break_test.rb} +41 -53
  87. data/test/{condition_test.rb → commands/condition_test.rb} +14 -14
  88. data/test/{continue_test.rb → commands/continue_test.rb} +0 -0
  89. data/test/{delete_test.rb → commands/delete_test.rb} +2 -2
  90. data/test/commands/display_test.rb +37 -0
  91. data/test/{edit_test.rb → commands/edit_test.rb} +0 -0
  92. data/test/{eval_test.rb → commands/eval_test.rb} +1 -0
  93. data/test/{finish_test.rb → commands/finish_test.rb} +11 -1
  94. data/test/{frame_test.rb → commands/frame_test.rb} +12 -16
  95. data/test/{help_test.rb → commands/help_test.rb} +21 -4
  96. data/test/{history_test.rb → commands/history_test.rb} +0 -0
  97. data/test/{info_test.rb → commands/info_test.rb} +5 -55
  98. data/test/{interrupt_test.rb → commands/interrupt_test.rb} +0 -0
  99. data/test/commands/irb_test.rb +28 -0
  100. data/test/{kill_test.rb → commands/kill_test.rb} +1 -1
  101. data/test/{list_test.rb → commands/list_test.rb} +1 -1
  102. data/test/{method_test.rb → commands/method_test.rb} +0 -0
  103. data/test/{post_mortem_test.rb → commands/post_mortem_test.rb} +6 -10
  104. data/test/{pry_test.rb → commands/pry_test.rb} +4 -13
  105. data/test/{quit_test.rb → commands/quit_test.rb} +4 -4
  106. data/test/{reload_test.rb → commands/reload_test.rb} +0 -0
  107. data/test/{restart_test.rb → commands/restart_test.rb} +6 -0
  108. data/test/{save_test.rb → commands/save_test.rb} +2 -2
  109. data/test/{set_test.rb → commands/set_test.rb} +9 -2
  110. data/test/{show_test.rb → commands/show_test.rb} +1 -1
  111. data/test/{source_test.rb → commands/source_test.rb} +3 -3
  112. data/test/{stepping_test.rb → commands/stepping_test.rb} +44 -35
  113. data/test/{thread_test.rb → commands/thread_test.rb} +0 -0
  114. data/test/{trace_test.rb → commands/trace_test.rb} +0 -0
  115. data/test/{display_test.rb → commands/undisplay_test.rb} +7 -45
  116. data/test/{variables_test.rb → commands/variables_test.rb} +10 -1
  117. data/test/debugger_alias_test.rb +2 -2
  118. data/test/runner_test.rb +127 -0
  119. data/test/support/matchers.rb +27 -25
  120. data/test/support/test_interface.rb +9 -5
  121. data/test/support/utils.rb +96 -101
  122. data/test/test_helper.rb +32 -20
  123. metadata +93 -68
  124. data/lib/byebug/commands/enable.rb +0 -154
  125. data/lib/byebug/commands/repl.rb +0 -126
  126. data/test/irb_test.rb +0 -47
  127. data/test/support/breakpoint.rb +0 -13
@@ -1,8 +1,11 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to customize the verbosity level for stack frames.
4
+ #
2
5
  class CallstyleSetting < Setting
3
6
  DEFAULT = 'long'
4
7
 
5
- def help
8
+ def banner
6
9
  'Set how you want method call parameters to be displayed'
7
10
  end
8
11
 
@@ -1,11 +1,14 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to force changing lines when executing step or next commands.
4
+ #
2
5
  class ForcestepSetting < Setting
3
- def help
4
- 'If true, next/step commands always move to a new line'
6
+ def banner
7
+ 'Force next/step commands to always move to a new line'
5
8
  end
6
9
 
7
10
  def print
8
- "forced-stepping is #{self.getter}"
11
+ "forced-stepping is #{getter}"
9
12
  end
10
13
  end
11
14
  end
@@ -1,9 +1,12 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to display full paths in backtraces.
4
+ #
2
5
  class FullpathSetting < Setting
3
6
  DEFAULT = true
4
7
 
5
- def help
6
- 'Display full file names in frames'
8
+ def banner
9
+ 'Display full file names in backtraces'
7
10
  end
8
11
  end
9
12
  end
@@ -1,10 +1,12 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to customize the file where byebug's history is saved.
4
+ #
2
5
  class HistfileSetting < Setting
3
6
  DEFAULT = File.expand_path("#{ENV['HOME'] || '.'}/.byebug_hist")
4
7
 
5
- def help
6
- "Customize file where history is loaded from and saved to. By default, " \
7
- "~/.byebug_hist"
8
+ def banner
9
+ 'File where cmd history is saved to. Default: ~/.byebug_hist'
8
10
  end
9
11
 
10
12
  def to_s
@@ -1,10 +1,12 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to customize the number of byebug commands to be saved in history.
4
+ #
2
5
  class HistsizeSetting < Setting
3
6
  DEFAULT = 256
4
7
 
5
- def help
6
- "Customize maximum number of commands that can be stored in byebug's " \
7
- "history record. By default, #{DEFAULT}"
8
+ def banner
9
+ 'Maximum number of commands that can be stored in byebug history'
8
10
  end
9
11
 
10
12
  def to_s
@@ -1,6 +1,9 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to enable/disable linetracing.
4
+ #
2
5
  class LinetraceSetting < Setting
3
- def help
6
+ def banner
4
7
  'Enable line execution tracing'
5
8
  end
6
9
 
@@ -1,8 +1,12 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to customize the number of source code lines to be displayed every
4
+ # time the "list" command is invoked.
5
+ #
2
6
  class ListsizeSetting < Setting
3
7
  DEFAULT = 10
4
8
 
5
- def help
9
+ def banner
6
10
  'Set number of source lines to list by default'
7
11
  end
8
12
 
@@ -1,28 +1,36 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to enable/disable post_mortem mode, i.e., a debugger prompt after
4
+ # program termination by unhandled exception.
5
+ #
2
6
  class PostMortemSetting < Setting
3
- def help
7
+ def initialize
8
+ Byebug.post_mortem = DEFAULT
9
+ end
10
+
11
+ def banner
4
12
  'Enable/disable post-mortem mode'
5
13
  end
6
14
 
7
15
  def value=(v)
8
16
  Byebug.post_mortem = v
9
- at_exit { handle_post_mortem if Byebug.post_mortem? }
10
17
  end
11
18
 
12
19
  def value
13
20
  Byebug.post_mortem?
14
21
  end
22
+ end
15
23
 
16
- private
17
- #
18
- # Saves information about the unhandled exception and gives a byebug
19
- # prompt back to the user before program termination.
20
- #
21
- def handle_post_mortem
22
- context = Byebug.raised_exception.__bb_context
23
- file = Byebug.raised_exception.__bb_file
24
- line = Byebug.raised_exception.__bb_line
25
- Byebug.handler.at_line(context, file, line)
26
- end
24
+ #
25
+ # Saves information about the unhandled exception and gives a byebug
26
+ # prompt back to the user before program termination.
27
+ #
28
+ def self.handle_post_mortem
29
+ context = Byebug.raised_exception.__bb_context
30
+ file = Byebug.raised_exception.__bb_file
31
+ line = Byebug.raised_exception.__bb_line
32
+ Byebug.handler.at_line(context, file, line)
27
33
  end
34
+
35
+ at_exit { Byebug.handle_post_mortem if Byebug.post_mortem? }
28
36
  end
@@ -1,7 +1,11 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to enable/disable the display of backtraces when evaluations raise
4
+ # errors.
5
+ #
2
6
  class StackOnErrorSetting < Setting
3
- def help
4
- 'Display stack trace when "eval" raises an exception'
7
+ def banner
8
+ 'Display stack trace when `eval` raises an exception'
5
9
  end
6
10
  end
7
11
  end
@@ -1,6 +1,11 @@
1
1
  module Byebug
2
+ #
3
+ # Special setting to flag that byebug is being tested.
4
+ #
5
+ # FIXME: make this private.
6
+ #
2
7
  class TestingSetting < Setting
3
- def help
8
+ def banner
4
9
  'Used when testing byebug'
5
10
  end
6
11
  end
@@ -1,6 +1,10 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to allow consecutive repeated lines to be displayed when line
4
+ # tracing is enabled.
5
+ #
2
6
  class TracingPlusSetting < Setting
3
- def help
7
+ def banner
4
8
  'Set line execution tracing to always show different lines'
5
9
  end
6
10
  end
@@ -1,7 +1,18 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to show verbose output about TracePoint API events.
4
+ #
2
5
  class VerboseSetting < Setting
3
- def help
4
- 'Enable verbose output of TracePoint API events'
6
+ def banner
7
+ 'Enable verbose output of TracePoint API events'
8
+ end
9
+
10
+ def value=(v)
11
+ Byebug.verbose = v
12
+ end
13
+
14
+ def value
15
+ Byebug.verbose?
5
16
  end
6
17
  end
7
18
  end
@@ -1,8 +1,11 @@
1
1
  module Byebug
2
+ #
3
+ # Setting to customize the maximum width of byebug's output.
4
+ #
2
5
  class WidthSetting < Setting
3
6
  DEFAULT = 160
4
7
 
5
- def help
8
+ def banner
6
9
  "Number of characters per line in byebug's output"
7
10
  end
8
11
 
@@ -1,3 +1,3 @@
1
1
  module Byebug
2
- VERSION = '3.2.0'
2
+ VERSION = '3.3.0'
3
3
  end
@@ -27,12 +27,12 @@ module Byebug
27
27
  enter 'break 19'
28
28
 
29
29
  debug_proc(@example) do
30
- assert_equal 19, first_brkpt.pos
31
- assert_equal __FILE__, first_brkpt.source
32
- assert_equal nil, first_brkpt.expr
33
- assert_equal 0, first_brkpt.hit_count
34
- assert_equal 0, first_brkpt.hit_value
35
- assert_equal true, first_brkpt.enabled?
30
+ assert_equal 19, Breakpoint.first.pos
31
+ assert_equal __FILE__, Breakpoint.first.source
32
+ assert_equal nil, Breakpoint.first.expr
33
+ assert_equal 0, Breakpoint.first.hit_count
34
+ assert_equal 0, Breakpoint.first.hit_value
35
+ assert_equal true, Breakpoint.first.enabled?
36
36
  end
37
37
  end
38
38
 
@@ -144,26 +144,26 @@ module Byebug
144
144
  end
145
145
 
146
146
  def test_disabling_breakpoints_with_short_syntax_sets_enabled_to_false
147
- enter 'break 19', 'break 20', -> { "disable #{first_brkpt.id}" }
147
+ enter 'break 19', 'break 20', -> { "disable #{Breakpoint.first.id}" }
148
148
 
149
- debug_proc(@example) { assert_equal false, first_brkpt.enabled? }
149
+ debug_proc(@example) { assert_equal false, Breakpoint.first.enabled? }
150
150
  end
151
151
 
152
152
  def test_disabling_breakpoints_with_short_syntax_properly_ignores_them
153
- enter 'break 19', 'break 20', -> { "disable #{first_brkpt.id}" } , 'cont'
153
+ enter 'b 19', 'b 20', -> { "disable #{Breakpoint.first.id}" } , 'cont'
154
154
 
155
155
  debug_proc(@example) { assert_equal 20, state.line }
156
156
  end
157
157
 
158
158
  def test_disabling_breakpoints_with_full_syntax_sets_enabled_to_false
159
- enter 'b 19', 'b 20', -> { "disable breakpoints #{first_brkpt.id}" }
159
+ enter 'b 19', 'b 20', -> { "disable breakpoints #{Breakpoint.first.id}" }
160
160
 
161
- debug_proc(@example) { assert_equal false, first_brkpt.enabled? }
161
+ debug_proc(@example) { assert_equal false, Breakpoint.first.enabled? }
162
162
  end
163
163
 
164
164
  def test_disabling_breakpoints_with_full_syntax_properly_ignores_them
165
- enter 'b 19', 'b 20', -> { "disable breakpoints #{first_brkpt.id}" },
166
- 'cont'
165
+ enter 'break 19', 'break 20',
166
+ -> { "disable breakpoints #{Breakpoint.first.id}" }, 'cont'
167
167
 
168
168
  debug_proc(@example) { assert_equal 20, state.line }
169
169
  end
@@ -172,8 +172,8 @@ module Byebug
172
172
  enter 'break 19', 'break 20', 'disable breakpoints'
173
173
 
174
174
  debug_proc(@example) do
175
- assert_equal false, first_brkpt.enabled?
176
- assert_equal false, last_brkpt.enabled?
175
+ assert_equal false, Breakpoint.first.enabled?
176
+ assert_equal false, Breakpoint.last.enabled?
177
177
  end
178
178
  end
179
179
 
@@ -188,8 +188,8 @@ module Byebug
188
188
  enter 'disable'
189
189
 
190
190
  debug_proc(@example)
191
- check_error_includes \
192
- '"disable" must be followed by "display", "breakpoints" or breakpoint ids'
191
+ check_error_includes '"disable" must be followed by "display", ' \
192
+ '"breakpoints" or breakpoint ids'
193
193
  end
194
194
 
195
195
  def test_disabling_breakpoints_shows_an_error_if_no_breakpoints_are_set
@@ -203,20 +203,20 @@ module Byebug
203
203
  enter 'break 5', 'disable foo'
204
204
 
205
205
  debug_proc(@example)
206
- check_output_includes \
206
+ check_error_includes \
207
207
  '"disable breakpoints" argument "foo" needs to be a number'
208
208
  end
209
209
 
210
210
  def test_enabling_breakpoints_with_short_syntax_sets_enabled_to_true
211
211
  enter 'b 19', 'b 20', 'disable breakpoints',
212
- -> { "enable #{first_brkpt.id}" }
212
+ -> { "enable #{Breakpoint.first.id}" }
213
213
 
214
- debug_proc(@example) { assert_equal true, first_brkpt.enabled? }
214
+ debug_proc(@example) { assert_equal true, Breakpoint.first.enabled? }
215
215
  end
216
216
 
217
217
  def test_enabling_breakpoints_with_short_syntax_stops_at_enabled_breakpoint
218
218
  enter 'break 19', 'break 20', 'disable breakpoints',
219
- -> { "enable #{first_brkpt.id}" }, 'cont'
219
+ -> { "enable #{Breakpoint.first.id}" }, 'cont'
220
220
 
221
221
  debug_proc(@example) { assert_equal 19, state.line }
222
222
  end
@@ -225,8 +225,8 @@ module Byebug
225
225
  enter 'break 19', 'break 20', 'disable breakpoints', 'enable breakpoints'
226
226
 
227
227
  debug_proc(@example) do
228
- assert_equal true, first_brkpt.enabled?
229
- assert_equal true, last_brkpt.enabled?
228
+ assert_equal true, Breakpoint.first.enabled?
229
+ assert_equal true, Breakpoint.last.enabled?
230
230
  end
231
231
  end
232
232
 
@@ -245,14 +245,14 @@ module Byebug
245
245
 
246
246
  def test_enabling_breakpoints_with_full_syntax_sets_enabled_to_false
247
247
  enter 'break 19', 'break 20', 'disable breakpoints',
248
- -> { "enable breakpoints #{last_brkpt.id}" }
248
+ -> { "enable breakpoints #{Breakpoint.last.id}" }
249
249
 
250
- debug_proc(@example) { assert_equal false, first_brkpt.enabled? }
250
+ debug_proc(@example) { assert_equal false, Breakpoint.first.enabled? }
251
251
  end
252
252
 
253
253
  def test_enabling_breakpoints_with_full_syntax_stops_at_enabled_breakpoint
254
254
  enter 'break 19', 'break 20', 'disable breakpoints',
255
- -> { "enable breakpoints #{last_brkpt.id}" }, 'cont'
255
+ -> { "enable breakpoints #{Breakpoint.last.id}" }, 'cont'
256
256
 
257
257
  debug_proc(@example) { assert_equal 20, state.line }
258
258
  end
@@ -261,8 +261,8 @@ module Byebug
261
261
  enter 'enable'
262
262
 
263
263
  debug_proc(@example)
264
- check_error_includes \
265
- '"enable" must be followed by "display", "breakpoints" or breakpoint ids'
264
+ check_error_includes '"enable" must be followed by "display", ' \
265
+ '"breakpoints" or breakpoint ids'
266
266
  end
267
267
 
268
268
  def test_conditional_breakpoint_stops_if_condition_is_true
@@ -303,7 +303,7 @@ module Byebug
303
303
  module FilenameTests
304
304
  def test_setting_breakpoint_prints_confirmation_message
305
305
  enter 'break 19'
306
- debug_proc(@example) { @id = first_brkpt.id }
306
+ debug_proc(@example) { @id = Breakpoint.first.id }
307
307
  check_output_includes "Created breakpoint #{@id} at #{@filename}:19"
308
308
  end
309
309
 
@@ -342,35 +342,23 @@ module Byebug
342
342
  include FilenameTests
343
343
  end
344
344
 
345
- class BreakTestCaseAutoreload < BreakTestCase
346
- def setup
347
- super
348
- enter 'set autoreload'
345
+ def test_setting_breakpoint_with_autoreload_uses_new_source
346
+ enter 'set autoreload', -> do
347
+ change_line_in_file(__FILE__, 19, '')
348
+ 'break 19'
349
349
  end
350
350
 
351
- def test_setting_breakpoint_with_autoreload_uses_new_source
352
- enter -> do
353
- change_line_in_file(__FILE__, 19, '')
354
- 'break 19'
355
- end
356
- debug_proc(@example) { assert_empty Byebug.breakpoints }
357
- change_line_in_file(__FILE__,19, ' BreakExample.new.b')
358
- end
351
+ debug_proc(@example) { assert_empty Byebug.breakpoints }
352
+ change_line_in_file(__FILE__,19, ' BreakExample.new.b')
359
353
  end
360
354
 
361
- class BreakTestCaseNoAutoreload < BreakTestCase
362
- def setup
363
- super
364
- enter 'set noautoreload'
355
+ def test_setting_breakpoint_with_noautoreload_uses_old_source
356
+ enter 'set noautoreload', -> do
357
+ change_line_in_file(__FILE__, 19, '')
358
+ 'break 19'
365
359
  end
366
360
 
367
- def test_setting_breakpoint_with_autoreload_uses_new_source
368
- enter -> do
369
- change_line_in_file(__FILE__, 19, '')
370
- 'break 19'
371
- end
372
- debug_proc(@example) { assert_equal 1, Byebug.breakpoints.size }
373
- change_line_in_file(__FILE__,19, ' BreakExample.new.b')
374
- end
361
+ debug_proc(@example) { assert_equal 1, Byebug.breakpoints.size }
362
+ change_line_in_file(__FILE__,19, ' BreakExample.new.b')
375
363
  end
376
364
  end
@@ -12,27 +12,27 @@ module Byebug
12
12
  end
13
13
 
14
14
  def test_setting_condition_w_short_syntax_assigns_expression_to_breakpoint
15
- enter 'break 7', -> { "cond #{first_brkpt.id} b == 5" }
15
+ enter 'break 7', -> { "cond #{Breakpoint.first.id} b == 5" }
16
16
 
17
- debug_proc(@example) { assert_equal 'b == 5', first_brkpt.expr }
17
+ debug_proc(@example) { assert_equal 'b == 5', Breakpoint.first.expr }
18
18
  end
19
19
 
20
20
  def test_setting_condition_w_full_syntax_assigns_expression_to_breakpoint
21
- enter 'break 7', -> { "condition #{first_brkpt.id} b == 5" }
21
+ enter 'break 7', -> { "condition #{Breakpoint.first.id} b == 5" }
22
22
 
23
- debug_proc(@example) { assert_equal 'b == 5', first_brkpt.expr }
23
+ debug_proc(@example) { assert_equal 'b == 5', Breakpoint.first.expr }
24
24
  end
25
25
 
26
26
  def test_setting_condition_w_wrong_syntax_does_not_enable_breakpoint
27
- enter 'break 7', -> { "disable #{first_brkpt.id}" },
28
- -> { "cond #{first_brkpt.id} b ==" }
27
+ enter 'break 7', -> { "disable #{Breakpoint.first.id}" },
28
+ -> { "cond #{Breakpoint.first.id} b ==" }
29
29
 
30
- debug_proc(@example) { assert_equal false, first_brkpt.enabled? }
30
+ debug_proc(@example) { assert_equal false, Breakpoint.first.enabled? }
31
31
  end
32
32
 
33
33
  def test_setting_condition_w_wrong_syntax_shows_error
34
- enter 'break 7', -> { "disable #{first_brkpt.id}" },
35
- -> { "cond #{first_brkpt.id} b ==" }
34
+ enter 'break 7', -> { "disable #{Breakpoint.first.id}" },
35
+ -> { "cond #{Breakpoint.first.id} b ==" }
36
36
 
37
37
  debug_proc(@example)
38
38
  check_error_includes \
@@ -40,28 +40,28 @@ module Byebug
40
40
  end
41
41
 
42
42
  def test_execution_stops_when_condition_is_true
43
- enter 'break 7', -> { "cond #{first_brkpt.id} b == 5" }, 'cont'
43
+ enter 'break 7', -> { "cond #{Breakpoint.first.id} b == 5" }, 'cont'
44
44
 
45
45
  debug_proc(@example) { assert_equal 7, state.line }
46
46
  end
47
47
 
48
48
  def test_execution_does_not_stop_when_condition_is_false
49
- enter 'b 7', 'b 8', -> { "cond #{first_brkpt.id} b == 3" }, 'cont'
49
+ enter 'b 7', 'b 8', -> { "cond #{Breakpoint.first.id} b == 3" }, 'cont'
50
50
 
51
51
  debug_proc(@example) { assert_equal 8, state.line }
52
52
  end
53
53
 
54
54
  def test_conditions_with_wrong_syntax_are_ignored
55
- enter 'break 7', 'break 8', -> { "cond #{first_brkpt.id} b ==" }, 'cont'
55
+ enter 'b 7', 'b 8', -> { "cond #{Breakpoint.first.id} b ==" }, 'cont'
56
56
 
57
57
  debug_proc(@example) { assert_equal 7, state.line }
58
58
  end
59
59
 
60
60
  def test_empty_condition_means_removing_any_conditions
61
- enter 'b 7 if b == 3', 'b 8', -> { "cond #{first_brkpt.id}" }, 'cont'
61
+ enter 'b 7 if b == 3', 'b 8', -> { "cond #{Breakpoint.first.id}" }, 'c'
62
62
 
63
63
  debug_proc(@example) do
64
- assert_nil first_brkpt.expr
64
+ assert_nil Breakpoint.first.expr
65
65
  assert_equal 7, state.line
66
66
  end
67
67
  end