forked from ruby/debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnested_break_test.rb
More file actions
103 lines (82 loc) · 1.93 KB
/
nested_break_test.rb
File metadata and controls
103 lines (82 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# frozen_string_literal: true
require_relative '../support/console_test_case'
module DEBUGGER__
class NestedBreakAtMethodsTest < ConsoleTestCase
def program
<<~RUBY
1| def foo a
2| b = a + 1 # break
3| end
4| def bar
5| x = 1 # break
6| end
7| bar
8| x = 2
RUBY
end
def test_nested_break
debug_code program do
type 'break 2'
type 'break 5'
type 'c'
assert_line_num 5
type 'up'
assert_line_text(/=>\#1/)
type 'p foo(42)'
if TracePoint.respond_to? :allow_reentry
# nested break
assert_line_num 2
type 'p a'
assert_line_text(/42/)
type 'c'
assert_line_num 7 # because restored `up` line
end
# pop nested break
assert_line_text(/43/)
type 'bt'
assert_line_text(/=>\#1/)
type 'c'
end
end
def test_nested_break_bt
debug_code program do
type 'break 2'
type 'break 5'
type 'c'
assert_line_num 5
type 'p foo(42)'
if TracePoint.respond_to? :allow_reentry
# nested break
assert_line_num 2
type 'bt'
assert_no_line_text 'thread_client.rb'
type 'c'
end
type 'c'
end
end
def test_multiple_nested_break
debug_code program do
type 'break 2'
type 'break 5'
type 'c'
assert_line_num 5
type 'p foo(42)'
if TracePoint.respond_to? :allow_reentry
# nested break
assert_line_num 2
type 'p foo(142)'
type 'bt'
assert_line_text(/\#\d+\s+<main>/)
type 'c'
assert_line_text(/143/)
type 'bt'
assert_no_line_text(/\#9/)
type 'c'
end
assert_line_text(/43/)
type 'c'
end
end
end
end