Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c575a16d57bb
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a74f43772806
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Jun 5, 2015

  1. Copy the full SHA
    2ce6ecf View commit details
  2. Copy the full SHA
    e6ca982 View commit details

Commits on Jun 6, 2015

  1. Merge pull request #3427 from kachick/enumerator-size

    Enumerator#size should call callable size as Proc
    Yorick Peterse committed Jun 6, 2015
    Copy the full SHA
    a74f437 View commit details
Showing with 7 additions and 1 deletion.
  1. +1 −1 kernel/common/enumerator.rb
  2. +6 −0 spec/ruby/core/enumerator/size_spec.rb
2 changes: 1 addition & 1 deletion kernel/common/enumerator.rb
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ def rewind
end

def size
@size.kind_of?(Proc) ? @size.call : @size
@size.respond_to?(:call) ? @size.call : @size
end

def with_index(offset=0)
6 changes: 6 additions & 0 deletions spec/ruby/core/enumerator/size_spec.rb
Original file line number Diff line number Diff line change
@@ -17,4 +17,10 @@
base_size = 300
enum.size.should == 301
end

it "returns the result from size.call if the size respond to call " do
obj = mock('call')
obj.should_receive(:call).and_return(42)
Enumerator.new(obj) {}.size.should == 42
end
end