byebug 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,12 +14,12 @@ class TestConditions < TestDsl::TestCase
14
14
 
15
15
  it 'must stop at the breakpoint if condition is true' do
16
16
  enter ->{ "cond #{Byebug.breakpoints.first.id} b == 5" }, 'cont'
17
- debug_file('conditions') { state.line.must_equal 3 }
17
+ debug_file('conditions') { $state.line.must_equal 3 }
18
18
  end
19
19
 
20
20
  it 'must work with full command name too' do
21
21
  enter ->{ "condition #{Byebug.breakpoints.first.id} b == 5" }, 'cont'
22
- debug_file('conditions') { state.line.must_equal 3 }
22
+ debug_file('conditions') { $state.line.must_equal 3 }
23
23
  end
24
24
  end
25
25
 
@@ -28,7 +28,7 @@ class TestConditions < TestDsl::TestCase
28
28
 
29
29
  it 'must not stop at the breakpoint if condition is false' do
30
30
  enter ->{ "cond #{Byebug.breakpoints.first.id} b == 3" }, 'cont'
31
- debug_file('conditions') { state.line.must_equal 4 }
31
+ debug_file('conditions') { $state.line.must_equal 4 }
32
32
  end
33
33
 
34
34
  it 'must assign expression to breakpoint in spite of incorrect syntax' do
@@ -39,7 +39,7 @@ class TestConditions < TestDsl::TestCase
39
39
 
40
40
  it 'must ignore the condition if when incorrect syntax' do
41
41
  enter ->{ "cond #{Byebug.breakpoints.first.id} b ==" }, 'cont'
42
- debug_file('conditions') { state.line.must_equal 4 }
42
+ debug_file('conditions') { $state.line.must_equal 4 }
43
43
  end
44
44
  end
45
45
  end
@@ -53,7 +53,7 @@ class TestConditions < TestDsl::TestCase
53
53
  end
54
54
 
55
55
  it 'must unconditionally stop on the breakpoint' do
56
- debug_file('conditions') { state.line.must_equal 3 }
56
+ debug_file('conditions') { $state.line.must_equal 3 }
57
57
  end
58
58
  end
59
59
 
@@ -66,7 +66,7 @@ class TestConditions < TestDsl::TestCase
66
66
 
67
67
  it 'must not set breakpoint condition if breakpoint id is incorrect' do
68
68
  enter 'break 3', 'cond 8 b == 3', 'cont'
69
- debug_file('conditions') { state.line.must_equal 3 }
69
+ debug_file('conditions') { $state.line.must_equal 3 }
70
70
  end
71
71
  end
72
72
 
@@ -74,7 +74,7 @@ class TestConditions < TestDsl::TestCase
74
74
  it 'must be able to set conditions in post-mortem mode' do
75
75
  enter 'cont', 'break 12', ->{ "cond #{Byebug.breakpoints.first.id} true" },
76
76
  'cont'
77
- debug_file('post_mortem') { state.line.must_equal 12 }
77
+ debug_file('post_mortem') { $state.line.must_equal 12 }
78
78
  end
79
79
  end
80
80
 
@@ -5,29 +5,29 @@ class TestContinue < TestDsl::TestCase
5
5
  describe "successful" do
6
6
  it "must continue up to breakpoint if no line specified" do
7
7
  enter 'break 4', 'continue'
8
- debug_file('continue') { state.line.must_equal 4 }
8
+ debug_file('continue') { $state.line.must_equal 4 }
9
9
  end
10
10
 
11
11
  it "must work in abbreviated mode too" do
12
12
  enter 'break 4', 'cont'
13
- debug_file('continue') { state.line.must_equal 4 }
13
+ debug_file('continue') { $state.line.must_equal 4 }
14
14
  end
15
15
 
16
16
  it "must continue up to specified line" do
17
17
  enter 'cont 4'
18
- debug_file('continue') { state.line.must_equal 4 }
18
+ debug_file('continue') { $state.line.must_equal 4 }
19
19
  end
20
20
  end
21
21
 
