mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
Update to ruby/spec@abf1700
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6a4aa4838c
commit
5b593e3889
79 changed files with 1555 additions and 304 deletions
|
@ -1,5 +1,17 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe "Enumerator#inspect" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
describe "shows a representation of the Enumerator" do
|
||||
it "including receiver and method" do
|
||||
(1..3).each.inspect.should == "#<Enumerator: 1..3:each>"
|
||||
end
|
||||
|
||||
it "including receiver and method and arguments" do
|
||||
(1..3).each_slice(2).inspect.should == "#<Enumerator: 1..3:each_slice(2)>"
|
||||
end
|
||||
|
||||
it "including the nested Enumerator" do
|
||||
(1..3).each.each_slice(2).inspect.should == "#<Enumerator: #<Enumerator: 1..3:each>:each_slice(2)>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ describe "Enumerator::Lazy#grep" do
|
|||
end
|
||||
|
||||
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
|
||||
it "stops after specified times when not given a block" do
|
||||
it "stops after specified times when not given a block" do
|
||||
(0..Float::INFINITY).lazy.grep(Integer).grep(Object).first(3).should == [0, 1, 2]
|
||||
|
||||
@eventsmixed.grep(BasicObject).grep(Object).first(1)
|
||||
|
|
|
@ -63,7 +63,7 @@ ruby_version_is "2.3" do
|
|||
end
|
||||
|
||||
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
|
||||
it "stops after specified times when not given a block" do
|
||||
it "stops after specified times when not given a block" do
|
||||
(0..Float::INFINITY).lazy.grep_v(3..5).grep_v(6..10).first(3).should == [0, 1, 2]
|
||||
|
||||
@eventsmixed.grep_v(Symbol).grep_v(String).first(1)
|
||||
|
|
39
spec/rubyspec/core/enumerator/lazy/uniq_spec.rb
Normal file
39
spec/rubyspec/core/enumerator/lazy/uniq_spec.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../fixtures/classes', __FILE__)
|
||||
|
||||
ruby_version_is '2.4' do
|
||||
describe 'Enumerator::Lazy#uniq' do
|
||||
context 'when yielded with an argument' do
|
||||
before :each do
|
||||
@lazy = [0, 1, 2, 3].to_enum.lazy.uniq(&:even?)
|
||||
end
|
||||
|
||||
it 'returns a lazy enumerator' do
|
||||
@lazy.should be_an_instance_of(Enumerator::Lazy)
|
||||
@lazy.force.should == [0, 1]
|
||||
end
|
||||
|
||||
it 'sets the size to nil' do
|
||||
@lazy.size.should == nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when yielded with multiple arguments' do
|
||||
before :each do
|
||||
enum = Object.new.to_enum
|
||||
class << enum
|
||||
def each
|
||||
yield 0, 'foo'
|
||||
yield 1, 'FOO'
|
||||
yield 2, 'bar'
|
||||
end
|
||||
end
|
||||
@lazy = enum.lazy
|
||||
end
|
||||
|
||||
it 'returns all yield arguments as an array' do
|
||||
@lazy.uniq { |_, label| label.downcase }.force.should == [[0, 'foo'], [2, 'bar']]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue