Skip to content

Commit 3fec2d9

Browse files
st0012ko1
authored andcommitted
Add whereami test
1 parent 87b6c06 commit 3fec2d9

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

test/console/whereami_test.rb

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../support/console_test_case'
4+
5+
module DEBUGGER__
6+
class WhereamiTest < ConsoleTestCase
7+
def program
8+
<<~RUBY
9+
1| a = 1
10+
2| a = 1
11+
3| a = 1
12+
4| a = 1
13+
5| a = 1
14+
6| a = 1
15+
7| a = 1
16+
8| a = 1
17+
9| a = 1
18+
10| a = 1
19+
11| b = 1
20+
12| b = 1
21+
13| b = 1
22+
14| b = 1
23+
15| b = 1
24+
16| b = 1
25+
17| b = 1
26+
18| b = 1
27+
19| b = 1
28+
20| b = 1
29+
21| c = 1
30+
RUBY
31+
end
32+
33+
def test_whereami_displays_current_frames_code
34+
debug_code(program) do
35+
type "list"
36+
type "list"
37+
38+
# after 2 list commands, we should advance to the next 10 lines and not able to see the current frame's source
39+
assert_no_line_text(/=> 1\| a = 1/)
40+
assert_line_text(/b = 1/)
41+
42+
type "whereami"
43+
44+
# with whereami, we should see the current frame's source but have no visual outside the closest 10 lines
45+
assert_no_line_text(/b = 1/)
46+
assert_line_text(/=> 1\| a = 1/)
47+
48+
type "list"
49+
50+
# list command should work as normal after whereami is executed
51+
assert_no_line_text(/b = 1/)
52+
assert_line_text(/c = 1/)
53+
54+
type "continue"
55+
end
56+
end
57+
end
58+
end

0 commit comments

Comments
 (0)