Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/pp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@ def pretty_print_cycle(q) # :nodoc:
end
end

verbose, $VERBOSE = $VERBOSE, nil
begin
has_data_define = defined?(Data.define)
ensure
$VERBOSE = verbose
end

class Data # :nodoc:
def pretty_print(q) # :nodoc:
class_name = PP.mcall(self, Kernel, :class).name
Expand Down Expand Up @@ -522,7 +529,7 @@ def pretty_print(q) # :nodoc:
def pretty_print_cycle(q) # :nodoc:
q.text sprintf("#<data %s:...>", PP.mcall(self, Kernel, :class).name)
end
end if defined?(Data.define)
end if has_data_define

class Range # :nodoc:
def pretty_print(q) # :nodoc:
Expand Down
9 changes: 8 additions & 1 deletion test/test_pp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,14 @@ def test_struct
assert_equal("#{a.inspect}\n", PP.pp(a, ''.dup)) unless RUBY_ENGINE == "truffleruby"
end

if defined?(Data.define)
verbose, $VERBOSE = $VERBOSE, nil
begin
has_data_define = defined?(Data.define)
ensure
$VERBOSE = verbose
end

if has_data_define
D = Data.define(:aaa, :bbb)
def test_data
a = D.new("aaa", "bbb")
Expand Down
Loading