Jonathan Paisley
jp-ww****@dcs*****
Fri Mar 24 19:03:44 JST 2006
On 24 Mar 2006, at 9:48, kimura wataru wrote: > I wrote simple tests for [Rubycocoa-devel 195]. I cannnot decide > to use OCUnit and otest tests of Objective-C side. Since the tests are quite small, it's probably easiest to stick with wrapping in Test::Unit for now. However, I've not used OCUnit so I don't know much about it -- perhaps it is very easy too! A couple of comments (I've snipped the code to show the relevant lines): +- (BOOL) assertIDFromSameObjectWithInit + rbobj_a = rb_str_new2("test"); + ocobj_a = [[[RBObject alloc] initWithRubyObject:rbobj_a] autorelease]; + rbobj_b = rb_str_dup(rbobj_a); + ocobj_b = [[[RBObject alloc] initWithRubyObject:rbobj_b] autorelease]; + ret = (ocobj_a != ocobj_b) ? YES : NO; rbobj_a and rbobj_b are different Ruby objects, so perhaps the method should be called 'assertIDFromDifferentObjectWithInit'? +- (BOOL) assertIDFromOtherObject +{ + BOOL ret; + VALUE rbobj_a, rbobj_b; + id ocobj_a, ocobj_b; + id pool = [[NSAutoreleasePool alloc] init]; + + rbobj_a = rb_str_new2("test"); + ocobj_a = [RBObject RBObjectWithRubyObject:rbobj_a]; + ocobj_b = [RBObject RBObjectWithRubyObject:rbobj_b]; + ret = (ocobj_a != ocobj_b) ? YES : NO; rbobj_b is not initialized in this function. It seems that there should be two sets of tests: one that uses alloc/ init, the other uses the RBObjectWithRubyObject class method. For each set, there should be a test that ensures that the same RBObject is returned for the same VALUE, and the other should ensure that different RBObjects are returned for different VALUEs.