[Rubycocoa-devel 1288] Added test for equality bug.

Back to archive index

Eloy Duran e.dur****@super*****
Sat Jan 19 11:26:43 JST 2008


Hi,

As discussed with Laurent I added a test for a bug,
which causes for instance the MailDemoSimple sample to not work, in  
rev. 2174.

The only way I was able to reproduce the problem was by creating a nib  
and instantiating an object there.
Then getting a reference to that object in 2 different ways and  
compare them (tc_uniqobj.rb):

     def  
test_equality_of_a_objc_object_that_has_been_instantiated_from_a_nib
       # A naive fix for equality.
       # OSX::NSObject.class_eval do
       #   def ==(other)
       #     __ocid__ == other.__ocid__
       #   end
       # end

       url = OSX::NSURL.fileURLWithPath(File.expand_path('../ 
TableView.nib', __FILE__))
       nib = OSX::NSNib.alloc.initWithContentsOfURL(url)
       owner = OSX::TableViewNibOwner.alloc.init
       res, outlets = nib.instantiateNibWithOwner_topLevelObjects(owner)

       # They are both the same objc objects but referenced in another  
way,
       # which seems to return different ruby proxy instances.
       tableView1 = outlets.select {|obj| obj.is_a?  
OSX::NSScrollView }.first
       tableView2 = owner.instance_variable_get(:@tableView)

       assert tableView1 == tableView2
       assert tableView1 === tableView2
       assert OSX::NSScrollView === tableView2
     end

Cheers,
Eloy




More information about the Rubycocoa-devel mailing list
Back to archive index