mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make Array methods return Array instances instead of subclass instances
This changes the following methods to return Array instances instead of subclass instances: * Array#drop * Array#drop_while * Array#flatten * Array#slice! * Array#slice/#[] * Array#take * Array#take_while * Array#uniq * Array#* Fixes [Bug #6087]
This commit is contained in:
parent
7d6c72dc06
commit
2a294d499b
Notes:
git
2020-11-04 07:02:06 +09:00
Merged: https://github.com/ruby/ruby/pull/3690 Merged-By: jeremyevans <code@jeremyevans.net>
6 changed files with 171 additions and 95 deletions
|
@ -76,10 +76,20 @@ describe "Array#* with an integer" do
|
|||
@array = ArraySpecs::MyArray[1, 2, 3, 4, 5]
|
||||
end
|
||||
|
||||
it "returns a subclass instance" do
|
||||
(@array * 0).should be_an_instance_of(ArraySpecs::MyArray)
|
||||
(@array * 1).should be_an_instance_of(ArraySpecs::MyArray)
|
||||
(@array * 2).should be_an_instance_of(ArraySpecs::MyArray)
|
||||
ruby_version_is ''...'3.0' do
|
||||
it "returns a subclass instance" do
|
||||
(@array * 0).should be_an_instance_of(ArraySpecs::MyArray)
|
||||
(@array * 1).should be_an_instance_of(ArraySpecs::MyArray)
|
||||
(@array * 2).should be_an_instance_of(ArraySpecs::MyArray)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is '3.0' do
|
||||
it "returns an Array instance" do
|
||||
(@array * 0).should be_an_instance_of(Array)
|
||||
(@array * 1).should be_an_instance_of(Array)
|
||||
(@array * 2).should be_an_instance_of(Array)
|
||||
end
|
||||
end
|
||||
|
||||
it "does not call #initialize on the subclass instance" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue