Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into 1.8.7
Browse files Browse the repository at this point in the history
Conflicts:
	spec/ruby/core/enumerable/cycle_spec.rb
	spec/ruby/core/enumerable/each_with_index_spec.rb
	spec/ruby/core/enumerable/find_index_spec.rb
	spec/ruby/core/enumerable/partition_spec.rb
	spec/ruby/core/enumerable/reject_spec.rb
	spec/ruby/core/enumerable/slice_before_spec.rb
brixen committed Feb 20, 2015
2 parents 35674f3 + 4417909 commit 2dbabba
Showing 59 changed files with 236 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ before_script:
- if [ $TRAVIS_OS_NAME == linux ]; then travis_retry ./configure --llvm-config llvm-config-3.4; fi
- if [ $TRAVIS_OS_NAME == osx ]; then travis_retry ./configure --llvm-config /usr/local/opt/llvm/bin/llvm-config; fi

script: rake
script: rake ci

after_success:
- if [ $TRAVIS_BRANCH == $TRAVIS_TAG ]; then rake deploy; fi
21 changes: 18 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -80,6 +80,7 @@ class SpecRunner

@at_exit_handler_set = false
@at_exit_status = 0
@flags = nil

def self.at_exit_status
@at_exit_status
@@ -96,16 +97,24 @@ class SpecRunner
@at_exit_status = status
end

def self.flags
@flags
end

def self.flags=(value)
@flags = value
end

def initialize
@handler = lambda do |ok, status|
self.class.set_at_exit_status(status.exitstatus) unless ok
end
end

def run(suite=:ci_files, flags=nil)
def run(suite=:ci_files)
self.class.set_at_exit_handler

sh("bin/mspec ci :#{suite} #{ENV['CI_MODE_FLAG'] || flags} -t bin/#{BUILD_CONFIG[:program_name]} -d --background", &@handler)
sh("bin/mspec ci :#{suite} #{self.class.flags} -t bin/#{BUILD_CONFIG[:program_name]} -d --background", &@handler)
end
end

@@ -177,14 +186,20 @@ task :docs do
Rubinius::Documentation.main
end

desc "Run CI in default (configured) mode but do not rebuild on failure"
desc "Run specs in default (configured) mode but do not rebuild on failure"
task :spec => %w[build vm:test] do
clean_environment

spec_runner = SpecRunner.new
spec_runner.run
end

desc "Run specs as in the spec task, but with CI formatting"
task :ci do
SpecRunner.flags = "-V" # show spec file names
Rake::Task["spec"].invoke
end

desc "Print list of items marked to-do in kernel/ (@todo|TODO)"
task :todos do

4 changes: 4 additions & 0 deletions spec/ruby/core/array/delete_if_spec.rb
Original file line number Diff line number Diff line change
@@ -72,4 +72,8 @@
@a.untrusted?.should be_true
end
end

it "returns the correct size when no block is given" do
[1, 2, 3].delete_if.size.should == 3
end
end
4 changes: 4 additions & 0 deletions spec/ruby/core/array/each_index_spec.rb
Original file line number Diff line number Diff line change
@@ -36,5 +36,9 @@
ScratchPad.recorded.should == [0]
end

it "returns the correct size when no block is given" do
[1, 2, 3].each_index.size.should == 3
end

it_behaves_like :enumeratorize, :each_index
end
4 changes: 4 additions & 0 deletions spec/ruby/core/array/each_spec.rb
Original file line number Diff line number Diff line change
@@ -26,5 +26,9 @@
b.should == [2, nil, 4]
end

it "returns the correct size when no block is given" do
[1, 2, 3].each.size.should == 3
end

it_behaves_like :enumeratorize, :each
end
8 changes: 8 additions & 0 deletions spec/ruby/core/array/reject_spec.rb
Original file line number Diff line number Diff line change
@@ -57,6 +57,10 @@
end
end

it "returns the correct size when no block is given" do
[1, 2, 3, 4, 5, 6].reject.size.should == 6
end

it_behaves_like :enumeratorize, :reject
end

@@ -134,5 +138,9 @@
end
end

it "returns the correct size when no block is given" do
[1, 2, 3, 4, 5, 6].reject!.size.should == 6
end

it_behaves_like :enumeratorize, :reject!
end
4 changes: 4 additions & 0 deletions spec/ruby/core/array/reverse_each_spec.rb
Original file line number Diff line number Diff line change
@@ -33,5 +33,9 @@
ScratchPad.recorded.should == [array, array, array, array, array, 3.0, 'two', 1]
end

it "returns the correct size when no block is given" do
[1, 2, 3].reverse_each.size.should == 3
end

