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,103 +1,119 @@
1
- class EvalTest
2
- def sum(a,b)
3
- a + b
4
- end
1
+ module EvalTest
2
+ class Example
3
+ def sum(a,b)
4
+ a + b
5
+ end
5
6
 
6
- def inspect
7
- raise "Broken"
7
+ def inspect
8
+ raise "Broken"
9
+ end
8
10
  end
9
- end
10
11
 
11
- class TestEval < TestDsl::TestCase
12
- it 'must evaluate an expression' do
13
- enter 'eval 3 + 2'
14
- debug_file 'eval'
15
- check_output_includes '5'
16
- end
12
+ class EvalTestCase < TestDsl::TestCase
13
+ before do
14
+ @example = -> do
15
+ byebug
16
+ @foo = Example.new
17
+ @foo.sum(1, 2)
18
+ end
19
+ end
17
20
 
18
- it 'must work with shortcut' do
19
- enter 'e 3 + 2'
20
- debug_file 'eval'
21
- check_output_includes '5'
22
- end
21
+ it 'must evaluate an expression' do
22
+ enter 'eval 3 + 2'
23
+ debug_proc(@example)
24
+ check_output_includes '5'
25
+ end
23
26
 
24
- it 'must work with another syntax' do
25
- enter 'p 3 + 2'
26
- debug_file 'eval'
27
- check_output_includes '5'
28
- end
27
+ it 'must evaluate expression that calls Timeout::timeout' do
28
+ enter 'eval Timeout::timeout(60) { 1 }'
29
+ debug_proc(@example)
30
+ check_output_includes '1'
31
+ end
29
32
 
30
- it 'must work when inspect raises an exception' do
31
- enter 'c 4', 'p @foo'
32
- debug_file('eval') { state.line.must_equal 4 }
33
- check_output_includes 'RuntimeError Exception: Broken'
34
- end
33
+ it 'must work with shortcut' do
34
+ enter 'e 3 + 2'
35
+ debug_proc(@example)
36
+ check_output_includes '5'
37
+ end
35
38
 
36
- describe 'autoeval' do
37
- it 'must be set by default' do
38
- enter '[5,6,7].inject(&:+)'
39
- debug_file 'eval'
40
- check_output_includes '18'
39
+ it 'must work with another syntax' do
40
+ enter 'p 3 + 2'
41
+ debug_proc(@example)
42
+ check_output_includes '5'
41
43
  end
42
44
 
43
- it 'can be turned off and back on' do
44
- enter 'set noautoeval', '[5,6,7].inject(&:+)',
45
- 'set autoeval', '[1,2,3].inject(&:+)'
46
- debug_file 'eval'
47
- check_output_doesnt_include '18'
48
- check_output_includes '6'
45
+ it 'must work when inspect raises an exception' do
46
+ enter 'c 17', 'p @foo'
47
+ debug_proc(@example) { state.line.must_equal 17 }
48
+ check_output_includes 'RuntimeError Exception: Broken'
49
49
  end
50
- end
51
50
 
52
- describe 'stack trace on error' do
53
- describe 'when enabled' do
54
- temporary_change_hash Byebug.settings, :stack_on_error, true
51
+ describe 'autoeval' do
52
+ it 'must be set by default' do
53
+ enter '[5, 6 , 7].inject(&:+)'
54
+ debug_proc(@example)
55
+ check_output_includes '18'
56
+ end
55
57
 
