diff --git a/lib/pp.rb b/lib/pp.rb index fb7aa7b41c6fd4..f04b7bf0cc9cb8 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -444,7 +444,7 @@ def pretty_print_cycle(q) # :nodoc: class Range # :nodoc: def pretty_print(q) # :nodoc: - q.pp self.begin + q.pp self.begin if self.begin q.breakable '' q.text(self.exclude_end? ? '...' : '..') q.breakable '' diff --git a/test/test_pp.rb b/test/test_pp.rb index 6da2b808b9844f..26e730fd009ffd 100644 --- a/test/test_pp.rb +++ b/test/test_pp.rb @@ -28,6 +28,13 @@ def o.method end assert_equal(%(""\n), PP.pp(o, "".dup)) end + + def test_range + assert_equal("0..1\n", PP.pp(0..1, "".dup)) + 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)) + end end class HasInspect