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: a74f43772806
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3c7b4ec4ff59
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Jun 5, 2015

  1. Copy the full SHA
    c391908 View commit details
  2. Copy the full SHA
    7330b68 View commit details

Commits on Jun 6, 2015

  1. Merge pull request #3428 from kachick/enumerable-each_cons

    Enumerable#each_cons should set size at 0 when the argument is larger than self
    Yorick Peterse committed Jun 6, 2015
    Copy the full SHA
    3c7b4ec View commit details
Showing with 8 additions and 3 deletions.
  1. +3 −3 kernel/common/enumerable.rb
  2. +5 −0 spec/ruby/core/enumerable/each_cons_spec.rb
6 changes: 3 additions & 3 deletions kernel/common/enumerable.rb
Original file line number Diff line number Diff line change
@@ -418,9 +418,9 @@ def each_cons(num)
unless block_given?
return to_enum(:each_cons, num) do
enum_size = enumerator_size
if enum_size.nil?
nil
elsif enum_size == 0
if enum_size.nil?
nil
elsif enum_size == 0 || enum_size < n
0
else
enum_size - n + 1
5 changes: 5 additions & 0 deletions spec/ruby/core/enumerable/each_cons_spec.rb
Original file line number Diff line number Diff line change
@@ -75,6 +75,11 @@
enum.each_cons(1).size.should == 10
end

it "returns 0 when the argument is larger than self" do
enum = EnumerableSpecs::NumerousWithSize.new(1, 2, 3)
enum.each_cons(20).size.should == 0
end

it "returns 0 when the enum is empty" do
enum = EnumerableSpecs::EmptyWithSize.new
enum.each_cons(10).size.should == 0