byebug 1.0.1 → 1.0.2

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.
@@ -1,62 +1,68 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "Eval Command" do
3
+ describe 'Eval Command' do
4
4
  include TestDsl
5
5
 
6
- it "must evaluate an expression" do
6
+ it 'must evaluate an expression' do
7
7
  enter 'eval 3 + 2'
8
8
  debug_file 'eval'
9
- check_output_includes "5"
9
+ check_output_includes '5'
10
10
  end
11
11
 
12
- it "must work with shortcut" do
12
+ it 'must work with shortcut' do
13
13
  enter 'e 3 + 2'
14
14
  debug_file 'eval'
15
- check_output_includes "5"
15
+ check_output_includes '5'
16
16
  end
17
17
 
18
- it "must work with another syntax" do
18
+ it 'must work with another syntax' do
19
19
  enter 'p 3 + 2'
20
20
  debug_file 'eval'
21
- check_output_includes "5"
21
+ check_output_includes '5'
22
22
  end
23
23
 
24
- describe "autoeval" do
25
- temporary_change_hash_value(Byebug::Command.settings, :autoeval, false)
24
+ describe 'autoeval' do
25
+ it 'must be set by default' do
26
+ enter '[5,6,7].inject(&:+)'
27
+ debug_file 'eval'
28
+ check_output_includes '18'
29
+ end
26
30
 
27
- it "must eval the expression if no matching command is found" do
28
- enter 'set autoeval', '[5,6,7].inject(&:+)'
31
+ it 'can be turned off and back on' do
32
+ enter 'set noautoeval', '[5,6,7].inject(&:+)',
33
+ 'set autoeval', '[1,2,3].inject(&:+)'
29
34
  debug_file 'eval'
30
- check_output_includes "18"
35
+ check_output_doesnt_include '18'
36
+ check_output_includes '6'
31
37
  end
32
38
  end
33
39
 
34
- describe "stack trace on error" do
40
+ describe 'stack trace on error' do
35
41
  temporary_change_hash_value(Byebug::Command.settings, :stack_trace_on_error, false)
36
42
 
37
- it "must show a stack trace if showing trace on error is enabled" do
43
+ it 'must show a stack trace if showing trace on error is enabled' do
38
44
  enter 'set notrace', 'eval 2 / 0'
39
45
  debug_file 'eval'
40
- check_output_includes "ZeroDivisionError Exception: divided by 0"
46
+ check_output_includes 'ZeroDivisionError Exception: divided by 0'
41
47
  check_output_doesnt_include /\S+:\d+:in `eval':divided by 0/
42
48
  end
43
49
 
44
- it "must show a stack trace if showing trace on error is enabled" do
50
+ it 'must show a stack trace if showing trace on error is enabled' do
45
51
  enter 'set trace', 'eval 2 / 0'
46
52
  debug_file 'eval'
47
53
  check_output_includes /\S+:\d+:in `eval':divided by 0/
48
- check_output_doesnt_include "ZeroDivisionError Exception: divided by 0"
54
+ check_output_doesnt_include 'ZeroDivisionError Exception: divided by 0'
49
55
  end
50
56
  end
51
57
 
52
58
 
53
- it "must pretty print the expression result" do
54
- enter 'pp {a: "3" * 40, b: "4" * 30}'
59
+ it 'must pretty print the expression result' do
60
+ enter 'pp {a: \'3\' * 40, b: \'4\' * 30}'
55
61
  debug_file 'eval'
56
- check_output_includes "{:a=>\"#{"3" * 40}\",\n :b=>\"#{"4" * 30}\"}"
62
+ check_output_includes "{:a=>\"#{'3' * 40}\",\n :b=>\"#{'4' * 30}\"}"
57
63
  end
58
64
 
59
- it "must print expression and columnize the result" do
65
+ it 'must print expression and columnize the result' do
60
66
  temporary_change_hash_value(Byebug::PutLCommand.settings, :width, 20) do
61
67
  enter 'putl [1, 2, 3, 4, 5, 9, 8, 7, 6]'
62
68
  debug_file 'eval'
@@ -64,7 +70,7 @@ describe "Eval Command" do
64
70
  end
65
71
  end
66
72
 