56
- it 'must show a stack trace' do
57
- enter 'eval 2 / 0'
58
- debug_file 'eval'
59
- check_output_includes(/\s*from \S+:in \`eval\'/)
60
- check_output_doesnt_include 'ZeroDivisionError Exception: divided by 0'
58
+ it 'can be turned off and back on' do
59
+ enter 'set noautoeval', '[5, 6, 7].inject(&:+)',
60
+ 'set autoeval', '[1, 2, 3].inject(&:+)'
61
+ debug_proc(@example)
62
+ check_output_doesnt_include '18'
63
+ check_output_includes '6'
61
64
  end
62
65
  end
63
66
 
64
- describe 'when disabled' do
65
- temporary_change_hash Byebug.settings, :stack_on_error, false
67
+ describe 'stack trace on error' do
68
+ describe 'when enabled' do
69
+ temporary_change_hash Byebug::Setting, :stack_on_error, true
70
+
71
+ it 'must show a stack trace' do
72
+ enter 'eval 2 / 0'
73
+ debug_proc(@example)
74
+ check_output_includes(/\s*from \S+:in \`eval\'/)
75
+ check_output_doesnt_include 'ZeroDivisionError Exception: divided by 0'
76
+ end
77
+ end
78
+
79
+ describe 'when disabled' do
80
+ temporary_change_hash Byebug::Setting, :stack_on_error, false
66
81
 
67
- it 'must only show exception' do
68
- enter 'eval 2 / 0'
69
- debug_file 'eval'
70
- check_output_includes 'ZeroDivisionError Exception: divided by 0'
71
- check_output_doesnt_include(/\S+:\d+:in `eval':divided by 0/)
82
+ it 'must only show exception' do
83
+ enter 'eval 2 / 0'
84
+ debug_proc(@example)
85
+ check_output_includes 'ZeroDivisionError Exception: divided by 0'
86
+ check_output_doesnt_include(/\S+:\d+:in `eval':divided by 0/)
87
+ end
72
88
  end
73
89
  end
74
- end
75
90
 
76
- describe 'pp' do
77
- it 'must pretty print the expression result' do
78
- enter 'pp {a: \'3\' * 40, b: \'4\' * 30}'
79
- debug_file 'eval'
80
- check_output_includes "{:a=>\"#{'3' * 40}\",\n :b=>\"#{'4' * 30}\"}"
91
+ describe 'pp' do
92
+ it 'must pretty print the expression result' do
93
+ enter 'pp {a: \'3\' * 40, b: \'4\' * 30}'
94
+ debug_proc(@example)
95
+ check_output_includes "{:a=>\"#{'3' * 40}\",\n :b=>\"#{'4' * 30}\"}"
96
+ end
81
97
  end
82
- end
83
98
 
84
- describe 'putl' do
85
- temporary_change_hash Byebug.settings, :width, 20
99
+ describe 'putl' do
100
+ temporary_change_hash Byebug::Setting, :width, 20
86
101
 
87
- it 'must print expression and columnize the result' do
88
- enter 'putl [1, 2, 3, 4, 5, 9, 8, 7, 6]'
89
- debug_file 'eval'
90
- check_output_includes "1 3 5 8 6\n2 4 9 7"
102
+ it 'must print expression and columnize the result' do
103
+ enter 'putl [1, 2, 3, 4, 5, 9, 8, 7, 6]'
104
+ debug_proc(@example)
105
+ check_output_includes "1 3 5 8 6\n2 4 9 7"
106
+ end
91
107
  end
92
- end
93
108
 
94
- describe 'ps' do
95
- temporary_change_hash Byebug.settings, :width, 20
109
+ describe 'ps' do
110
+ temporary_change_hash Byebug::Setting, :width, 20
96
111
 
97
- it 'must print expression and sort and columnize the result' do
98
- enter 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
99
- debug_file 'eval'
100
- check_output_includes "1 3 5 7 9\n2 4 6 8"
112
+ it 'must print expression and sort and columnize the result' do
113
+ enter 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
114
+ debug_proc(@example)
115
+ check_output_includes "1 3 5 7 9\n2 4 6 8"
116
+ end
101
117
  end
102
118
  end
103
119
  end
@@ -1,53 +1,64 @@
1
- class FinishExample
2
- def a
3
- b
4
- end
5
- def b
6
- c
7
- 2
8
- end
9
- def c
10
- d
11
- 3
12
- end
13
- def d
14
- 5
15
- end
16
- end
1
+ module FinishTest
2
+ class Example
3
+ def a
4
+ b
5
+ end
17
6
 
18
- class TestFinish < TestDsl::TestCase
19
- before { enter "break #{__FILE__}:14", 'cont' }
7
+ def b
8
+ c
9
+ 2
10
+ end
20
11
 
21
- it 'must stop after current frame is finished when without arguments' do
22
- enter 'finish'
23
- debug_file('finish') { state.line.must_equal 11 }
24
- end
12
+ def c
13
+ d
14
+ 3
15
+ end
25
16
 
26
- it 'must stop before current frame finishes if 0 specified as argument' do
27
- enter 'finish 0'
28
- debug_file('finish') { state.line.must_equal 15 }
17
+ def d
18
+ 5
19
+ end
29
20
  end
30
21
 
31
- it 'must stop after current frame is finished if 1 specified as argument' do
32
- enter 'finish 1'
33
- debug_file('finish') { state.line.must_equal 11 }
34
- end
22
+ class FinishTestCase < TestDsl::TestCase
23
+ before do
24
+ @example = -> do
25
+ byebug
26
+ Example.new.a
27
+ end
28
+ enter 'break 18', 'cont'
29
+ end
35
30
 
36
- it 'must behave consistenly even if current frame has been changed' do
37
- enter 'up', 'finish'
38
- debug_file('finish') { state.line.must_equal 7 }
39
- end
31
+ it 'must stop after current frame is finished when without arguments' do
32
+ enter 'finish'
33
+ debug_proc(@example) { state.line.must_equal 14 }
34
+ end
40
35
 
41
- describe 'not a number is specified for frame' do
42
- before { enter 'finish foo' }
36
+ it 'must stop before current frame finishes if 0 specified as argument' do
37
+ enter 'finish 0'
38
+ debug_proc(@example) { state.line.must_equal 19 }
39
+ end
43
40
 
44
- it 'must show an error' do
45
- debug_file('finish')
46
- check_output_includes '"finish" argument "foo" needs to be a number.'
41
+ it 'must stop after current frame is finished if 1 specified as argument' do
42
+ enter 'finish 1'
43
+ debug_proc(@example) { state.line.must_equal 14 }
47
44
  end
48
45
 
49
- it 'must be on the same line' do
50
- debug_file('finish') { state.line.must_equal 14 }
46
+ it 'must behave consistenly even if current frame has been changed' do
47
+ enter 'up', 'finish'
48
+ debug_proc(@example) { state.line.must_equal 9 }
49
+ end
50
+
51
+ describe 'not a number is specified for frame' do
52
+ before { enter 'finish foo' }
53
+
54
+ it 'must show an error' do
55
+ debug_proc(@example)
56
+ check_output_includes '"finish" argument "foo" needs to be a number'
57
+ end
58
+
59
+ it 'must be on the same line' do
60
+ debug_proc(@example) { state.line.must_equal 18 }
61
+ end
51
62
  end
52
63
  end
53
64
  end
@@ -1,228 +1,241 @@
1
- class FrameExample
2
- def initialize(f)
3
- @f = f
4
- end
5
-
6
- def a
7
- b
8
- end
9
-
10
- def b
11
- c
12
- 2
13
- end
14
-
15
- def c
16
- d('a')
17
- 3
18
- end
19
-
20
- def d(e)
21
- 5
1
+ module FrameTest
2
+ class Example
3
+ def initialize(f)
4
+ @f = f
5
+ end
6
+ def a
7
+ b
8
+ end
9
+ def b
10
+ c
11
+ 2
12
+ end
13
+ def c
14
+ d('a')
15
+ 3
16
+ end
17
+ def d(e)
18
+ 5
19
+ end
22
20
  end
23
- end
24
21
 
25
- class FrameDeepExample
26
- def a
27
- z = 1
28
- z += b
29
- end
30
- def b
31
- z = 2
32
- z += c
33
- end
34
- def c
35
- z = 3
36
- byebug
37
- z += d('a')
38
- end
39
- def d(e)
40
- 4
22
+ class DeepExample
23
+ def a
24
+ z = 1
25
+ z += b
26
+ end
27
+ def b
28
+ z = 2
29
+ z += c
30
+ end
31
+ def c
32
+ z = 3
33
+ byebug
34
+ z += d('a')
35
+ end
36
+ def d(e)
37
+ 4
38
+ end
41
39
  end
42
- end
43
40
 
44
- class TestFrame < TestDsl::TestCase
45
- describe 'when byebug started at the beginning' do
41
+ class FrameTestCase < TestDsl::TestCase
46
42
  before do
47
- @tst_file = fullpath('frame')
48
- enter "break #{__FILE__}:21", 'cont'
43
+ @example = -> do
44
+ byebug
45
+ fr_ex = Example.new('f')
46
+ fr_ex.a()
47
+ end
49
48
  end
50
49
 
51
- it 'must go up' do
52
- enter 'up'
53
- debug_file('frame') { state.line.must_equal 16 }
54
- end
50
+ describe 'when byebug started at the beginning' do
51
+ before do
52
+ enter "break #{__FILE__}:18", 'cont'
53
+ end
55
54
 
56
- it 'must go up by specific number of frames' do
57
- enter 'up 2'
58
- debug_file('frame') { state.line.must_equal 11 }
59
- end
55
+ it 'must go up' do
56
+ enter 'up'
57
+ debug_proc(@example) { state.line.must_equal 14 }
58
+ end
60
59
 
61
- it 'must go down' do
62
- enter 'up', 'down'
63
- debug_file('frame') { state.line.must_equal 21 }
64
- end
60
+ it 'must go up by specific number of frames' do
61
+ enter 'up 2'
62
+ debug_proc(@example) { state.line.must_equal 10 }
63
+ end
65
64
 
66
- it 'must go down by specific number of frames' do
67
- enter 'up 3', 'down 2'
68
- debug_file('frame') { state.line.must_equal 16 }
69
- end
65
+ it 'must go down' do
66
+ enter 'up', 'down'
67
+ debug_proc(@example) { state.line.must_equal 18 }
68
+ end
70
69
 
71
- it 'must set frame' do
72
- enter 'frame 2'
73
- debug_file('frame') { state.line.must_equal 11 }
74
- end
70
+ it 'must go down by specific number of frames' do
71
+ enter 'up 3', 'down 2'
72
+ debug_proc(@example) { state.line.must_equal 14 }
73
+ end
75
74
 
76
- it 'must print current stack frame when without arguments' do
77
- enter 'up', 'frame'
78
- debug_file('frame')
79
- check_output_includes(/#1 FrameExample\.c\s+at #{__FILE__}:16/)
80
- end
75
+ it 'must set frame' do
76
+ enter 'frame 2'
77
+ debug_proc(@example) { state.line.must_equal 10 }
78
+ end
81
79
 
82
- it 'must set frame to the first one' do
83
- enter 'up', 'frame 0'
84
- debug_file('frame') { state.line.must_equal 21 }
85
- end
80
+ it 'must print current stack frame when without arguments' do
81
+ enter 'up', 'frame'
82
+ debug_proc(@example)
83
+ check_output_includes(/#1 FrameTest::Example\.c\s+at #{__FILE__}:14/)
84
+ end
86
85
 
87
- it 'must set frame to the last one' do
88
- enter 'frame -1'
89
- debug_file('frame') { File.basename(state.file).must_equal 'test_helper.rb' }
90
- end
86
+ it 'must set frame to the first one' do
87
+ enter 'up', 'frame 0'
88
+ debug_proc(@example) { state.line.must_equal 18 }
89
+ end
91
90
 
92
- it 'must not set frame if the frame number is too low' do
93
- enter 'down'
94
- debug_file('frame') { state.line.must_equal 21 }
95
- check_output_includes \
96
- "Can't navigate beyond the newest frame", interface.error_queue
97
- end
91
+ it 'must set frame to the last one' do
92
+ enter 'frame -1'
93
+ debug_proc(@example) { File.basename(state.file).must_equal 'test_helper.rb' }
94
+ end
98
95
 
99
- it 'must not set frame if the frame number is too high' do
100
- enter 'up 100'
101
- debug_file('frame') { state.line.must_equal 21 }
102
- check_output_includes \
103
- "Can't navigate beyond the oldest frame", interface.error_queue
104
- end
96
+ it 'must not set frame if the frame number is too low' do
97
+ enter 'down'
98
+ debug_proc(@example) { state.line.must_equal 18 }
99
+ check_output_includes \
100
+ "Can't navigate beyond the newest frame", interface.error_queue
101
+ end
105
102
 
106
- describe 'fullpath' do
107
- describe 'when set' do
108
- temporary_change_hash Byebug.settings, :fullpath, true
109
-
110
- it 'must display current backtrace with fullpaths' do
111
- enter 'where'
112
- debug_file 'frame'
113
- check_output_includes(
114
- /--> #0 FrameExample\.d\(e#String\)\s+at #{__FILE__}:21/,
115
- /#1 FrameExample\.c\s+at #{__FILE__}:16/,
116
- /#2 FrameExample\.b\s+at #{__FILE__}:11/)
117
- end
103
+ it 'must not set frame if the frame number is too high' do
104
+ enter 'up 100'
105
+ debug_proc(@example) { state.line.must_equal 18 }
106
+ check_output_includes \
107
+ "Can't navigate beyond the oldest frame", interface.error_queue
118
108
  end
119
109
 
120
- describe 'when unset' do
121
- temporary_change_hash Byebug.settings, :fullpath, false
110
+ describe 'fullpath' do
111
+ describe 'when set' do
112
+ temporary_change_hash Byebug::Setting, :fullpath, true
122
113
 
123
- it 'must display current backtrace with shortpaths' do
124
- enter 'where'
125
- debug_file 'frame'
126
- check_output_includes(
127
- /--> #0 FrameExample\.d\(e#String\)\s+at #{shortpath(__FILE__)}:21/,
128
- /#1 FrameExample\.c\s+at #{shortpath(__FILE__)}:16/,
129
- /#2 FrameExample\.b\s+at #{shortpath(__FILE__)}:11/,
130
- /#3 FrameExample\.a\s+at #{shortpath(__FILE__)}:7/)
114
+ it 'must display current backtrace with fullpaths' do
115
+ enter 'where'
116
+ debug_proc(@example)
117
+ check_output_includes(
118
+ /--> #0 FrameTest::Example\.d\(e#String\)\s+at #{__FILE__}:18/,
119
+ /#1 FrameTest::Example\.c\s+at #{__FILE__}:14/,
120
+ /#2 FrameTest::Example\.b\s+at #{__FILE__}:10/,
121
+ /#3 FrameTest::Example\.a\s+at #{__FILE__}:7/)
122
+ end
131
123
  end
132
- end
133
- end
134
124
 
135
- describe 'callstyle' do
136
- describe 'long' do
137
- temporary_change_hash Byebug.settings, :callstyle, :long
138
-
139
- it 'displays current backtrace with callstyle "long"' do
140
- enter 'where'
141
- debug_file 'frame'
142
- check_output_includes(
143
- /--> #0 FrameExample\.d\(e#String\)\s+at #{__FILE__}:21/,
144
- /#1 FrameExample\.c\s+at #{__FILE__}:16/,
145
- /#2 FrameExample\.b\s+at #{__FILE__}:11/,
146
- /#3 FrameExample\.a\s+at #{__FILE__}:7/)
125
+ describe 'when unset' do
126
+ temporary_change_hash Byebug::Setting, :fullpath, false
127
+
128
+ it 'must display current backtrace with shortpaths' do
129
+ path = shortpath(__FILE__)
130
+ enter 'where'
131
+ debug_proc(@example)
132
+ check_output_includes(
133
+ /--> #0 FrameTest::Example\.d\(e#String\)\s+at #{path}:18/,
134
+ /#1 FrameTest::Example\.c\s+at #{path}:14/,
135
+ /#2 FrameTest::Example\.b\s+at #{path}:10/,
136
+ /#3 FrameTest::Example\.a\s+at #{path}:7/)
137
+ end
147
138
  end
148
139
  end
149
140
 
150
- describe 'short' do
151
- temporary_change_hash Byebug.settings, :callstyle, :short
141
+ describe 'callstyle' do
142
+ describe 'long' do
143
+ temporary_change_hash Byebug::Setting, :callstyle, :long
152
144
 
153
- it 'displays current backtrace with callstyle "short"' do
145
+ it 'displays current backtrace with callstyle "long"' do
154
146
  enter 'where'
155
- debug_file 'frame'
156
- check_output_includes(/--> #0 d\(e\)\s+at #{__FILE__}:21/,
157
- /#1 c\s+at #{__FILE__}:16/,
158
- /#2 b\s+at #{__FILE__}:11/,
159
- /#3 a\s+at #{__FILE__}:7/)
147
+ debug_proc(@example)
148
+ check_output_includes(
149
+ /--> #0 FrameTest::Example\.d\(e#String\)\s+at #{__FILE__}:18/,
150
+ /#1 FrameTest::Example\.c\s+at #{__FILE__}:14/,
151
+ /#2 FrameTest::Example\.b\s+at #{__FILE__}:10/,
152
+ /#3 FrameTest::Example\.a\s+at #{__FILE__}:7/)
153
+ end
154
+ end
155
+
156
+ describe 'short' do
157
+ temporary_change_hash Byebug::Setting, :callstyle, :short
158
+
159
+ it 'displays current backtrace with callstyle "short"' do
160
+ enter 'where'
161
+ debug_proc(@example)
162
+ check_output_includes(/--> #0 d\(e\)\s+at #{__FILE__}:18/,
163
+ /#1 c\s+at #{__FILE__}:14/,
164
+ /#2 b\s+at #{__FILE__}:10/,
165
+ /#3 a\s+at #{__FILE__}:7/)
166
+ end
160
167
  end
161
168
  end
162
169
  end
163
- end
164
170
 
165
- describe 'when byebug is started deep in the callstack' do
166
- before { enter "break #{__FILE__}:40", 'cont' }
171
+ describe 'when byebug is started deep in the callstack' do
172
+ before do
173
+ @deep_example = -> do
174
+ DeepExample.new.a
175
+ end
176
+ enter "break #{__FILE__}:37", 'cont'
177
+ end
167
178
 
168
- it 'must print backtrace' do
169
- enter 'where'
170
- debug_file 'frame_deep'
171
- check_output_includes(
172
- /--> #0 FrameDeepExample\.d\(e#String\)\s+at #{__FILE__}:40/,
173
- /#1 FrameDeepExample\.c\s+at #{__FILE__}:37/,
174
- /#2 FrameDeepExample\.b\s+at #{__FILE__}:32/)
175
- end
179
+ it 'must print backtrace' do
180
+ enter 'where'
181
+ debug_proc(@deep_example)
182
+ check_output_includes(
183
+ /--> #0 FrameTest::DeepExample\.d\(e#String\)\s+at #{__FILE__}:37/,
184
+ /#1 FrameTest::DeepExample\.c\s+at #{__FILE__}:34/,
185
+ /#2 FrameTest::DeepExample\.b\s+at #{__FILE__}:29/)
186
+ end
176
187
 
177
- it 'must go up' do
178
- enter 'up'
179
- debug_file('frame_deep') { state.line.must_equal 37 }
180
- end
188
+ it 'must go up' do
189
+ enter 'up'
190
+ debug_proc(@deep_example) { state.line.must_equal 34 }
191
+ end
181
192
 
182
- it 'must go down' do
183
- enter 'up', 'down'
184
- debug_file('frame_deep') { state.line.must_equal 40 }
185
- end
193
+ it 'must go down' do
194
+ enter 'up', 'down'
195
+ debug_proc(@deep_example) { state.line.must_equal 37 }
196
+ end
186
197
 
187
- it 'must set frame' do
188
- enter 'frame 2'
189
- debug_file('frame_deep') { state.line.must_equal 32 }
190
- end
198
+ it 'must set frame' do
199
+ enter 'frame 2'
200
+ debug_proc(@deep_example) { state.line.must_equal 29 }
201
+ end
191
202
 
192
- it 'must eval properly when scaling the stack' do
193
- enter 'p z', 'up', 'p z', 'up', 'p z'
194
- debug_file('frame_deep')
195
- check_output_includes 'nil', '3', '2'
203
+ it 'must eval properly when scaling the stack' do
204
+ enter 'p z', 'up', 'p z', 'up', 'p z'
205
+ debug_proc(@deep_example)
206
+ check_output_includes 'nil', '3', '2'
207
+ end
196
208
  end
197
- end
198
209
 
199
- describe 'c-frames' do
200
- it 'must mark c-frames when printing the stack' do
201
- enter "break #{__FILE__}:3", 'cont', 'where'
202
- enter 'where'
203
- debug_file 'frame'
204
- check_output_includes(
205
- /--> #0 FrameExample.initialize\(f#String\)\s+at #{__FILE__}:3/,
206
- /ͱ-- #1 Class.new\(\*args\)\s+at #{fullpath('frame')}:3/,
207
- /#2 <top \(required\)>\s+at #{fullpath('frame')}:3/)
208
- end
210
+ describe 'c-frames' do
211
+ it 'must mark c-frames when printing the stack' do
212
+ file = __FILE__
213
+ enter "break #{__FILE__}:4", 'cont', 'where'
214
+ enter 'where'
215
+ debug_proc(@example)
216
+ check_output_includes(
217
+ /--> #0 FrameTest::Example.initialize\(f#String\)\s+at #{file}:4/,
218
+ /ͱ-- #1 Class.new\(\*args\)\s+at #{file}:45/,
219
+ /#2 block \(2 levels\) in <class:FrameTestCase>\s+at #{file}:45/)
220
+ end
209
221
 
210
- it '"up" skips c-frames' do
211
- enter "break #{__FILE__}:7", 'cont', 'up', 'eval fr_ex.class.to_s'
212
- debug_file 'frame'
213
- check_output_includes '"FrameExample"'
214
- end
222
+ it '"up" skips c-frames' do
223
+ enter "break #{__FILE__}:7", 'cont', 'up', 'eval fr_ex.class.to_s'
224
+ debug_proc(@example)
225
+ check_output_includes '"FrameTest::Example"'
226
+ end
215
227
 
216
- it '"down" skips c-frames' do
217
- enter "break #{__FILE__}:7", 'cont', 'up', 'down', 'eval @f'
218
- debug_file 'frame'
219
- check_output_includes '"f"'
220
- end
228
+ it '"down" skips c-frames' do
229
+ enter "break #{__FILE__}:7", 'cont', 'up', 'down', 'eval @f'
230
+ debug_proc(@example)
231
+ check_output_includes '"f"'
232
+ end
221
233
 
222
- it 'must not jump straigh to c-frames' do
223
- enter "break #{__FILE__}:3", 'cont', 'frame 1'
224
- debug_file 'frame'
225
- check_output_includes "Can't navigate to c-frame", interface.error_queue
234
+ it 'must not jump straigh to c-frames' do
235
+ enter "break #{__FILE__}:4", 'cont', 'frame 1'
236
+ debug_proc(@example)
237
+ check_output_includes "Can't navigate to c-frame", interface.error_queue
238
+ end
226
239
  end
227
240
  end
228
241
  end