diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
commit | da7976235fbc2986925969646071bebe3702e49f (patch) | |
tree | 83bbf6a8e03cf990369feabe6c1c9d45c69f4c85 /spec/ruby/core/enumerator/lazy/shared | |
parent | b8e389a0f3226c90e96e02e6396686a3bef6a456 (diff) |
Update to ruby/spec@7a16e01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/enumerator/lazy/shared')
4 files changed, 24 insertions, 0 deletions
diff --git a/spec/ruby/core/enumerator/lazy/shared/collect.rb b/spec/ruby/core/enumerator/lazy/shared/collect.rb index a686f30fd8..5690255a0c 100644 --- a/spec/ruby/core/enumerator/lazy/shared/collect.rb +++ b/spec/ruby/core/enumerator/lazy/shared/collect.rb @@ -53,4 +53,10 @@ describe :enumerator_lazy_collect, shared: true do end end end + + it "works with an infinite enumerable" do + s = 0..Float::INFINITY + s.lazy.send(@method) { |n| n }.first(100).should == + s.first(100).send(@method) { |n| n }.to_a + end end diff --git a/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb b/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb index 26478f4ce0..e8ee4b6940 100644 --- a/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb +++ b/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb @@ -69,4 +69,10 @@ describe :enumerator_lazy_collect_concat, shared: true do end end end + + it "works with an infinite enumerable" do + s = 0..Float::INFINITY + s.lazy.send(@method) { |n| [-n, +n] }.first(200).should == + s.first(100).send(@method) { |n| [-n, +n] }.to_a + end end diff --git a/spec/ruby/core/enumerator/lazy/shared/select.rb b/spec/ruby/core/enumerator/lazy/shared/select.rb index 9127cf72b4..39074408ee 100644 --- a/spec/ruby/core/enumerator/lazy/shared/select.rb +++ b/spec/ruby/core/enumerator/lazy/shared/select.rb @@ -57,4 +57,10 @@ describe :enumerator_lazy_select, shared: true do end end end + + it "works with an infinite enumerable" do + s = 0..Float::INFINITY + s.lazy.send(@method) { |n| true }.first(100).should == + s.first(100).send(@method) { |n| true } + end end diff --git a/spec/ruby/core/enumerator/lazy/shared/to_enum.rb b/spec/ruby/core/enumerator/lazy/shared/to_enum.rb index a62a8ef90e..d488c9b263 100644 --- a/spec/ruby/core/enumerator/lazy/shared/to_enum.rb +++ b/spec/ruby/core/enumerator/lazy/shared/to_enum.rb @@ -47,4 +47,10 @@ describe :enumerator_lazy_to_enum, shared: true do @infinite.send(method, *args).should be_an_instance_of(Enumerator::Lazy) end end + + it "works with an infinite enumerable" do + s = 0..Float::INFINITY + s.lazy.send(@method, :with_index).first(100).should == + s.first(100).to_enum.send(@method, :with_index).to_a + end end |