Skip to content

Commit 82fb8c8

Browse files
committedJan 9, 2016
fix merge problem handling eof in #each
2 parents f813c6c + 850dad7 commit 82fb8c8

File tree

7 files changed

+49
-13
lines changed

7 files changed

+49
-13
lines changed
 

‎README

+13-8
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ Rubinius runs on Mac OS X and many Unix/Linux operating systems. Microsoft
1111
Windows is not yet supported.
1212

1313

14-
2. The Ruby Programming Language
14+
2. Code of Conduct
15+
16+
Participation in the Rubinius project is governed by the Rubinius Code of
17+
Conduct. See http://rubinius.com/code-of-conduct/
18+
19+
3. The Ruby Programming Language
1520

1621
Many popular Ruby applications, like Rails, run on Rubinius, which aims to be
17-
compatible with Ruby version 2.1.
22+
compatible with Ruby version 2.2.
1823

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

3540

36-
3. License
41+
4. License
3742

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

42-
4. Installing Rubinius from Source
47+
5. Installing Rubinius from Source
4348

4449
To install Rubinius, use the following steps:
4550

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

5863

59-
5. Using RubyGems
64+
6. Using RubyGems
6065

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

6368
$ rbx -S gem install <gem_name>
6469

6570

66-
6. Documentation
71+
7. Documentation
6772

6873
The Rubinius documentation is available at the Rubinius website:
6974

7075
http://rubinius.com
7176

7277

73-
7. Issues & Support
78+
8. Issues & Support
7479

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

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

8388

84-
8. Contributing
89+
9. Contributing
8590

8691
The Rubinius team welcomes contributions. For more information, read the
8792
CONTRIBUTING file in the root directory of Rubinius.

‎README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ Rubinius includes a bytecode virtual machine, generational garbage collector, an
99
Rubinius runs on Mac OS X and many Unix/Linux operating systems. Microsoft Windows is not yet supported.
1010

1111

12+
### Code of Conduct
13+
14+
Participation in the Rubinius project is governed by the Rubinius [Code of
15+
Conduct](http://rubinius.com/code-of-conduct/).
16+
1217
### The Ruby Programming Language
1318

1419
Many popular Ruby applications, like Rails, run on Rubinius, which aims to be
15-
compatible with Ruby version 2.1.
20+
compatible with Ruby version 2.2.
1621

1722
Rubinius includes a Ruby parser, Ruby bytecode compiler, Ruby core library,
1823
and C-API compatibility for native C extensions. The Ruby core library is

‎kernel/common/enumerable.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ def find_index(value=undefined)
563563

564564
def first(n=undefined)
565565
return __take__(n) unless undefined.equal?(n)
566-
each { |element| return element }
566+
each do
567+
return Rubinius.single_block_arg
568+
end
567569
nil
568570
end
569571

‎kernel/common/io.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -2170,6 +2170,7 @@ def each(sep_or_limit=$/, limit=nil, &block)
21702170
end
21712171
end
21722172

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

21752176
EachReader.new(self, sep, limit).each(&block)
@@ -2596,9 +2597,9 @@ def puts(*args)
25962597
str = ""
25972598
elsif Thread.guarding? arg
25982599
str = "[...]"
2599-
elsif arg.kind_of?(Array)
2600+
elsif arg.respond_to?(:to_ary)
26002601
Thread.recursion_guard arg do
2601-
arg.each do |a|
2602+
arg.to_ary.each do |a|
26022603
puts a
26032604
end
26042605
end

‎spec/ruby/core/enumerable/first_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
EnumerableSpecs::Empty.new.first.should == nil
1313
end
1414

15+
it 'returns a gathered array from yield parameters' do
16+
EnumerableSpecs::YieldsMulti.new.to_enum.first.should == [1, 2]
17+
EnumerableSpecs::YieldsMixed2.new.to_enum.first.should == nil
18+
end
19+
1520
it "raises a RangeError when passed a Bignum" do
1621
enum = EnumerableSpecs::Empty.new
1722
lambda { enum.first(bignum_value) }.should raise_error(RangeError)

‎spec/ruby/core/io/puts_spec.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@
3737
@io.puts(nil, nil).should == nil
3838
end
3939

40-
it "calls to_s before writing non-string objects" do
40+
it "calls to_ary before writing non-string objects that respond to :to_ary" do
41+
object = mock('hola')
42+
object.should_receive(:to_ary).and_return(["hola"])
43+
44+
@io.should_receive(:write).with("hola")
45+
@io.should_receive(:write).with("\n")
46+
@io.puts(object).should == nil
47+
end
48+
49+
it "calls to_s before writing non-string objects that don't respond to :to_ary" do
4150
object = mock('hola')
4251
object.should_receive(:to_s).and_return("hola")
4352

‎spec/ruby/core/io/shared/each.rb

+9
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@
7373
end
7474
end
7575

76+
describe "with limit" do
77+
describe "when limit is 0" do
78+
it "raises an ArgumentError" do
79+
# must pass block so Enumerator is evaluated and raises
80+
lambda { @io.send(@method, 0){} }.should raise_error(ArgumentError)
81+
end
82+
end
83+
end
84+
7685
describe "when passed a String containing one space as a separator" do
7786
it "uses the passed argument as the line separator" do
7887
@io.send(@method, " ") { |s| ScratchPad << s }

0 commit comments

Comments
 (0)
Failed to load comments.