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
6 changes: 4 additions & 2 deletions lib/pp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,13 @@ def pretty_print_cycle(q) # :nodoc:

class Range # :nodoc:
def pretty_print(q) # :nodoc:
q.pp self.begin if self.begin
begin_nil = self.begin == nil
end_nil = self.end == nil
q.pp self.begin if !begin_nil || end_nil
q.breakable ''
q.text(self.exclude_end? ? '...' : '..')
q.breakable ''
q.pp self.end if self.end
q.pp self.end if !end_nil || begin_nil
end
end

Expand Down
4 changes: 4 additions & 0 deletions test/test_pp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def test_range
assert_equal("0...1\n", PP.pp(0...1, "".dup))
assert_equal("0...\n", PP.pp(0..., "".dup))
assert_equal("...1\n", PP.pp(...1, "".dup))
assert_equal("..false\n", PP.pp(..false, "".dup))
assert_equal("false..\n", PP.pp(false.., "".dup))
assert_equal("false..false\n", PP.pp(false..false, "".dup))
assert_equal("nil..nil\n", PP.pp(nil..nil, "".dup))
end
end

Expand Down