Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |