Skip to content

Commit 891bd8b

Browse files
st0012ko1
authored andcommitted
Add tests for binding.bp with pre/do options
1 parent ef4ff9c commit 891bd8b

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

test/debug/bp_test.rb

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ def test_breakpoint_fires_correctly
2525
end
2626
end
2727

28-
class BindingBPWithCommandTest < TestCase
28+
class BindingBPWithPreCommandTest < TestCase
2929
def program
3030
<<~RUBY
3131
1| class Foo
3232
2| def bar
33-
3| binding.bp(do: "continue")
33+
3| binding.bp(pre: "p 'aaaaa'")
3434
4| baz
3535
5| end
3636
6|
@@ -45,11 +45,54 @@ def program
4545

4646
def test_breakpoint_execute_command_argument_correctly
4747
debug_code(program) do
48+
type 'continue'
49+
assert_line_text('Foo#bar')
50+
assert_line_text(/aaaaa/)
51+
# should stay at Foo#bar
52+
assert_no_line_text(/Foo#baz/)
53+
4854
type 'continue'
4955
assert_line_text('Foo#baz')
56+
type 'continue'
57+
end
58+
end
59+
60+
def test_debugger_doesnt_complain_about_duplicated_breakpoint
61+
debug_code(program) do
62+
type 'continue'
63+
assert_no_line_text(/duplicated breakpoint:/)
5064
type 'q!'
5165
end
5266
end
67+
end
68+
69+
class BindingBPWithDoCommandTest < TestCase
70+
def program
71+
<<~RUBY
72+
1| class Foo
73+
2| def bar
74+
3| binding.bp(do: "p 'aaaaa'")
75+
4| baz
76+
5| end
77+
6|
78+
7| def baz
79+
8| binding.bp
80+
9| end
81+
10| end
82+
11|
83+
12| Foo.new.bar
84+
RUBY
85+
end
86+
87+
def test_breakpoint_execute_command_argument_correctly
88+
debug_code(program) do
89+
type 'continue'
90+
assert_line_text(/aaaaa/)
91+
# should move on to the next bp
92+
assert_line_text('Foo#baz')
93+
type 'continue'
94+
end
95+
end
5396

5497
def test_debugger_doesnt_complain_about_duplicated_breakpoint
5598
debug_code(program) do

0 commit comments

Comments
 (0)