22
22
  describe "unsuccessful" do
23
23
  it "must ignore the command if specified line is not valid" do
24
24
  enter 'cont 123'
25
- debug_file('continue') { state.line.must_equal 2 }
25
+ debug_file('continue') { $state.line.must_equal 2 }
26
26
  end
27
27
 
28
28
  it "must show error if specified line is not valid" do
29
29
  enter 'cont 123'
30
- debug_file('continue')
30
+ debug_file 'continue'
31
31
  check_output_includes "Line 123 is not a stopping point in file " \
32
32
  "\"#{fullpath('continue')}\"", interface.error_queue
33
33
  end
@@ -16,7 +16,7 @@ class TestDisplay < TestDsl::TestCase
16
16
 
17
17
  it 'must save displayed expressions' do
18
18
  enter 'display d + 1'
19
- debug_file('display') { state.display.must_equal [[true, 'd + 1']] }
19
+ debug_file('display') { $state.display.must_equal [[true, 'd + 1']] }
20
20
  end
21
21
 
22
22
  it 'displays all expressions available' do
@@ -47,7 +47,7 @@ class TestDisplay < TestDsl::TestCase
47
47
 
48
48
  it 'must set all expressions saved to "false"' do
49
49
  debug_file('display') {
50
- state.display.must_equal [[false, 'abc'], [false, 'd']] }
50
+ $state.display.must_equal [[false, 'abc'], [false, 'd']] }
51
51
  end
52
52
 
53
53
  it 'must not show any output' do
@@ -61,7 +61,7 @@ class TestDisplay < TestDsl::TestCase
61
61
 
62
62
  it 'must set all expressions saved to "false"' do
63
63
  debug_file('display') {
64
- state.display.must_equal [[true, 'abc'], [true, 'd']] }
64
+ $state.display.must_equal [[true, 'abc'], [true, 'd']] }
65
65
  end
66
66
 
67
67
  it 'must not show any output' do
@@ -81,7 +81,7 @@ class TestDisplay < TestDsl::TestCase
81
81
 
82
82
  it 'must set inactive positions' do
83
83
  debug_file('display') {
84
- state.display.must_equal [[nil, 'abc'], [true, 'd']] }
84
+ $state.display.must_equal [[nil, 'abc'], [true, 'd']] }
85
85
  end
86
86
 
87
87
  it 'must display only the active position' do
@@ -99,7 +99,7 @@ class TestDisplay < TestDsl::TestCase
99
99
  describe 'disable' do
100
100
  it 'must disable a position' do
101
101
  enter 'display d', 'disable display 1'
102
- debug_file('display') { state.display.must_equal [[false, 'd']] }
102
+ debug_file('display') { $state.display.must_equal [[false, 'd']] }
103
103
  end
104
104
 
105
105
  it 'must show an error if no displays are set' do
@@ -120,7 +120,7 @@ class TestDisplay < TestDsl::TestCase
120
120
  describe 'enable' do
121
121
  it 'must enable a position' do
122
122
  enter 'display d', 'disable display 1', 'enable display 1'
123
- debug_file('display') { state.display.must_equal [[true, 'd']] }
123
+ debug_file('display') { $state.display.must_equal [[true, 'd']] }
124
124
  end
125
125
  end
126
126
 
@@ -29,8 +29,8 @@ class TestEdit < TestDsl::TestCase
29
29
 
30
30
  it 'must open specified line in specified file with configured editor' do
31
31
  Byebug::Edit.any_instance.expects(:system).
32
- with("editr +3 #{fullpath('breakpoint1')}")
33
- enter "edit #{fullpath('breakpoint1')}:3"
32
+ with("editr +3 #{fullpath('breakpoint')}")
33
+ enter "edit #{fullpath('breakpoint')}:3"
34
34
  debug_file 'edit'
35
35
  end
36
36
  end
