From b9c524c391c7145f72c7ee29ca569de5d22e035d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Thu, 5 Dec 2013 16:02:16 +0100 Subject: [PATCH] Add failing tests for Ruby methods that should return retained objects. Related to http://hipbyte.myjetbrains.com/youtrack/issue/RM-343. --- test/test/spec/memory_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test/spec/memory_spec.rb b/test/test/spec/memory_spec.rb index 40195aad..a6a84890 100644 --- a/test/test/spec/memory_spec.rb +++ b/test/test/spec/memory_spec.rb @@ -257,6 +257,26 @@ describe "Objective-C methods that return retained objects" do end end +describe "Ruby methods that return retained objects" do + def newObject; Object.new; end + def newbuildObject; Object.new; end + + it "returns a retained object if the method name starts exactly with 'new'" do + lambda { newObject }.should.not.be.autoreleased + lambda { newbuildObject }.should.be.autoreleased + end + + def copyObject; Object.new; end + def objectCopy; Object.new; end + def copyingObject; Object.new; end + + it "returns a retained object if the method name contains 'copy'" do + lambda { copyObject }.should.not.be.autoreleased + lambda { objectCopy }.should.not.be.autoreleased + lambda { copyingObject }.should.be.autoreleased + end +end + class TestSetValueForKey attr_accessor :foo end