Index: tests/RuntimeTests.m ================================================================== --- tests/RuntimeTests.m +++ tests/RuntimeTests.m @@ -17,21 +17,29 @@ #include "config.h" #import "OFString.h" #import "OFAutoreleasePool.h" +#import "OFNotImplementedException.h" + #import "TestsAppDelegate.h" static OFString *module = @"Runtime"; + +@interface OFObject (SuperTest) +- (id)superTest; +@end @interface RuntimeTest: OFObject { OFString *_foo, *_bar; } @property (copy, nonatomic) OFString *foo; @property (retain) OFString *bar; + +- (id)nilSuperTest; @end @implementation RuntimeTest @synthesize foo = _foo; @synthesize bar = _bar; @@ -41,19 +49,39 @@ [_foo release]; [_bar release]; [super dealloc]; } + +- (id)superTest +{ + return [super superTest]; +} + +- (id)nilSuperTest +{ + self = nil; + + return [self superTest]; +} @end @implementation TestsAppDelegate (RuntimeTests) - (void)runtimeTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; RuntimeTest *rt = [[[RuntimeTest alloc] init] autorelease]; - OFString *t = [OFMutableString stringWithString: @"foo"]; - OFString *foo = @"foo"; + OFString *t, *foo; + + EXPECT_EXCEPTION(@"Calling a non-existant method via super", + OFNotImplementedException, [rt superTest]) + + TEST(@"Calling a method via a super with self == nil", + [rt nilSuperTest] == nil) + + t = [OFMutableString stringWithString: @"foo"]; + foo = @"foo"; [rt setFoo: t]; TEST(@"copy, nonatomic properties", [[rt foo] isEqual: foo] && [rt foo] != foo && [[rt foo] retainCount] == 1)