@@ -0,0 +1,24 @@
1
+ class SteppingExample
2
+ def a
3
+ z = 2
4
+ b
5
+ end
6
+
7
+ def b
8
+ v2 = 5 if 1 == 2 ; [1,2,3].map { |a| a.to_f }
9
+ c
10
+ end
11
+
12
+ def c
13
+ z = 4
14
+ 5
15
+ byebug
16
+ end
17
+ end
18
+
19
+ ex = SteppingExample.new.a
20
+ 2.times do
21
+ ex += 1
22
+ end
23
+
24
+ ex
@@ -4,22 +4,22 @@ class TestFinish < TestDsl::TestCase
4
4
 
5
5
  it 'must stop at the next frame by default' do
6
6
  enter 'break 16', 'cont', 'finish'
7
- debug_file('finish') { state.line.must_equal 13 }
7
+ debug_file('finish') { $state.line.must_equal 13 }
8
8
  end
9
9
 
10
10
  it 'must stop at the #0 frame by default' do
11
11
  enter 'break 16', 'cont', 'finish 0'
12
- debug_file('finish') { state.line.must_equal 13 }
12
+ debug_file('finish') { $state.line.must_equal 13 }
13
13
  end
14
14
 
15
15
  it 'must stop at the specified frame' do
16
16
  enter 'break 16', 'cont', 'finish 1'
17
- debug_file('finish') { state.line.must_equal 9 }
17
+ debug_file('finish') { $state.line.must_equal 9 }
18
18
  end
19
19
 
20
20
  it 'must stop at the next frame if the current frame was changed' do
21
21
  enter 'break 16', 'cont', 'up', 'finish'
22
- debug_file('finish') { state.line.must_equal 9 }
22
+ debug_file('finish') { $state.line.must_equal 9 }
23
23
  end
24
24
 
25
25
  describe 'not a number is specified for frame' do
@@ -31,7 +31,7 @@ class TestFinish < TestDsl::TestCase
31
31
  end
32
32
 
33
33
  it 'must be on the same line' do
34
- debug_file('finish') { state.line.must_equal 16 }
34
+ debug_file('finish') { $state.line.must_equal 16 }
35
35
  end
36
36
  end
37
37
 
@@ -4,32 +4,32 @@ class TestFrame < TestDsl::TestCase
4
4
 
5
5
  it 'must go up' do
6
6
  enter 'break 16', 'cont', 'up'
7
- debug_file('frame') { state.line.must_equal 12 }
7
+ debug_file('frame') { $state.line.must_equal 12 }
8
8
  end
9
9
 
10
10
  it 'must go up by specific number of frames' do
11
11
  enter 'break 16', 'cont', 'up 2'
12
- debug_file('frame') { state.line.must_equal 8 }
12
+ debug_file('frame') { $state.line.must_equal 8 }
13
13
  end
14
14
 
15
15
  it 'must go down' do
16
16
  enter 'break 16', 'cont', 'up', 'down'
17
- debug_file('frame') { state.line.must_equal 16 }
17
+ debug_file('frame') { $state.line.must_equal 16 }
18
18
  end
19
19
 
20
20
  it 'must go down by specific number of frames' do
21
21
  enter 'break 16', 'cont', 'up 3', 'down 2'
22
- debug_file('frame') { state.line.must_equal 12 }
22
+ debug_file('frame') { $state.line.must_equal 12 }
23
23
  end
24
24
 
25
25
  it 'must set frame' do
26
26
  enter 'break 16', 'cont', 'frame 2'
27
- debug_file('frame') { state.line.must_equal 8 }
27
+ debug_file('frame') { $state.line.must_equal 8 }
28
28
  end
29
29
 
30
30
  it 'must set frame to the first one by default' do
31
31
  enter 'break 16', 'cont', 'up', 'frame'
32
- debug_file('frame') { state.line.must_equal 16 }
32
+ debug_file('frame') { $state.line.must_equal 16 }
33
33
  end
34
34
 
35
35
  it 'must print current stack frame when without arguments' do
@@ -40,29 +40,27 @@ class TestFrame < TestDsl::TestCase
40
40
 
41
41
  it 'must set frame to the first one' do
42
42
  enter 'break 16', 'cont', 'up', 'frame 0'
