Commit d016059b authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2017 from suzukaze/fix_enumerator.inspect

Add args in Enumerator#inspect
parents eab754d8 1368ae64
......@@ -216,7 +216,15 @@ class Enumerator
def inspect
return "#<#{self.class}: uninitialized>" unless @obj
"#<#{self.class}: #{@obj}:#{@meth}>"
args = ""
if @args && @args.size > 0
args = "("
@args.each {|arg| args << "#{arg}, " }
args = args[0, args.size-2]
args << ")"
end
"#<#{self.class}: #{@obj}:#{@meth}#{args}>"
end
##
......
......@@ -90,6 +90,10 @@ end
assert 'Enumerator#inspect' do
e = (0..10).each
assert_equal("#<Enumerator: 0..10:each>", e.inspect)
e = Enumerator.new("FooObject", :foo, 1)
assert_equal("#<Enumerator: FooObject:foo(1)>", e.inspect)
e = Enumerator.new("FooObject", :foo, 1, 2, 3)
assert_equal("#<Enumerator: FooObject:foo(1, 2, 3)>", e.inspect)
end
assert 'Enumerator#each' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment