Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #164 from BanzaiMan/array_delete

Array#delete should return the last equal element in the array.
  • Loading branch information...
commit 1cb0c9402122667ed2c83c98d23768fc1b64fec0 2 parents 28f5214 + be8dbfc
@brixen brixen authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 core/array/delete_spec.rb
View
28 core/array/delete_spec.rb
@@ -14,6 +14,34 @@ 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')
+ y = mock('delete_more')
+ def x.==(other) 3 == other end
+ def y.==(other) 3 == other end
+
+ a = [1, 2, 3, y, 4, 3, 5, x]
+
+ ret = a.delete 3
+ ret.should equal(x)
+ end
+ end
+
it "calculates equality correctly for reference values" do
a = ["foo", "bar", "foo", "quux", "foo"]
a.delete "foo"
Please sign in to comment.
Something went wrong with that request. Please try again.