43
- debug_file('frame') { state.line.must_equal 16 }
43
+ debug_file('frame') { $state.line.must_equal 16 }
44
44
  end
45
45
 
46
46
  it 'must set frame to the last one' do
47
47
  enter 'break 16', 'cont', 'bt', 'frame -1'
48
- debug_file('frame') { state.file.must_match /minitest\/unit.rb/ }
48
+ debug_file('frame') { $state.file.must_match /minitest\/unit.rb/ }
49
49
  check_output_doesnt_include "at #{fullpath('frame')}:"
50
50
  end
51
51
 
52
52
  it 'must not set frame if the frame number is too low' do
53
53
  enter 'break 16', 'cont', 'down'
54
- debug_file('frame') { state.line.must_equal 16 }
54
+ debug_file('frame') { $state.line.must_equal 16 }
55
55
  check_output_includes \
56
- 'Adjusting would put us beyond the newest (innermost) frame.',
57
- interface.error_queue
56
+ 'Adjusting would put us beyond the newest frame.', interface.error_queue
58
57
  end
59
58
 
60
59
  it 'must not set frame if the frame number is too high' do
61
60
  enter 'break 16', 'cont', 'up 100'
62
- debug_file('frame') { state.line.must_equal 16 }
61
+ debug_file('frame') { $state.line.must_equal 16 }
63
62
  check_output_includes \
64
- 'Adjusting would put us beyond the oldest (initial) frame.',
65
- interface.error_queue
63
+ 'Adjusting would put us beyond the oldest frame.', interface.error_queue
66
64
  end
67
65
 
68
66
  describe 'when byebug is started deep in the callstack' do
@@ -77,17 +75,17 @@ class TestFrame < TestDsl::TestCase
77
75
 
78
76
  it 'must go up' do
79
77
  enter 'break 16', 'cont', 'up'
80
- debug_file('frame_deep') { state.line.must_equal 13 }
78
+ debug_file('frame_deep') { $state.line.must_equal 13 }
81
79
  end
82
80
 
83
81
  it 'must go down' do
84
82
  enter 'break 16', 'cont', 'up', 'down'
85
- debug_file('frame_deep') { state.line.must_equal 16 }
83
+ debug_file('frame_deep') { $state.line.must_equal 16 }
86
84
  end
87
85
 
88
86
  it 'must set frame' do
89
87
  enter 'break 16', 'cont', 'frame 2'
90
- debug_file('frame_deep') { state.line.must_equal 8 }
88
+ debug_file('frame_deep') { $state.line.must_equal 8 }
91
89
  end
92
90
 
93
91
  it 'must eval properly when scaling the stack' do
@@ -131,17 +129,17 @@ class TestFrame < TestDsl::TestCase
131
129
  end
132
130
 
133
131
  describe 'callstyle' do
134
- describe 'last' do
135
- temporary_change_hash Byebug::Command.settings, :callstyle, :last
132
+ describe 'long' do
133
+ temporary_change_hash Byebug::Command.settings, :callstyle, :long
136
134
 
137
- it 'displays current backtrace with callstyle "last"' do
135
+ it 'displays current backtrace with callstyle "long"' do
138
136
  enter 'break 16', 'cont', 'where'
139
137
  debug_file 'frame'
140
138
  check_output_includes \
141
- /--> #0 A.d(e#String) at #{fullpath('frame')}:16/x,
142
- /#1 A.c at #{fullpath('frame')}:12/x ,
143
- /#2 A.b at #{fullpath('frame')}:8/x ,
144
- /#3 A.a at #{fullpath('frame')}:5/x
139
+ /--> #0 A.d(e#String) at #{fullpath('frame')}:16/x,
140
+ /#1 A.c at #{fullpath('frame')}:12/x ,
141
+ /#2 A.b at #{fullpath('frame')}:8/x ,
142
+ /#3 A.a at #{fullpath('frame')}:5/x
145
143
  end
146
144
  end
147
145
 
@@ -151,19 +149,10 @@ class TestFrame < TestDsl::TestCase
151
149
  it 'displays current backtrace with callstyle "short"' do