it_behaves_like :enumeratorize, :reverse_each
end
4 changes: 4 additions & 0 deletions spec/ruby/core/array/shared/keep_if.rb
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@
[1, 2, 3].send(@method).should be_an_instance_of(enumerator_class)
end

it "returns the correct size when no block is given" do
[1, 2, 3].send(@method).size.should == 3
end

describe "on frozen objects" do
before(:each) do
@origin = [true, false]
4 changes: 4 additions & 0 deletions spec/ruby/core/array/sort_by_spec.rb
Original file line number Diff line number Diff line change
@@ -45,4 +45,8 @@
partially_sorted.any?{|ary| ary != [1, 2, 3, 4, 5]}.should be_true
end
end

it "returns the correct size when no block is given" do
[1, 2, 3, 4, 5, 6].sort_by!.size.should == 6
end
end
43 changes: 42 additions & 1 deletion spec/ruby/core/enumerable/each_with_index_spec.rb
Original file line number Diff line number Diff line change
@@ -3,5 +3,46 @@
require File.expand_path('../shared/each_with_index', __FILE__)

describe "Enumerable#each_with_index" do
it_behaves_like(:each_with_index, :each_with_index)
before :each do
@b = EnumerableSpecs::Numerous.new(2, 5, 3, 6, 1, 4)
end

it "passes each element and its index to block" do
@a = []
@b.each_with_index { |o, i| @a << [o, i] }
@a.should == [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]]
end

it "provides each element to the block" do
acc = []
obj = EnumerableSpecs::EachDefiner.new()
res = obj.each_with_index {|a,i| acc << [a,i]}
acc.should == []
obj.should == res
end

it "provides each element to the block and its index" do
acc = []
res = @b.each_with_index {|a,i| acc << [a,i]}
[[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]].should == acc
res.should eql(@b)
end

it "binds splat arguments properly" do
acc = []
res = @b.each_with_index { |*b| c,d = b; acc << c; acc << d }
[2, 0, 5, 1, 3, 2, 6, 3, 1, 4, 4, 5].should == acc
res.should eql(@b)
end

it "returns an enumerator if no block" do
e = @b.each_with_index
e.should be_an_instance_of(enumerator_class)
e.to_a.should == [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]]
end

it "passes extra parameters to each" do
count = EnumerableSpecs::EachCounter.new(:apple)
count.each_with_index.to_a.should == [[:apple, 0]]
end
end
6 changes: 6 additions & 0 deletions spec/ruby/core/enumerable/fixtures/classes.rb
Original file line number Diff line number Diff line change
@@ -11,6 +11,12 @@ def each
end
end

class NumerousWithSize < Numerous
def size
@list.size
end
end

class EachCounter < Numerous
attr_reader :times_called, :times_yielded, :arguments_passed
def initialize(*list)
1 change: 0 additions & 1 deletion spec/ruby/core/enumerable/partition_spec.rb
Original file line number Diff line number Diff line change
@@ -22,5 +22,4 @@
multi = EnumerableSpecs::YieldsMulti.new
multi.partition {|e| e == [3, 4, 5] }.should == [[[3, 4, 5]], [[1, 2], [6, 7, 8, 9]]]
end

end
1 change: 0 additions & 1 deletion spec/ruby/core/enumerable/reject_spec.rb
Original file line number Diff line number Diff line change
@@ -27,6 +27,5 @@
multi = EnumerableSpecs::YieldsMulti.new
multi.reject {|e| e == [3, 4, 5] }.should == [[1, 2], [6, 7, 8, 9]]
end

end

5 changes: 5 additions & 0 deletions spec/ruby/core/enumerable/shared/collect.rb
Original file line number Diff line number Diff line change
@@ -40,4 +40,9 @@
enum.each { |i| -i }.should == [-2, -5, -3, -6, -1, -4]
end
end

it "returns the correct size when no block is given" do
enum = EnumerableSpecs::NumerousWithSize.new(1, 2, 3, 4)
enum.send(@method).size.should == 4
end
end
5 changes: 5 additions & 0 deletions spec/ruby/core/enumerable/shared/collect_concat.rb
Original file line number Diff line number Diff line change
@@ -47,4 +47,9 @@
enum.should be_an_instance_of(enumerator_class)
enum.each{ |i| [i] * i }.should == [1, 2, 2]
end

it "returns the correct size when no block is given" do
enum = EnumerableSpecs::NumerousWithSize.new([1, 2], [3, 4], [5, 6])
enum.send(@method).size.should == 3
end
end
1 change: 0 additions & 1 deletion spec/ruby/core/enumerable/shared/find.rb
Original file line number Diff line number Diff line change
@@ -74,5 +74,4 @@
multi = EnumerableSpecs::YieldsMulti.new
multi.send(@method) {|e| e == [1, 2] }.should == [1, 2]
end