67
- it "must print expression and sort and columnize the result" do
73
+ it 'must print expression and sort and columnize the result' do
68
74
  temporary_change_hash_value(Byebug::PSCommand.settings, :width, 20) do
69
75
  enter 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
70
76
  debug_file 'eval'
@@ -72,7 +78,7 @@ describe "Eval Command" do
72
78
  end
73
79
  end
74
80
 
75
- it "must set width by the 'set' command" do
81
+ it 'must set width by the "set" command' do
76
82
  temporary_change_hash_value(Byebug::PSCommand.settings, :width, 20) do
77
83
  enter 'set width 10', 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
78
84
  debug_file 'eval'
@@ -80,12 +86,12 @@ describe "Eval Command" do
80
86
  end
81
87
  end
82
88
 
83
- describe "Post Mortem" do
84
- it "must work in post-mortem mode" do
85
- skip("No post morten mode for now")
86
- #enter 'cont', 'eval 2 + 2'
87
- #debug_file "post_mortem"
88
- #check_output_includes "4"
89
+ describe 'Post Mortem' do
90
+ it 'must work in post-mortem mode' do
91
+ skip('No post morten mode for now')
92
+ enter 'cont', 'eval 2 + 2'
93
+ debug_file 'post_mortem'
94
+ check_output_includes '4'
89
95
  end
90
96
  end
91
97
 
@@ -1,70 +1,71 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "Frame Command" do
3
+ describe 'Frame Command' do
4
4
  include TestDsl
5
5
 
6
- it "must go up" do
6
+ it 'must go up' do
7
7
  enter 'break 16', 'cont', 'up'
8
8
  debug_file('frame') { state.line.must_equal 12 }
9
9
  end
10
10
 
11
- it "must go up by specific number of frames" do
11
+ it 'must go up by specific number of frames' do
12
12
  enter 'break 16', 'cont', 'up 2'
13
13
  debug_file('frame') { state.line.must_equal 8 }
14
14
  end
15
15
 
16
- it "must go down" do
16
+ it 'must go down' do
17
17
  enter 'break 16', 'cont', 'up', 'down'
18
18
  debug_file('frame') { state.line.must_equal 16 }
19
19
  end
20
20
 
21
- it "must go down by specific number of frames" do
21
+ it 'must go down by specific number of frames' do
22
22
  enter 'break 16', 'cont', 'up 3', 'down 2'
23
23
  debug_file('frame') { state.line.must_equal 12 }
24
24
  end
25
25
 
26
- it "must set frame" do
26
+ it 'must set frame' do
27
27
  enter 'break 16', 'cont', 'frame 2'
28
28
  debug_file('frame') { state.line.must_equal 8 }
29
29
  end
30
30
 
31
- it "must set frame to the first one by default" do
31
+ it 'must set frame to the first one by default' do
32
32
  enter 'break 16', 'cont', 'up', 'frame'
33
33
  debug_file('frame') { state.line.must_equal 16 }
34
34
  end
35
35
 
36
- it "must print current stack frame when without arguments" do
36
+ it 'must print current stack frame when without arguments' do
37
37
  enter 'break A.d', 'cont', 'up', 'frame'
38
- debug_file('frame') { check_output_includes "#0", "A.d(e#String)" }
38
+ debug_file('frame') { check_output_includes '#0', 'A.d(e#String)' }
39
39
  end
40
40
 
41
- it "must set frame to the first one" do
41
+ it 'must set frame to the first one' do
42
42
  enter 'break 16', 'cont', 'up', 'frame 0'
43
43
  debug_file('frame') { state.line.must_equal 16 }
44
44
  end
45
45
 
46
- it "must set frame to the last one" do
46
+ it 'must set frame to the last one' do
47
47
  enter 'break 16', 'cont', 'frame -1'
48
- debug_file('frame') { state.line.must_equal 20 }
48
+ debug_file('frame') { state.file.must_match /test_dsl.rb/ }
49
+ check_output_doesnt_include "at #{fullpath('frame')}:"
49
50
  end
50
51
 
51
- it "must not set frame if the frame number is too low" do
52
+ it 'must not set frame if the frame number is too low' do
52
53
  enter 'break 16', 'cont', 'down'
53
54
  debug_file('frame') { state.line.must_equal 16 }