152
150
  enter 'break 16', 'cont', 'where'
153
151
  debug_file 'frame'
154
- check_output_includes /--> #0 d(e) at #{fullpath('frame')}:16/x,
155
- /#1 c at #{fullpath('frame')}:12/x,
156
- /#2 b at #{fullpath('frame')}:8/x,
157
- /#3 a at #{fullpath('frame')}:5/x
158
- end
159
- end
160
-
161
- describe 'tracked' do
162
- temporary_change_hash Byebug::Command.settings, :callstyle, :tracked
163
-
164
- it 'displays current backtrace with callstyle "tracked"' do
165
- skip 'XXX: Style supported but not working....'
166
- debug_file 'frame'
152
+ check_output_includes /--> #0 d(e) at #{fullpath('frame')}:16/x,
153
+ /#1 c at #{fullpath('frame')}:12/x,
154
+ /#2 b at #{fullpath('frame')}:8/x,
155
+ /#3 a at #{fullpath('frame')}:5/x
167
156
  end
168
157
  end
169
158
  end
@@ -171,7 +160,7 @@ class TestFrame < TestDsl::TestCase
171
160
  describe 'Post Mortem' do
172
161
  it 'must work in post-mortem mode' do
173
162
  enter 'cont', 'frame'
174
- debug_file('post_mortem') { state.line.must_equal 8 }
163
+ debug_file('post_mortem') { $state.line.must_equal 8 }
175
164
  end
176
165
  end
177
166
 
@@ -6,7 +6,7 @@ class TestJump < TestDsl::TestCase
6
6
  it "must jump with absolute line number" do
7
7
  skip("No jumping for now")
8
8
  enter 'break 6', 'cont', "jump 8 #{fullpath('jump')}"
9
- debug_file('jump') { state.line.must_equal 8 }
9
+ debug_file('jump') { $state.line.must_equal 8 }
10
10
  end
11
11
 
12
12
  it "must not initialize skipped variables during jump" do
@@ -20,13 +20,13 @@ class TestJump < TestDsl::TestCase
20
20
  it "must jump with relative line number (-)" do
21
21
  skip("No jumping for now")
22
22
  enter 'break 8', 'cont', "jump -2 #{fullpath('jump')}"
23
- debug_file('jump') { state.line.must_equal 6 }
23
+ debug_file('jump') { $state.line.must_equal 6 }
24
24
  end
25
25
 
26
26
  it "must jump with relative line number (+)" do
27
27
  skip("No jumping for now")
28
28
  enter 'break 8', 'cont', "jump +2 #{fullpath('jump')}"
29
- debug_file('jump') { state.line.must_equal 10 }
29
+ debug_file('jump') { $state.line.must_equal 10 }
30
30
  end
31
31
  end
32
32
 
@@ -50,7 +50,7 @@ class TestJump < TestDsl::TestCase
50
50
  it "must not jump to there" do
51
51
  skip("No jumping for now")
52
52
  enter "jump 13 #{fullpath('jump')}"
53
- debug_file('jump') { state.line.must_equal 3 }
53
+ debug_file('jump') { $state.line.must_equal 3 }
54
54
  end
55
55
 
56
56
  it "must show an error" do
@@ -68,11 +68,10 @@ class TestJump < TestDsl::TestCase
68
68
  it "must work in post-mortem mode" do
69
69
  skip 'No jumping for now plus this test fails with "Segmentation ' \
70
70
  'fault". Probably need to fix it somehow or forbid this command ' \
71
- 'in post mortem mode. Seems like state.context.frame_file and ' \
72
- 'state.context.frame_line cause that.'
71
+ 'in post mortem mode. Seems like $state.context.frame_file and ' \
72
+ '$state.context.frame_line cause that.'
73
73
  enter 'cont', 'jump 12'
74
74
  debug_file 'post_mortem'
75
75
  end
76
76
  end
77
-
78
77
  end
@@ -161,7 +161,7 @@ class TestList < TestDsl::TestCase
161
161
  end
