forked from ruby/debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint_test.rb
More file actions
62 lines (55 loc) · 1.25 KB
/
Copy pathprint_test.rb
File metadata and controls
62 lines (55 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true
require_relative '../support/console_test_case'
module DEBUGGER__
class PrintTest < ConsoleTestCase
def program
<<~RUBY
1| h = { foo: "bar" }
2| binding.break
RUBY
end
def test_p_prints_the_expression
debug_code(program) do
type "c"
type "p h"
assert_line_text({ foo: "bar" }.inspect)
type "c"
end
end
def test_pp_pretty_prints_the_expression
debug_code(program) do
type "c"
type "pp h"
assert_line_text({ foo: "bar" }.pretty_print_inspect)
type "c"
end
end
end
class InspectionFailureTest < ConsoleTestCase
def program
<<~RUBY
1| f = Object.new
2| def f.inspect
3| raise "foo"
4| end
5| binding.b
RUBY
end
def test_p_prints_the_expression
debug_code(program) do
type "c"
type "p f"
assert_line_text('#<RuntimeError: foo> rescued during inspection')
type "c"
end
end
def test_pp_pretty_prints_the_expression
debug_code(program) do
type "c"
type "pp f"
assert_line_text('#<RuntimeError: foo> rescued during inspection')
type "c"
end
end
end
end