Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

On 1.8.7, Array#delete returns the argument

The return value is the argument, even when it is not an element of
the array.
  • Loading branch information...
commit be8dbfc03acb8b233a4f5e1dd46e3847f48edece 1 parent 8730666
@BanzaiMan BanzaiMan authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 core/array/delete_spec.rb
View
14 core/array/delete_spec.rb
@@ -14,6 +14,20 @@ def x.==(other) 3 == other end
a.should == [1, 2, 4, 5]
end
+ ruby_version_is '1.8.7' do
+ it "returns the argument" do
+ x = mock('delete')
+ y = mock('delete_more')
+ def x.==(other) 3 == other end
+ def y.==(other) 3 == other end
+
+ a = [1, 2, 3, 4, 3, 5, x]
+
+ ret = a.delete y
+ ret.should equal(y)
+ end
+ end
+
ruby_version_is '1.9' ... '2.0' do
it "returns the last element in the array for which object is equal under #==" do
x = mock('delete')

5 comments on commit be8dbfc

@unak

on ruby 1.9, Array#delete returns the last deleted item. so this spec is wrong about 1.9 or later. please fix.

@BanzaiMan

@unak 1.9 and later are dealt with in the subsequent block, committed in cc976da and 8730666.

@dbussink

I think the problem comes from that the ruby_version_is matcher specifies a version and newer. So ruby_version_is '1.8.7' will also match 1.9. You probably need ruby_version_is '1.8.7'...'1.9' as the guard.

@unak

dbussink is right. BanzaiMan, you should check RubyCI, I think.

@BanzaiMan

Ah, OK. I will do that. Thank you for pointing this out. ad588bb

Please sign in to comment.
Something went wrong with that request. Please try again.