Skip to content

Commit

Permalink
Add tests for frame control commands
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 authored and ko1 committed Jun 17, 2021
1 parent 9e8fdce commit 7167fd3
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test/debug/frame_control_test.rb
@@ -0,0 +1,68 @@
# frozen_string_literal: true

require_relative '../support/test_case'

module DEBUGGER__
class FrameControlTest < TestCase
def program
<<~RUBY
1| class Foo
2| def bar
3| baz
4| end
5|
6| def baz
7| 10
8| end
9| end
10|
11| Foo.new.bar
RUBY
end

def test_frame_prints_the_current_frame
debug_code(program) do
type 'b 7'
type 'continue'

type 'frame'
assert_line_text(/Foo#baz at/)
type 'q!'
end
end

def test_up_moves_up_one_frame
debug_code(program) do
type 'b 7'
type 'continue'

type 'frame'
assert_line_text(/Foo#baz at/)
type 'up'
assert_line_text(/Foo#bar at/)
type 'up'
assert_line_text(/<main> at/)
type 'frame'
assert_line_text(/<main> at/)
type 'q!'
end
end

def test_down_moves_down_one_frame
debug_code(program) do
type 'b 7'
type 'continue'

type 'up'
assert_line_text(/Foo#bar at/)
type 'up'
assert_line_text(/<main> at/)
type 'down'
assert_line_text(/Foo#bar at/)
type 'down'
assert_line_text(/Foo#baz at/)
type 'q!'
end
end
end
end

0 comments on commit 7167fd3

Please sign in to comment.