Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Enumerable#compact and Enumerator::Lazy#compact #933

Merged
merged 2 commits into from
Jul 19, 2022
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
11 changes: 11 additions & 0 deletions core/enumerable/compact_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is '3.1' do
describe "Enumerable#compact" do
it 'returns array without nil elements' do
arr = EnumerableSpecs::Numerous.new(nil, 1, 2, nil, true)
arr.compact.should == [1, 2, true]
end
end
end
14 changes: 14 additions & 0 deletions core/enumerator/lazy/lazy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
]
lazy_methods += [:chunk_while, :uniq]

ruby_version_is '3.1' do
lazy_methods += [:compact]
end

Enumerator::Lazy.instance_methods(false).should include(*lazy_methods)
end
end
Expand All @@ -26,3 +30,13 @@
lazy.lazy.should equal(lazy)
end
end

ruby_version_is '3.1' do
describe "Enumerator::Lazy#compact" do
it 'returns array without nil elements' do
arr = [1, nil, 3, false, 5].to_enum.lazy.compact
arr.should be_an_instance_of(Enumerator::Lazy)
arr.force.should == [1, 3, false, 5]
end
end
end