debugger 1.2.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -0
- data/README.md +2 -0
- data/Rakefile +3 -55
- data/debugger.gemspec +2 -0
- data/lib/debugger/version.rb +1 -1
- data/lib/ruby-debug-base.rb +3 -1
- data/lib/ruby-debug/commands/irb.rb +1 -1
- data/lib/ruby-debug/commands/jump.rb +1 -1
- data/lib/ruby-debug/commands/method.rb +1 -1
- data/lib/ruby-debug/commands/show.rb +1 -1
- data/lib/ruby-debug/commands/trace.rb +2 -2
- data/lib/ruby-debug/commands/variables.rb +3 -3
- data/test/breakpoints_test.rb +365 -0
- data/test/conditions_test.rb +76 -0
- data/test/continue_test.rb +28 -0
- data/test/display_test.rb +141 -0
- data/test/edit_test.rb +55 -0
- data/test/eval_test.rb +92 -0
- data/test/examples/breakpoint1.rb +15 -0
- data/test/examples/breakpoint2.rb +7 -0
- data/test/examples/conditions.rb +4 -0
- data/test/examples/continue.rb +4 -0
- data/test/examples/display.rb +5 -0
- data/test/examples/edit.rb +3 -0
- data/test/examples/edit2.rb +3 -0
- data/test/examples/eval.rb +4 -0
- data/test/examples/finish.rb +20 -0
- data/test/examples/frame.rb +31 -0
- data/test/examples/help.rb +2 -0
- data/test/examples/info.rb +48 -0
- data/test/examples/info2.rb +3 -0
- data/test/examples/irb.rb +6 -0
- data/test/examples/jump.rb +14 -0
- data/test/examples/kill.rb +2 -0
- data/test/examples/list.rb +12 -0
- data/test/examples/method.rb +15 -0
- data/test/examples/post_mortem.rb +19 -0
- data/test/examples/quit.rb +2 -0
- data/test/examples/reload.rb +6 -0
- data/test/examples/restart.rb +6 -0
- data/test/examples/save.rb +3 -0
- data/test/examples/set.rb +3 -0
- data/test/examples/set_annotate.rb +12 -0
- data/test/examples/settings.rb +1 -0
- data/test/examples/show.rb +2 -0
- data/test/examples/source.rb +3 -0
- data/test/examples/stepping.rb +21 -0
- data/test/examples/thread.rb +32 -0
- data/test/examples/tmate.rb +10 -0
- data/test/examples/trace.rb +7 -0
- data/test/examples/trace_threads.rb +20 -0
- data/test/examples/variables.rb +26 -0
- data/test/finish_test.rb +48 -0
- data/test/frame_test.rb +140 -0
- data/test/help_test.rb +50 -0
- data/test/info_test.rb +325 -0
- data/test/irb_test.rb +81 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +47 -0
- data/test/list_test.rb +145 -0
- data/test/method_test.rb +70 -0
- data/test/post_mortem_test.rb +25 -0
- data/test/quit_test.rb +55 -0
- data/test/reload_test.rb +43 -0
- data/test/restart_test.rb +143 -0
- data/test/save_test.rb +92 -0
- data/test/set_test.rb +163 -0
- data/test/show_test.rb +292 -0
- data/test/source_test.rb +44 -0
- data/test/stepping_test.rb +118 -0
- data/test/support/breakpoint.rb +12 -0
- data/test/support/context.rb +14 -0
- data/test/support/matchers.rb +67 -0
- data/test/support/mocha_extensions.rb +71 -0
- data/test/support/processor.rb +7 -0
- data/test/support/test_dsl.rb +205 -0
- data/test/support/test_interface.rb +66 -0
- data/test/test_helper.rb +8 -0
- data/test/thread_test.rb +122 -0
- data/test/tmate_test.rb +43 -0
- data/test/trace_test.rb +154 -0
- data/test/variables_test.rb +114 -0
- metadata +107 -158
- data/test/base/base.rb +0 -71
- data/test/base/binding.rb +0 -24
- data/test/base/catchpoint.rb +0 -22
- data/test/base/load.rb +0 -36
- data/test/bp_loop_issue.rb +0 -3
- data/test/classes.rb +0 -11
- data/test/config.yaml +0 -8
- data/test/data/annotate.cmd +0 -29
- data/test/data/annotate.right +0 -139
- data/test/data/break_bad.cmd +0 -18
- data/test/data/break_bad.right +0 -28
- data/test/data/break_loop_bug.cmd +0 -5
- data/test/data/break_loop_bug.right +0 -15
- data/test/data/breakpoints.cmd +0 -38
- data/test/data/breakpoints.right +0 -98
- data/test/data/catch.cmd +0 -20
- data/test/data/catch.right +0 -49
- data/test/data/catch2.cmd +0 -19
- data/test/data/catch2.right +0 -65
- data/test/data/catch3.cmd +0 -11
- data/test/data/catch3.right +0 -37
- data/test/data/condition.cmd +0 -28
- data/test/data/condition.right +0 -65
- data/test/data/ctrl.cmd +0 -23
- data/test/data/ctrl.right +0 -70
- data/test/data/display.cmd +0 -24
- data/test/data/display.right +0 -44
- data/test/data/dollar-0.right +0 -2
- data/test/data/dollar-0a.right +0 -2
- data/test/data/dollar-0b.right +0 -2
- data/test/data/edit.cmd +0 -12
- data/test/data/edit.right +0 -19
- data/test/data/emacs_basic.cmd +0 -43
- data/test/data/emacs_basic.right +0 -106
- data/test/data/enable.cmd +0 -20
- data/test/data/enable.right +0 -36
- data/test/data/finish.cmd +0 -16
- data/test/data/finish.right +0 -31
- data/test/data/frame.cmd +0 -26
- data/test/data/frame.right +0 -55
- data/test/data/help.cmd +0 -20
- data/test/data/help.right +0 -21
- data/test/data/history.right +0 -7
- data/test/data/info-thread.cmd +0 -13
- data/test/data/info-thread.right +0 -37
- data/test/data/info-var-bug2.cmd +0 -5
- data/test/data/info-var-bug2.right +0 -10
- data/test/data/info-var.cmd +0 -23
- data/test/data/info-var.right +0 -52
- data/test/data/info.cmd +0 -21
- data/test/data/info.right +0 -65
- data/test/data/jump.cmd +0 -16
- data/test/data/jump.right +0 -56
- data/test/data/jump2.cmd +0 -16
- data/test/data/jump2.right +0 -44
- data/test/data/linetrace.cmd +0 -6
- data/test/data/linetrace.right +0 -23
- data/test/data/list.cmd +0 -19
- data/test/data/list.right +0 -127
- data/test/data/method.cmd +0 -10
- data/test/data/method.right +0 -21
- data/test/data/methodsig.cmd +0 -10
- data/test/data/methodsig.right +0 -20
- data/test/data/next.cmd +0 -22
- data/test/data/next.right +0 -61
- data/test/data/noquit.right +0 -1
- data/test/data/output.cmd +0 -6
- data/test/data/output.right +0 -31
- data/test/data/pm-bug.cmd +0 -7
- data/test/data/pm-bug.right +0 -12
- data/test/data/post-mortem-next.cmd +0 -8
- data/test/data/post-mortem-next.right +0 -14
- data/test/data/post-mortem-osx.right +0 -31
- data/test/data/post-mortem.cmd +0 -13
- data/test/data/post-mortem.right +0 -32
- data/test/data/quit.cmd +0 -6
- data/test/data/quit.right +0 -0
- data/test/data/raise.cmd +0 -11
- data/test/data/raise.right +0 -23
- data/test/data/save.cmd +0 -34
- data/test/data/save.right +0 -59
- data/test/data/scope-var.cmd +0 -42
- data/test/data/scope-var.right +0 -587
- data/test/data/setshow.cmd +0 -56
- data/test/data/setshow.right +0 -98
- data/test/data/source.cmd +0 -5
- data/test/data/source.right +0 -15
- data/test/data/stepping.cmd +0 -21
- data/test/data/stepping.right +0 -50
- data/test/data/test-init-cygwin.right +0 -7
- data/test/data/test-init-osx.right +0 -4
- data/test/data/test-init.right +0 -5
- data/test/data/trace.right +0 -14
- data/test/dollar-0.rb +0 -5
- data/test/gcd-dbg-nox.rb +0 -30
- data/test/gcd-dbg.rb +0 -29
- data/test/gcd.rb +0 -18
- data/test/helper.rb +0 -142
- data/test/info-var-bug.rb +0 -47
- data/test/info-var-bug2.rb +0 -2
- data/test/jump.rb +0 -14
- data/test/jump2.rb +0 -27
- data/test/lib/commands/catchpoint_test.rb +0 -28
- data/test/lib/commands/unit/regexp.rb +0 -38
- data/test/next.rb +0 -18
- data/test/null.rb +0 -1
- data/test/output.rb +0 -2
- data/test/pm-base.rb +0 -17
- data/test/pm-bug.rb +0 -3
- data/test/pm-catch.rb +0 -12
- data/test/pm-catch2.rb +0 -27
- data/test/pm-catch3.rb +0 -47
- data/test/pm.rb +0 -11
- data/test/raise.rb +0 -3
- data/test/rdebug-save.1 +0 -7
- data/test/runall +0 -12
- data/test/scope-var.rb +0 -29
- data/test/tdebug.rb +0 -246
- data/test/test-annotate.rb +0 -24
- data/test/test-break-bad.rb +0 -36
- data/test/test-breakpoints.rb +0 -24
- data/test/test-catch.rb +0 -24
- data/test/test-catch2.rb +0 -24
- data/test/test-catch3.rb +0 -24
- data/test/test-condition.rb +0 -24
- data/test/test-ctrl.rb +0 -51
- data/test/test-display.rb +0 -25
- data/test/test-dollar-0.rb +0 -39
- data/test/test-edit.rb +0 -25
- data/test/test-emacs-basic.rb +0 -25
- data/test/test-enable.rb +0 -24
- data/test/test-finish.rb +0 -33
- data/test/test-frame.rb +0 -33
- data/test/test-help.rb +0 -54
- data/test/test-hist.rb +0 -65
- data/test/test-info-thread.rb +0 -31
- data/test/test-info-var.rb +0 -46
- data/test/test-info.rb +0 -25
- data/test/test-init.rb +0 -43
- data/test/test-jump.rb +0 -34
- data/test/test-list.rb +0 -24
- data/test/test-method.rb +0 -33
- data/test/test-next.rb +0 -24
- data/test/test-output.rb +0 -25
- data/test/test-quit.rb +0 -29
- data/test/test-raise.rb +0 -24
- data/test/test-remote.rb +0 -14
- data/test/test-save.rb +0 -30
- data/test/test-scope-var.rb +0 -24
- data/test/test-setshow.rb +0 -24
- data/test/test-source.rb +0 -24
- data/test/test-stepping.rb +0 -25
- data/test/test-trace.rb +0 -46
- data/test/thread1.rb +0 -25
- data/test/trunc-call.rb +0 -30
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Conditions" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
describe "setting condition" do
|
7
|
+
before { enter 'break 3' }
|
8
|
+
|
9
|
+
describe "successfully" do
|
10
|
+
before { enter ->{"cond #{breakpoint.id} b == 5"}, "cont" }
|
11
|
+
it "must stop at the breakpoint if condition is true" do
|
12
|
+
debug_file('conditions') { state.line.must_equal 3 }
|
13
|
+
end
|
14
|
+
|
15
|
+
it "must assign that expression to breakpoint" do
|
16
|
+
debug_file('conditions') { breakpoint.expr.must_equal "b == 5" }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "must not stop at the breakpoint if condition is false" do
|
21
|
+
enter "break 4", ->{"cond #{breakpoint.id} b == 3"}, "cont"
|
22
|
+
debug_file('conditions') { state.line.must_equal 4 }
|
23
|
+
end
|
24
|
+
|
25
|
+
it "must ignore the condition if its syntax is incorrect" do
|
26
|
+
enter "break 3", ->{"cond #{breakpoint.id} b =="}, "break 4", "cont"
|
27
|
+
debug_file('conditions') { state.line.must_equal 4 }
|
28
|
+
end
|
29
|
+
|
30
|
+
it "must assign the expression to the breakpoint anyway, even if its syntax is incorrect" do
|
31
|
+
enter "break 3", ->{"cond #{breakpoint.id} b =="}, "break 4", "cont"
|
32
|
+
debug_file('conditions') { breakpoint.expr.must_equal "b ==" }
|
33
|
+
end
|
34
|
+
|
35
|
+
it "must work with full command name too" do
|
36
|
+
enter ->{"condition #{breakpoint.id} b == 5"}, "cont"
|
37
|
+
debug_file('conditions') { state.line.must_equal 3 }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
describe "removing conditions" do
|
43
|
+
before { enter "break 3 if b == 3", "break 4", ->{"cond #{breakpoint.id}"}, "cont" }
|
44
|
+
|
45
|
+
it "must remove the condition from the breakpoint" do
|
46
|
+
debug_file('conditions') { breakpoint.expr.must_be_nil }
|
47
|
+
end
|
48
|
+
|
49
|
+
it "must not stop on the breakpoint" do
|
50
|
+
debug_file('conditions') { state.line.must_equal 3 }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
describe "errors" do
|
56
|
+
it "must show error if there are no breakpoints" do
|
57
|
+
enter 'cond 1 true'
|
58
|
+
debug_file('conditions')
|
59
|
+
check_output_includes "No breakpoints have been set."
|
60
|
+
end
|
61
|
+
|
62
|
+
it "must not set breakpoint condition if breakpoint id is incorrect" do
|
63
|
+
enter 'break 3', 'cond 8 b == 3', 'cont'
|
64
|
+
debug_file('conditions') { state.line.must_equal 3 }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
describe "Post Mortem" do
|
70
|
+
it "must be able to set conditions in post-mortem mode" do
|
71
|
+
enter 'cont', 'break 12', ->{"cond #{breakpoint.id} true"}, 'cont'
|
72
|
+
debug_file("post_mortem") { state.line.must_equal 12 }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Continue Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must continue up to breakpoint" do
|
7
|
+
enter 'break 4', 'continue'
|
8
|
+
debug_file('continue') { state.line.must_equal 4 }
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must continue up to specified line" do
|
12
|
+
enter 'cont 4'
|
13
|
+
debug_file('continue') { state.line.must_equal 4 }
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must ignore the command if there is no specified line" do
|
17
|
+
enter 'cont 123'
|
18
|
+
debug_file('continue') { state.line.must_equal 2 }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "must show error if there is no specified line" do
|
22
|
+
enter 'cont 123'
|
23
|
+
debug_file('continue')
|
24
|
+
check_output_includes "Line 123 is not a stopping point in file \"#{fullpath('continue')}\".", interface.error_queue
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must ignore the line if the context is dead"
|
28
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Display Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must show expressions" do
|
7
|
+
enter 'display d + 1', 'break 3', 'cont'
|
8
|
+
debug_file('display')
|
9
|
+
check_output_includes "1: ", "d + 1 = 5"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must work with shortcut" do
|
13
|
+
enter 'disp d + 1', 'break 3', 'cont'
|
14
|
+
debug_file('display')
|
15
|
+
check_output_includes "1: ", "d + 1 = 5"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "must save displayed expressions" do
|
19
|
+
enter 'display d + 1'
|
20
|
+
debug_file('display') { state.display.must_equal [[true, "d + 1"]] }
|
21
|
+
end
|
22
|
+
|
23
|
+
it "displays all expressions available" do
|
24
|
+
enter 'break 3', 'cont', -> do
|
25
|
+
Debugger.handler.display.concat([[true, "abc"], [true, "d"]]); 'display'
|
26
|
+
end
|
27
|
+
debug_file('display')
|
28
|
+
check_output_includes "1: ", "abc = ", "2: ", "d = 4"
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "undisplay" do
|
32
|
+
describe "undisplay all" do
|
33
|
+
before do
|
34
|
+
enter 'break 3', 'cont', -> do
|
35
|
+
Debugger.handler.display.concat([[true, "abc"], [true, "d"]])
|
36
|
+
'undisplay'
|
37
|
+
end, confirm_response, 'display'
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "confirmation is successful" do
|
41
|
+
let(:confirm_response) { 'y' }
|
42
|
+
|
43
|
+
it "must ask about confirmation" do
|
44
|
+
debug_file('display')
|
45
|
+
check_output_includes "Clear all expressions? (y/n)", interface.confirm_queue
|
46
|
+
end
|
47
|
+
|
48
|
+
it "must set all expressions saved to 'false'" do
|
49
|
+
debug_file('display') { state.display.must_equal [[false, "abc"], [false, "d"]] }
|
50
|
+
end
|
51
|
+
|
52
|
+
it "must not show any output" do
|
53
|
+
debug_file('display')
|
54
|
+
check_output_doesnt_include "1: ", "abc = ", "2: ", "d = 4"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "confirmation is unsuccessful" do
|
59
|
+
let(:confirm_response) { 'n' }
|
60
|
+
|
61
|
+
it "must set all expressions saved to 'false'" do
|
62
|
+
debug_file('display') { state.display.must_equal [[true, "abc"], [true, "d"]] }
|
63
|
+
end
|
64
|
+
|
65
|
+
it "must not show any output" do
|
66
|
+
debug_file('display')
|
67
|
+
check_output_includes "1: ", "abc = ", "2: ", "d = 4"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "undisplay specific position" do
|
73
|
+
before do
|
74
|
+
enter 'break 3', 'cont', -> do
|
75
|
+
Debugger.handler.display.concat([[true, "abc"], [true, "d"]])
|
76
|
+
'undisplay 1'
|
77
|
+
end, 'display'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "must set inactive positions" do
|
81
|
+
debug_file('display') { state.display.must_equal [[nil, "abc"], [true, "d"]] }
|
82
|
+
end
|
83
|
+
|
84
|
+
it "must display only the active position" do
|
85
|
+
debug_file('display')
|
86
|
+
check_output_includes "2: ", "d = 4"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "must not display the disabled position" do
|
90
|
+
debug_file('display')
|
91
|
+
check_output_doesnt_include "1: ", "abc"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "disable" do
|
97
|
+
it "must disable a position" do
|
98
|
+
enter 'display d', 'disable display 1'
|
99
|
+
debug_file('display') { state.display.must_equal [[false, "d"]] }
|
100
|
+
end
|
101
|
+
|
102
|
+
it "must show an error if no displays are set" do
|
103
|
+
enter 'disable display 1'
|
104
|
+
debug_file('display')
|
105
|
+
check_output_includes "No display expressions have been set.", interface.error_queue
|
106
|
+
end
|
107
|
+
|
108
|
+
it "must show an error if there is no such display position" do
|
109
|
+
enter 'display d', 'disable display 4'
|
110
|
+
debug_file('display')
|
111
|
+
check_output_includes "Disable display argument '4' needs to at most 1."
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "enable" do
|
116
|
+
it "must enable a position" do
|
117
|
+
enter 'display d', 'disable display 1', 'enable display 1'
|
118
|
+
debug_file('display') { state.display.must_equal [[true, "d"]] }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "annotate" do
|
123
|
+
temporary_change_method_value(Debugger, :annotate, 0)
|
124
|
+
|
125
|
+
it "must show display expression in annotation" do
|
126
|
+
enter 'display 2 + 2', 'set annotate 3', 'next', 'next'
|
127
|
+
debug_file 'display'
|
128
|
+
check_output_includes "\x1A\x1Adisplay", "1:", "2 + 2 = 4"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
describe "Post Mortem" do
|
134
|
+
it "must be able to set display expressions in post-mortem mode" do
|
135
|
+
enter 'cont', 'display 2 + 2', 'cont'
|
136
|
+
debug_file("post_mortem")
|
137
|
+
check_output_includes "1:", "2 + 2 = 4"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
data/test/edit_test.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Edit Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must open an editor with current file and line" do
|
7
|
+
temporary_change_hash_value(ENV, "EDITOR", 'editr') do
|
8
|
+
Debugger::Edit.any_instance.expects(:system).with("editr +2 #{fullpath('edit')}")
|
9
|
+
enter 'edit'
|
10
|
+
debug_file 'edit'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "must open a default editor with current file and line" do
|
15
|
+
temporary_change_hash_value(ENV, "EDITOR", nil) do
|
16
|
+
Debugger::Edit.any_instance.expects(:system).with("ex +2 #{fullpath('edit')}")
|
17
|
+
enter 'edit'
|
18
|
+
debug_file 'edit'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "must open an editor with specified file and line" do
|
23
|
+
temporary_change_hash_value(ENV, "EDITOR", 'editr') do
|
24
|
+
Debugger::Edit.any_instance.expects(:system).with("editr +3 #{fullpath('edit2')}")
|
25
|
+
enter "edit #{fullpath('edit2')}:3"
|
26
|
+
debug_file 'edit'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "must show an error if there is no such line" do
|
31
|
+
enter "edit #{fullpath('edit3')}:6"
|
32
|
+
debug_file 'edit'
|
33
|
+
check_output_includes "File \"#{fullpath('edit3')}\" is not readable.", interface.error_queue
|
34
|
+
end
|
35
|
+
|
36
|
+
it "must show an error if there is incorrect syntax" do
|
37
|
+
enter "edit blabla"
|
38
|
+
debug_file 'edit'
|
39
|
+
check_output_includes "Invalid file/line number specification: blabla", interface.error_queue
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
describe "Post Mortem" do
|
44
|
+
# TODO: This test fails with "Segmentation fault". Probably need to fix it somehow, or forbid this
|
45
|
+
# command in the post mortem mode
|
46
|
+
it "must work in post-mortem mode"
|
47
|
+
# temporary_change_hash_value(ENV, "EDITOR", 'editr') do
|
48
|
+
# Debugger::Edit.any_instance.expects(:system).with("editr +2 #{fullpath('edit')}")
|
49
|
+
# enter 'cont', "edit #{fullpath('edit')}:2", 'cont'
|
50
|
+
# debug_file "post_mortem"
|
51
|
+
# end
|
52
|
+
#end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/test/eval_test.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Eval Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must evaluate an expression" do
|
7
|
+
enter 'eval 3 + 2'
|
8
|
+
debug_file 'eval'
|
9
|
+
check_output_includes "5"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must work with shortcut" do
|
13
|
+
enter 'e 3 + 2'
|
14
|
+
debug_file 'eval'
|
15
|
+
check_output_includes "5"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "must work with another syntax" do
|
19
|
+
enter 'p 3 + 2'
|
20
|
+
debug_file 'eval'
|
21
|
+
check_output_includes "5"
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "autoeval" do
|
25
|
+
temporary_change_hash_value(Debugger::Command.settings, :autoeval, false)
|
26
|
+
|
27
|
+
it "must eval the expression if no matching command is found" do
|
28
|
+
enter 'set autoeval', '[5,6,7].inject(&:+)'
|
29
|
+
debug_file 'eval'
|
30
|
+
check_output_includes "18"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "stack trace on error" do
|
35
|
+
temporary_change_hash_value(Debugger::Command.settings, :stack_trace_on_error, false)
|
36
|
+
|
37
|
+
it "must show a stack trace if showing trace on error is enabled" do
|
38
|
+
enter 'set notrace', 'eval 2 / 0'
|
39
|
+
debug_file 'eval'
|
40
|
+
check_output_includes "ZeroDivisionError Exception: divided by 0"
|
41
|
+
check_output_doesnt_include /\S+:\d+:in `eval':divided by 0/
|
42
|
+
end
|
43
|
+
|
44
|
+
it "must show a stack trace if showing trace on error is enabled" do
|
45
|
+
enter 'set trace', 'eval 2 / 0'
|
46
|
+
debug_file 'eval'
|
47
|
+
check_output_includes /\S+:\d+:in `eval':divided by 0/
|
48
|
+
check_output_doesnt_include "ZeroDivisionError Exception: divided by 0"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
it "must pretty print the expression result" do
|
54
|
+
enter 'pp {a: "3" * 40, b: "4" * 30}'
|
55
|
+
debug_file 'eval'
|
56
|
+
check_output_includes "{:a=>\"#{"3" * 40}\",\n :b=>\"#{"4" * 30}\"}"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "must print expression and columnize the result" do
|
60
|
+
temporary_change_hash_value(Debugger::PutLCommand.settings, :width, 20) do
|
61
|
+
enter 'putl [1, 2, 3, 4, 5, 9, 8, 7, 6]'
|
62
|
+
debug_file 'eval'
|
63
|
+
check_output_includes "1 3 5 8 6\n2 4 9 7"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "must print expression and sort and columnize the result" do
|
68
|
+
temporary_change_hash_value(Debugger::PSCommand.settings, :width, 20) do
|
69
|
+
enter 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
|
70
|
+
debug_file 'eval'
|
71
|
+
check_output_includes "1 3 5 7 9\n2 4 6 8"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "must set width by the 'set' command" do
|
76
|
+
temporary_change_hash_value(Debugger::PSCommand.settings, :width, 20) do
|
77
|
+
enter 'set width 10', 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
|
78
|
+
debug_file 'eval'
|
79
|
+
check_output_includes "1 4 7\n2 5 8\n3 6 9"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
describe "Post Mortem" do
|
85
|
+
it "must work in post-mortem mode" do
|
86
|
+
enter 'cont', 'eval 2 + 2'
|
87
|
+
debug_file "post_mortem"
|
88
|
+
check_output_includes "4"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|