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

Commits on Jan 9, 2016

  1. Copy the full SHA
    d380a0b View commit details
  2. Copy the full SHA
    28dc295 View commit details
  3. Copy the full SHA
    850dad7 View commit details
Showing with 10 additions and 0 deletions.
  1. +1 −0 kernel/common/io.rb
  2. +9 −0 spec/ruby/core/io/shared/each.rb
1 change: 1 addition & 0 deletions kernel/common/io.rb
Original file line number Diff line number Diff line change
@@ -1394,6 +1394,7 @@ def each(sep_or_limit=$/, limit=nil, &block)
end
end

raise ArgumentError, "limit of 0 is invalid" if limit && limit.zero?
return if @ibuffer.exhausted?

EachReader.new(self, @ibuffer, sep, limit).each(&block)
9 changes: 9 additions & 0 deletions spec/ruby/core/io/shared/each.rb
Original file line number Diff line number Diff line change
@@ -73,6 +73,15 @@
end
end

describe "with limit" do
describe "when limit is 0" do
it "raises an ArgumentError" do
# must pass block so Enumerator is evaluated and raises
lambda { @io.send(@method, 0){} }.should raise_error(ArgumentError)
end
end
end

describe "when passed a String containing one space as a separator" do
it "uses the passed argument as the line separator" do
@io.send(@method, " ") { |s| ScratchPad << s }