Skip to content

Commit 07c1a7c

Browse files
committed
add a test
1 parent 6ae38ba commit 07c1a7c

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../support/test_case'
4+
5+
module DEBUGGER__
6+
class PostmortemTest < TestCase
7+
def program
8+
<<~RUBY
9+
1| def foo y = __LINE__
10+
2| bar
11+
3| end
12+
4| def bar x = __LINE__
13+
5| raise
14+
6| end
15+
7| foo
16+
RUBY
17+
end
18+
19+
def test_config_postmortem
20+
debug_code(program) do
21+
type 'config postmortem = true'
22+
type 'c'
23+
assert_line_text(/Enter postmortem mode with RuntimeError/)
24+
type 'p x'
25+
assert_line_text(/=> 4/)
26+
type 'up'
27+
type 'p y'
28+
assert_line_text(/=> 1/)
29+
type 'step'
30+
assert_line_text(/Can not use this command on postmortem mode/)
31+
type 'c'
32+
# assert_line_text(/unhandled exception/)
33+
end
34+
end
35+
end
36+
37+
class CustomPostmortemTest < TestCase
38+
def program
39+
<<~RUBY
40+
1| DEBUGGER__::CONFIG[:postmortem] = true
41+
2| def foo y = __LINE__
42+
3| bar
43+
4| end
44+
5| def bar x = __LINE__
45+
6| raise
46+
7| end
47+
8| begin
48+
9| foo
49+
10| rescue => e
50+
11| DEBUGGER__::SESSION.enter_postmortem_session e
51+
12| end
52+
13| binding.b
53+
14| v = :ok1
54+
15| DEBUGGER__::CONFIG[:postmortem] = false
55+
RUBY
56+
end
57+
58+
def test_config_postmortem
59+
debug_code(program) do
60+
type 'c'
61+
assert_line_num 6
62+
type 'bt'
63+
assert_line_text([/bar/, /foo/])
64+
type 'c'
65+
assert_line_num 13
66+
type 'p v'
67+
assert_line_text(/=> nil/)
68+
type 'step'
69+
type 'step'
70+
type 'p v'
71+
assert_line_text(/=> :ok1/)
72+
type 'c'
73+
assert_finish
74+
end
75+
end
76+
end
77+
end

0 commit comments

Comments
 (0)