54
55
  check_output_includes \
55
- "Adjusting would put us beyond the newest (innermost) frame.",
56
+ 'Adjusting would put us beyond the newest (innermost) frame.',
56
57
  interface.error_queue
57
58
  end
58
59
 
59
- it "must not set frame if the frame number is too high" do
60
+ it 'must not set frame if the frame number is too high' do
60
61
  enter 'break 16', 'cont', 'up 100'
61
62
  debug_file('frame') { state.line.must_equal 16 }
62
63
  check_output_includes \
63
- "Adjusting would put us beyond the oldest (initial) frame.",
64
+ 'Adjusting would put us beyond the oldest (initial) frame.',
64
65
  interface.error_queue
65
66
  end
66
67
 
67
- describe "full path settings" do
68
+ describe 'full path settings' do
68
69
  def short_path(fullpath)
69
70
  separator = File::ALT_SEPARATOR || File::SEPARATOR
70
71
  "...#{separator}" + fullpath.split(separator)[-3..-1].join(separator)
@@ -74,70 +75,70 @@ describe "Frame Command" do
74
75
  Byebug::Command.settings[:callstyle] = :last
75
76
  end
76
77
 
77
- it "must display current backtrace with full path = true" do
78
+ it 'must display current backtrace with full path = true' do
78
79
  enter 'set fullpath', 'break 16', 'cont', 'where'
79
80
  debug_file 'frame'
80
81
  check_output_includes \
81
- "-->", "#0", "A.d(e#String)", "at line #{fullpath('frame')}:16",
82
- "#1", "A.c", "at line #{fullpath('frame')}:12"
82
+ '-->', '#0', 'A.d(e#String)', "at #{fullpath('frame')}:16",
83
+ '#1', 'A.c' , "at #{fullpath('frame')}:12"
83
84
  end
84
85
 
85
- it "must display current backtrace with full path = false" do
86
+ it 'must display current backtrace with full path = false' do
86
87
  enter 'set nofullpath', 'break 16', 'cont', 'where'
87
88
  debug_file 'frame'
88
89
  check_output_includes \
89
- "-->", "#0", "A.d(e#String)", "at line #{short_path(fullpath('frame'))}:16",
90
- "#1", "A.c", "at line #{short_path(fullpath('frame'))}:12"
90
+ '-->', '#0', 'A.d(e#String)', "at #{short_path(fullpath('frame'))}:16",
91
+ '#1', 'A.c' , "at #{short_path(fullpath('frame'))}:12"
91
92
  end
92
93
  end
93
94
 
94
- describe "callstyles" do
95
- it "displays current backtrace with callstyle 'last'" do
95
+ describe 'callstyles' do
96
+ it 'displays current backtrace with callstyle "last"' do
96
97
  enter 'set callstyle last', 'break 16', 'cont', 'where'
97
98
  debug_file 'frame'
98
99
  check_output_includes \
99
- "-->", "#0", "A.d(e#String)", "at line #{fullpath('frame')}:16",
100
- "#1", "A.c", "at line #{fullpath('frame')}:12",
101
- "#2", "A.b", "at line #{fullpath('frame')}:8",
102
- "#3", "A.a", "at line #{fullpath('frame')}:5"
100
+ '-->', '#0', 'A.d(e#String)', "at #{fullpath('frame')}:16",
101
+ '#1', 'A.c' , "at #{fullpath('frame')}:12",
102
+ '#2', 'A.b' , "at #{fullpath('frame')}:8" ,
103
+ '#3', 'A.a' , "at #{fullpath('frame')}:5"
103
104
  end
104
105
 
105
- it "displays current backtrace with callstyle 'short'" do
106
+ it 'displays current backtrace with callstyle "short"' do
106
107
  enter 'set callstyle short', 'break 16', 'cont', 'where'
107
108
  debug_file 'frame'
108
109
  check_output_includes \
109
- "-->", "#0", "d(e)", "at line #{fullpath('frame')}:16",
110
- "#1", "c", "at line #{fullpath('frame')}:12",
111
- "#2", "b", "at line #{fullpath('frame')}:8",
112
- "#3", "a", "at line #{fullpath('frame')}:5"
110
+ '-->', '#0', 'd(e)', "at #{fullpath('frame')}:16",
111
+ '#1', 'c' , "at #{fullpath('frame')}:12",
112
+ '#2', 'b' , "at #{fullpath('frame')}:8" ,
113
+ '#3', 'a' , "at #{fullpath('frame')}:5"
113
114
  end
