Skip to content

Commit

Permalink
fix merge problem handling eof in #each
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckremes committed Jan 9, 2016
2 parents f813c6c + 850dad7 commit 82fb8c8
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 13 deletions.
21 changes: 13 additions & 8 deletions README
Expand Up @@ -11,10 +11,15 @@ Rubinius runs on Mac OS X and many Unix/Linux operating systems. Microsoft
Windows is not yet supported.


2. The Ruby Programming Language
2. Code of Conduct

Participation in the Rubinius project is governed by the Rubinius Code of
Conduct. See http://rubinius.com/code-of-conduct/

3. The Ruby Programming Language

Many popular Ruby applications, like Rails, run on Rubinius, which aims to be
compatible with Ruby version 2.1.
compatible with Ruby version 2.2.

Rubinius includes a Ruby parser, Ruby bytecode compiler, Ruby core library,
and C-API compatibility for native C extensions. The Ruby core library is
Expand All @@ -33,13 +38,13 @@ The following Ruby features are not supported on Rubinius:
* $SAFE levels


3. License
4. License

Rubinius uses the MPL-2.0 license. See LICENSE for details. Contributions made
prior to January 3rd, 2016 are licensed under the old BSD 3-clause license. A
copy of this license can be found in the file "BSD_LICENSE".

4. Installing Rubinius from Source
5. Installing Rubinius from Source

To install Rubinius, use the following steps:

Expand All @@ -56,21 +61,21 @@ information see http://rubinius.com/doc/en/getting-started/requirements/
and http://rubinius.com/doc/en/getting-started/building/.


5. Using RubyGems
6. Using RubyGems

Rubinius comes with RubyGems built-in. To install a gem, run the following:

$ rbx -S gem install <gem_name>


6. Documentation
7. Documentation

The Rubinius documentation is available at the Rubinius website:

http://rubinius.com


7. Issues & Support
8. Issues & Support

Please file tickets for bugs or problems. The issue tracker is:

Expand All @@ -81,7 +86,7 @@ For additional help, visit the Rubinius Gitter chat room:
https://gitter.im/rubinius/rubinius


8. Contributing
9. Contributing

The Rubinius team welcomes contributions. For more information, read the
CONTRIBUTING file in the root directory of Rubinius.
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -9,10 +9,15 @@ Rubinius includes a bytecode virtual machine, generational garbage collector, an
Rubinius runs on Mac OS X and many Unix/Linux operating systems. Microsoft Windows is not yet supported.


### Code of Conduct

Participation in the Rubinius project is governed by the Rubinius [Code of
Conduct](http://rubinius.com/code-of-conduct/).

### The Ruby Programming Language

Many popular Ruby applications, like Rails, run on Rubinius, which aims to be
compatible with Ruby version 2.1.
compatible with Ruby version 2.2.

Rubinius includes a Ruby parser, Ruby bytecode compiler, Ruby core library,
and C-API compatibility for native C extensions. The Ruby core library is
Expand Down
4 changes: 3 additions & 1 deletion kernel/common/enumerable.rb
Expand Up @@ -563,7 +563,9 @@ def find_index(value=undefined)

def first(n=undefined)
return __take__(n) unless undefined.equal?(n)
each { |element| return element }
each do
return Rubinius.single_block_arg
end
nil
end

Expand Down
5 changes: 3 additions & 2 deletions kernel/common/io.rb
Expand Up @@ -2170,6 +2170,7 @@ def each(sep_or_limit=$/, limit=nil, &block)
end
end

raise ArgumentError, "limit of 0 is invalid" if limit && limit.zero?
return if eof?

EachReader.new(self, sep, limit).each(&block)
Expand Down Expand Up @@ -2596,9 +2597,9 @@ def puts(*args)
str = ""
elsif Thread.guarding? arg
str = "[...]"
elsif arg.kind_of?(Array)
elsif arg.respond_to?(:to_ary)
Thread.recursion_guard arg do
arg.each do |a|
arg.to_ary.each do |a|
puts a
end
end
Expand Down
5 changes: 5 additions & 0 deletions spec/ruby/core/enumerable/first_spec.rb
Expand Up @@ -12,6 +12,11 @@
EnumerableSpecs::Empty.new.first.should == nil
end

it 'returns a gathered array from yield parameters' do
EnumerableSpecs::YieldsMulti.new.to_enum.first.should == [1, 2]
EnumerableSpecs::YieldsMixed2.new.to_enum.first.should == nil
end

it "raises a RangeError when passed a Bignum" do
enum = EnumerableSpecs::Empty.new
lambda { enum.first(bignum_value) }.should raise_error(RangeError)
Expand Down
11 changes: 10 additions & 1 deletion spec/ruby/core/io/puts_spec.rb
Expand Up @@ -37,7 +37,16 @@
@io.puts(nil, nil).should == nil
end

it "calls to_s before writing non-string objects" do
it "calls to_ary before writing non-string objects that respond to :to_ary" do
object = mock('hola')
object.should_receive(:to_ary).and_return(["hola"])

@io.should_receive(:write).with("hola")
@io.should_receive(:write).with("\n")
@io.puts(object).should == nil
end

it "calls to_s before writing non-string objects that don't respond to :to_ary" do
object = mock('hola')
object.should_receive(:to_s).and_return("hola")

Expand Down
9 changes: 9 additions & 0 deletions spec/ruby/core/io/shared/each.rb
Expand Up @@ -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 }
Expand Down

0 comments on commit 82fb8c8

Please sign in to comment.