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

Commits on Jun 5, 2015

  1. Copy the full SHA
    60b0f83 View commit details
  2. Copy the full SHA
    9746ecd View commit details
  3. Merge pull request #3425 from kachick/fix-lazy-take-size

    Enumerator::Lazy#take should switch size with Infinity
    Yorick Peterse committed Jun 5, 2015
    Copy the full SHA
    c575a16 View commit details
Showing with 5 additions and 1 deletion.
  1. +1 −1 kernel/common/enumerator.rb
  2. +4 −0 spec/ruby/core/enumerator/lazy/take_spec.rb
2 changes: 1 addition & 1 deletion kernel/common/enumerator.rb
Original file line number Diff line number Diff line change
@@ -258,7 +258,7 @@ def take(n)
raise ArgumentError, "attempt to take negative size" if n < 0

current_size = enumerator_size
set_size = if current_size.kind_of?(Integer)
set_size = if current_size.kind_of?(Numeric)
n < current_size ? n : current_size
else
current_size
4 changes: 4 additions & 0 deletions spec/ruby/core/enumerator/lazy/take_spec.rb
Original file line number Diff line number Diff line change
@@ -25,6 +25,10 @@
enumerator_class::Lazy.new(Object.new, 100) {}.take(200).size.should == 100
end

it "sets given count to size if the old size is Infinity" do
loop.lazy.take(20).size.should == 20
end

describe "when the returned lazy enumerator is evaluated by .force" do
it "stops after specified times" do
(0..Float::INFINITY).lazy.take(2).force.should == [0, 1]