114
115
 
115
- it "displays current backtrace with callstyle 'tracked'" do
116
- skip("XXX: Style supported but not working....")
116
+ it 'displays current backtrace with callstyle "tracked"' do
117
+ skip('XXX: Style supported but not working....')
117
118
  enter 'set callstyle tracked'
118
119
  debug_file 'frame'
119
120
  check_output_includes \
120
- "Invalid call style tracked. Should be one of: 'shast'."
121
+ 'Invalid call style tracked. Should be one of: "last".'
121
122
  Byebug::Command.settings[:callstyle].must_equal :last
122
123
  end
123
124
  end
124
125
 
125
- it "must change to frame in another thread" do
126
- skip("No threads supported")
126
+ it 'must change to frame in another thread' do
127
+ skip('No threads supported')
127
128
  end
128
129
 
129
- it "must not change to frame in another thread if thread doesn't exist" do
130
- skip("No threads supported")
130
+ it 'must not change to frame in another thread if thread doesn\'t exist' do
131
+ skip('No threads supported')
131
132
  end
132
133
 
133
- describe "Post Mortem" do
134
- # TODO: This test fails with "Segmentation fault". Probably need to fix it
134
+ describe 'Post Mortem' do
135
+ # TODO: This test fails with 'Segmentation fault'. Probably need to fix it
135
136
  # somehow, or forbid this command in the post mortem mode. Seems like
136
137
  # state.context.frame_file and state.context.frame_line cause that.
137
- it "must work in post-mortem mode" do
138
- skip("No post morten mode for now")
139
- enter 'cont', "frame"
140
- debug_file "post_mortem"
138
+ it 'must work in post-mortem mode' do
139
+ skip('No post morten mode for now')
140
+ enter 'cont', 'frame'
141
+ debug_file 'post_mortem'
141
142
  end
142
143
  end
143
144
 
@@ -235,9 +235,9 @@ describe "Info Command" do
235
235
  enter 'break 20', 'cont', 'info stack'
236
236
  debug_file 'info'
237
237
  check_output_includes \
238
- "-->", "#0", "A.a", "at line #{fullpath('info')}:20",
239
- "#1", "A.b", "at line #{fullpath('info')}:30",
240
- "#2", "at line #{fullpath('info')}:36"
238
+ "-->", "#0", "A.a", "at #{fullpath('info')}:20",
239
+ "#1", "A.b", "at #{fullpath('info')}:30",
240
+ "#2", "at #{fullpath('info')}:36"
241
241
  end
242
242
  end
243
243
 
@@ -262,7 +262,7 @@ describe "Info Command" do
262
262
  enter 'break 20', 'cont', ->{"info thread #{context.thnum} verbose"}
263
263
  debug_file 'info'
264
264
  check_output_includes /#<Thread:\S+ run>/, "#0", "A.a",
265
- "at line #{fullpath('info')}:20"
265
+ "at #{fullpath('info')}:20"
266
266
  end
267
267
 
268
268
  it "must show error when unknown parameter is used" do
@@ -72,10 +72,7 @@ describe "List Command" do
72
72
  end
73
73
 
74
74
  describe "autolist" do
75
- before do
76
- Byebug::Command.settings[:listsize] = 3
77
- Byebug::Command.settings[:autolist] = 0
78
- end
75
+ before { Byebug::Command.settings[:listsize] = 3 }
79
76
 
80
77
  it "must show the surronding lines even without 'list' command if autolist is enabled" do
81
78
  enter 'set autolist', 'break 5', 'cont'
@@ -2,43 +2,48 @@ require_relative 'test_helper'
2
2
 
3
3
  describe "Reload Command" do
4
4
  include TestDsl
5
- temporary_change_hash_value(Byebug::Command.settings, :reload_source_on_change, false)
6
5
 