162
162
 
163
163
  it 'must show an error when there is no such file' do
164
- enter ->{state.file = 'blabla'; 'list 4-4'}
164
+ enter -> { $state.file = 'blabla'; 'list 4-4' }
165
165
  debug_file 'list'
166
166
  check_output_includes 'No sourcefile available for blabla',
167
167
  interface.error_queue
@@ -9,7 +9,7 @@ class TestPostMortem < TestDsl::TestCase
9
9
 
10
10
  it 'must stop at the correct line' do
11
11
  enter 'cont'
12
- debug_file('post_mortem') { state.line.must_equal 8 }
12
+ debug_file('post_mortem') { $state.line.must_equal 8 }
13
13
  end
14
14
 
15
15
  it 'must exit from post mortem mode after stepping command' do
@@ -13,19 +13,19 @@ class TestRepl < TestDsl::TestCase
13
13
  it 'must support next command' do
14
14
  irb.stubs(:eval_input).throws(:IRB_EXIT, :next)
15
15
  enter 'irb'
16
- debug_file('repl') { state.line.must_equal 3 }
16
+ debug_file('repl') { $state.line.must_equal 3 }
17
17
  end
18
18
 
19
19
  it 'must support step command' do
20
20
  irb.stubs(:eval_input).throws(:IRB_EXIT, :step)
21
21
  enter 'irb'
22
- debug_file('repl') { state.line.must_equal 3 }
22
+ debug_file('repl') { $state.line.must_equal 3 }
23
23
  end
24
24
 
25
25
  it 'must support cont command' do
26
26
  irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
27
27
  enter 'break 4', 'irb'
28
- debug_file('repl') { state.line.must_equal 4 }
28
+ debug_file('repl') { $state.line.must_equal 4 }
29
29
  end
30
30
 
31
31
  describe 'autoirb' do
@@ -36,31 +36,11 @@ class TestRepl < TestDsl::TestCase
36
36
  end
37
37
  end
38
38
 
39
- describe 'setting context to $byebug_state' do
40
- temporary_change_hash Byebug::Command.settings, :testing, false
41
-
42
- it 'must set $byebug_state if irb is in the debug mode' do
43
- byebug_state = nil
44
- irb.stubs(:eval_input).calls { byebug_state = $byebug_state }
45
- enter 'irb -d'
46
- debug_file 'repl'
47
- byebug_state.must_be_kind_of Byebug::CommandProcessor::State
48
- end
49
-
50
- it 'must not set $byebug_state if irb is not in the debug mode' do
51
- byebug_state = nil
52
- irb.stubs(:eval_input).calls { byebug_state = $byebug_state }
53
- enter 'irb'
54
- debug_file 'repl'
55
- byebug_state.must_be_nil
56
- end
57
- end
58
-
59
39
  describe 'Post Mortem' do
60
40
  it 'must work in post-mortem mode' do
61
41
  irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
62
42
  enter 'cont', 'break 12', 'irb'
63
- debug_file('post_mortem') { state.line.must_equal 12 }
43
+ debug_file('post_mortem') { $state.line.must_equal 12 }
64
44
  end
65
45
  end
66
46
  end
@@ -86,22 +66,6 @@ class TestRepl < TestDsl::TestCase
86
66
  end
87
67
  end
88
68
 
89
- describe 'setting context to $byebug_state' do
90
- temporary_change_hash Byebug::Command.settings, :testing, false
91
-
92
- it 'must set $byebug_state if irb is in the debug mode' do
93
- enter 'pry -d'
94
- debug_file 'repl'
95
- $byebug_state.must_be_kind_of Byebug::CommandProcessor::State
96
- end
97
-
98
- it 'must not set $byebug_state if irb is not in the debug mode' do
99
- enter 'pry'
100
- debug_file 'repl'
101
- $byebug_state.must_be_nil
102
- end
103
- end
104
-
105
69
  describe 'Post Mortem' do
106
70
  it 'must work in post-mortem mode' do
107
71
  skip 'TODO'