Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions core/enumerable/uniq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ def each
end
end

it 'returns an array that contains only first argument of the yield' do
@enum.uniq { |_, label| label.downcase }.should == [0, 2]
ruby_version_is '2.5' do
it 'returns all yield arguments as an array' do
@enum.uniq { |_, label| label.downcase }.should == [[0, 'foo'], [2, 'bar']]
end
end

ruby_bug '#13669', '2.5' do
it 'returns an array that contains only first argument of the yield' do
@enum.uniq { |_, label| label.downcase }.should == [0, 2]
end
end
end
end
Expand Down
39 changes: 39 additions & 0 deletions core/enumerator/lazy/uniq_spec.rb
Original file line number Diff line number Diff line change
@@ -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