[ruby/pp] Fix pretty printing range begin/end with false or nil
https://github.com/ruby/pp/commit/6d9c0f255a
This commit is contained in:
parent
0de7e6ccb0
commit
7b51b3c75b
@ -488,11 +488,12 @@ end if defined?(Data.define)
|
||||
|
||||
class Range # :nodoc:
|
||||
def pretty_print(q) # :nodoc:
|
||||
q.pp self.begin if self.begin
|
||||
both_nil = self.begin == nil && self.end == nil
|
||||
q.pp self.begin if self.begin != nil || both_nil
|
||||
q.breakable ''
|
||||
q.text(self.exclude_end? ? '...' : '..')
|
||||
q.breakable ''
|
||||
q.pp self.end if self.end
|
||||
q.pp self.end if self.end != nil || both_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,6 +34,10 @@ class PPTest < Test::Unit::TestCase
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user