end
11 changes: 8 additions & 3 deletions spec/ruby/core/enumerable/slice_before_spec.rb
Original file line number Diff line number Diff line change
@@ -16,11 +16,16 @@
e.to_a.should == [[7], [6, 5, 4, 3], [2, 1]]
end

it "doesn't yield an empty array if the filter matches the first entry or the last entry" do
it "uses standard boolean as a test" do
arg = mock "filter"
arg.should_receive(:===).and_return(true).exactly(7)
arg.should_receive(:===).and_return(false, :foo, nil, false, false, 42, false)
e = @enum.slice_before(arg)
e.to_a.should == [[7], [6], [5], [4], [3], [2], [1]]
e.to_a.should == [[7], [6, 5, 4, 3], [2, 1]]
end

it "returns nil as size" do
enum = EnumerableSpecs::NumerousWithSize.new(1, 2, 3, 4, 5, 6)
enum.slice_before(3).size.should == nil
end

it "uses standard boolean as a test" do
38 changes: 33 additions & 5 deletions spec/ruby/core/kernel/shared/load.rb
Original file line number Diff line number Diff line change
@@ -83,12 +83,40 @@
lambda { @object.load(path) }.should raise_error(LoadError)
end

it "sets the enclosing scope to an anonymous module if passed true for 'wrap'" do
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR
@object.load(path, true).should be_true
describe "when passed true for 'wrap'" do
it "loads from an existing path" do
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR
@object.load(path, true).should be_true
end

it "sets the enclosing scope to an anonymous module" do
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR
@object.load(path, true)

Object.const_defined?(:LoadSpecWrap).should be_false
end

it "allows referencing outside namespaces" do
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR
@object.load(path, true)

ScratchPad.recorded.first.should be_an_instance_of(Class)
end

Object.const_defined?(:LoadSpecWrap).should be_false
ScratchPad.recorded.first.should be_an_instance_of(Class)
describe "with top-level methods" do
before :each do
path = File.expand_path "load_wrap_method_fixture.rb", CODE_LOADING_DIR
@object.load(path, true)
end

it "allows calling top-level methods" do
ScratchPad.recorded.last.should == :load_wrap_loaded
end

it "does not pollute the receiver" do
lambda { @object.send(:top_level_method) }.should raise_error(NameError)
end
end
end

describe "(shell expansion)" do
9 changes: 9 additions & 0 deletions spec/ruby/fixtures/code/load_wrap_method_fixture.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def top_level_method
::ScratchPad << :load_wrap_loaded
end

begin
top_level_method
rescue NameError
::ScratchPad << :load_wrap_error
end
2 changes: 2 additions & 0 deletions spec/tags/ruby/core/array/cycle_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Array#cycle returns Float::INFINITY as size when passed no argument and no block is given
fails:Array#cycle returns the correct size when passed a number n as argument and no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/array/delete_if_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Array#delete_if returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/array/each_index_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Array#each_index returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/array/each_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Array#each returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/array/keep_if_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Array#keep_if returns the correct size when no block is given
2 changes: 2 additions & 0 deletions spec/tags/ruby/core/array/reject_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Array#reject returns the correct size when no block is given
fails:Array#reject! returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/array/reverse_each_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Array#reverse_each returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/array/select_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Array#select! returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/array/sort_by_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Array#sort_by! returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/collect_concat_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#collect_concat returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/collect_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#collect returns the correct size when no block is given
2 changes: 2 additions & 0 deletions spec/tags/ruby/core/enumerable/cycle_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Enumerable#cycle passed no argument or nil returns Float::INFINITY as size when no block is given
fails:Enumerable#cycle passed a number n as an argument returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/detect_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#detect returns the nil as size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/drop_while_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#drop_while returns nil as size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/each_cons_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#each_cons returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/each_with_index_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#each_with_index returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/each_with_object_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#each_with_object returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/find_all_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#find_all returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/find_index_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#find_index without block returns nil as size
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/find_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#find returns the nil as size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/flat_map_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#flat_map returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/group_by_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#group_by returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/map_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#map returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/max_by_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#max_by returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/min_by_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#min_by returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/minmax_by_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#minmax_by returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/partition_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#partition returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/reject_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#reject returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/select_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#select returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/sort_by_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#sort_by returns the correct size when no block is given
1 change: 1 addition & 0 deletions spec/tags/ruby/core/enumerable/take_while_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Enumerable#take_while returns nil as size when no block is given
2 changes: 2 additions & 0 deletions spec/tags/ruby/core/kernel/load_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Kernel#load when passed true for 'wrap' with top-level methods allows calling top-level methods
fails:Kernel.load when passed true for 'wrap' with top-level methods allows calling top-level methods
Loading

0 comments on commit 2dbabba

Please sign in to comment.