7
- it "must notify that automatic reloading is off" do
8
- enter 'reload'
9
- debug_file 'reload'
10
- check_output_includes "Source code is reloaded. Automatic reloading is off."
11
- end
6
+ describe "Reload Command (Setup)" do
12
7
 
13
- it "must notify that automatic reloading is on" do
14
- enter 'set autoreload', 'reload'
15
- debug_file 'reload'
16
- check_output_includes "Source code is reloaded. Automatic reloading is on."
17
- end
8
+ before { Byebug::Command.settings[:reload_source_on_change] = false }
18
9
 
19
- describe "reloading" do
20
- after { change_line_in_file(fullpath('reload'), 4, '4') }
21
- it "must reload the code" do
22
- enter 'break 3', 'cont', 'l 4-4', -> do
23
- change_line_in_file(fullpath('reload'), 4, '100')
24
- 'reload'
25
- end, 'l 4-4'
10
+ it "must notify that automatic reloading is off" do
11
+ enter 'reload'
26
12
  debug_file 'reload'
27
- check_output_includes "4 100"
13
+ check_output_includes "Source code is reloaded. Automatic reloading is off."
28
14
  end
29
- end
30
15
 
31
- describe "Post Mortem" do
32
- #after { change_line_in_file(fullpath('post_mortem'), 7, ' z = 4') }
33
- it "must work in post-mortem mode" do
34
- skip("No post morten mode for now")
35
- #enter 'cont', -> do
36
- # change_line_in_file(fullpath('post_mortem'), 7, 'z = 100')
37
- # 'reload'
38
- #end, 'l 7-7'
39
- #debug_file 'post_mortem'
40
- #check_output_includes "7 z = 100"
16
+ it "must notify that automatic reloading is on" do
17
+ enter 'set autoreload', 'reload'
18
+ debug_file 'reload'
19
+ check_output_includes "Source code is reloaded. Automatic reloading is on."
41
20
  end
21
+
22
+ describe "reloading" do
23
+ after { change_line_in_file(fullpath('reload'), 4, '4') }
24
+ it "must reload the code" do
25
+ enter 'break 3', 'cont', 'l 4-4', -> do
26
+ change_line_in_file(fullpath('reload'), 4, '100')
27
+ 'reload'
28
+ end, 'l 4-4'
29
+ debug_file 'reload'
30
+ check_output_includes "4 100"
31
+ end
32
+ end
33
+
34
+ describe "Post Mortem" do
35
+ after { change_line_in_file(fullpath('post_mortem'), 7, ' z = 4') }
36
+ it "must work in post-mortem mode" do
37
+ skip("No post morten mode for now")
38
+ enter 'cont', -> do
39
+ change_line_in_file(fullpath('post_mortem'), 7, 'z = 100')
40
+ 'reload'
41
+ end, 'l 7-7'
42
+ debug_file 'post_mortem'
43
+ check_output_includes "7 z = 100"
44
+ end
45
+ end
46
+
42
47
  end
43
48
 
44
49
  end
@@ -19,7 +19,6 @@ describe "Show Command" do
19
19
  end
20
20
  end
21
21
 
22
-
23
22
  describe "args" do
24
23
  temporary_change_hash_value(Byebug::Command.settings, :argv, %w{foo bar})
25
24
 
@@ -106,12 +105,11 @@ describe "Show Command" do
106
105
  end
107
106
 
108
107
  it "must show linetrace" do
109
- enter 'trace on', 'show linetrace'
108
+ enter 'trace on', 'show linetrace', 'trace off'
110
109
  debug_file 'show'
111
110
  check_output_includes "line tracing is on."
112
111
  end
113
112
 
114
-
115
113
  describe "linetrace+" do
116
114
  it "must show a message when linetrace+ is on" do
117
115
  temporary_change_hash_value(Byebug::Command.settings, :tracing_plus, true) do
@@ -282,9 +280,9 @@ describe "Show Command" do
282
280
 
283
281
  it "must work in post-mortem mode" do
284
282
  skip("No post morten mode for now")
285
- #enter 'cont', "show autolist"
286
- #debug_file 'post_mortem'
287
- #check_output_includes "autolist is off."
283
+ enter 'cont', "show autolist"
284
+ debug_file 'post_mortem'
285
+ check_output_includes "autolist is off."
288
286
  end
289
287
  end
290
288