Skip to content

Commit

Permalink
Add tests for the info command
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Jun 8, 2021
1 parent a8e1497 commit 067e857
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions test/debug/info_test.rb
@@ -0,0 +1,67 @@
# frozen_string_literal: true

require_relative '../support/test_case'

module DEBUGGER__
class BasicInfoTest < TestCase
def program
<<~RUBY
1| def foo
2| @var = 10
3| a = 1
4| @var + 1
5| end
6|
7| foo
RUBY
end

def test_info_prints_locals_by_default
debug_code(program) do
type 'b 5'
type 'c'
type 'info'
assert_line_text(
" %self => main\n" \
" %return => 11\n" \
" a => 1\n" \
" @var => 10\n"
)
type 'q!'
end
end
end

class InfoThreadsTest < TestCase
def program
<<~RUBY
1| def foo
2| Thread.new { sleep 30 }
3| end
4|
5| foo
6| "placeholder"
RUBY
end

def test_prints_current_thread
debug_code(program) do
type 'b 6'
type 'c'
type 'info threads'
assert_line_text(/#0 \(sleep\)@.*:6:in `<main>'/)
type 'q!'
end
end

def test_prints_the_other_thread
debug_code(program) do
type 'b 6'
type 'c'
type 'info threads'
assert_line_text(/#1 \(sleep\)@.*:2 sleep_forever/)
type 'q!'
end
end
end
end

0 comments on commit 067e857

Please sign in to comment.