зеркало из https://github.com/github/ruby.git
[ruby/pp] Print beginless ranges properly
Instead of displaying the start of the range as nil https://github.com/ruby/pp/commit/1df210d903
This commit is contained in:
Родитель
9c3299896e
Коммит
e0312f90bb
|
@ -444,7 +444,7 @@ end if defined?(Data.define)
|
|||
|
||||
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 ''
|
||||
|
|
|
@ -28,6 +28,13 @@ class PPTest < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче