Minimal reproducing test case. This creates a test number 47 in the unit
test suite, which fails with an exception. The exception reproduces the bug.main
parent
2542638b23
commit
44d05e58a6
@ -0,0 +1,16 @@
|
||||
#include "ModTest.h"
|
||||
|
||||
@interface MyException : Test {
|
||||
@private
|
||||
char *_name;
|
||||
char *_reason;
|
||||
}
|
||||
+ (void) raise: (char *)name
|
||||
format: (char *)reason;
|
||||
- (void) raise;
|
||||
- (char *)name;
|
||||
- (char *)reason;
|
||||
- (MyException *)initWithName:(char *)name
|
||||
reason:(char *)reason;
|
||||
|
||||
@end
|
||||
@ -0,0 +1,47 @@
|
||||
#import "MyException.h"
|
||||
|
||||
@implementation MyException
|
||||
|
||||
- (MyException *)initWithName:(char *)name
|
||||
reason:(char *)reason
|
||||
{
|
||||
if ((self = [super init]) != nil) {
|
||||
_name = name;
|
||||
_reason = reason;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (void) raise: (char *)name
|
||||
format: (char *)reason
|
||||
{
|
||||
MyException *e = [[[MyException alloc] initWithName:name
|
||||
reason:reason] autorelease];
|
||||
[e raise];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (_name) {
|
||||
free(_name);
|
||||
}
|
||||
if (_reason) {
|
||||
free(_reason);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) raise {
|
||||
@throw self;
|
||||
}
|
||||
|
||||
- (char*)name
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
- (char*)reason
|
||||
{
|
||||
return _reason;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -0,0 +1,17 @@
|
||||
#import "ModTest.h"
|
||||
|
||||
#import "minRepM.h"
|
||||
|
||||
#import "stdio.h"
|
||||
|
||||
int main (int iArgc, const char *iArgv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
MinRepM *mrm = [MinRepM new];
|
||||
printf("Poking\n");
|
||||
[mrm poke];
|
||||
printf("Poked\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
#import "ModTest.h"
|
||||
|
||||
#import "minRep2.h"
|
||||
|
||||
@interface MinRep1 : Test {
|
||||
}
|
||||
- (void)poke;
|
||||
|
||||
@end
|
||||
@ -0,0 +1,17 @@
|
||||
#import "ModTest.h"
|
||||
|
||||
#import "minRep1.h"
|
||||
|
||||
#import "stdio.h"
|
||||
|
||||
@implementation MinRep1
|
||||
|
||||
- (void)poke
|
||||
{
|
||||
MinRep2 *mr2 = [MinRep2 new];
|
||||
printf("Poking from minRep1\n");
|
||||
[mr2 poke];
|
||||
[mr2 release];
|
||||
}
|
||||
|
||||
@end
|
||||
@ -0,0 +1,6 @@
|
||||
#import "ModTest.h"
|
||||
|
||||
@interface MinRep2 : Test {
|
||||
}
|
||||
- (void)poke;
|
||||
@end
|
||||
@ -0,0 +1,24 @@
|
||||
#import "ModTest.h"
|
||||
|
||||
#import "minRep2.h"
|
||||
#import "MyException.h"
|
||||
|
||||
#import "stdio.h"
|
||||
|
||||
@implementation MinRep2
|
||||
|
||||
- (void)poke {
|
||||
@try {
|
||||
printf("Raising MyException\n");
|
||||
MyException *e = [MyException new];
|
||||
@throw e;
|
||||
} @catch (MyException *localException) {
|
||||
printf("Caught - re-raising\n");
|
||||
[localException retain];
|
||||
[[localException autorelease] raise];
|
||||
} @catch(...) {
|
||||
printf("Caught in general block\n");
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@ -0,0 +1,10 @@
|
||||
#import "ModTest.h"
|
||||
|
||||
#import "minRep1.h"
|
||||
|
||||
@interface MinRepM : Test {
|
||||
MinRep1 *_mr1;
|
||||
}
|
||||
- (void)poke;
|
||||
|
||||
@end;
|
||||
@ -0,0 +1,26 @@
|
||||
#import "ModTest.h"
|
||||
|
||||
#import "minRepM.h"
|
||||
#import "minRep1.h"
|
||||
|
||||
#import "MyException.h"
|
||||
|
||||
#import "stdio.h"
|
||||
|
||||
@implementation MinRepM
|
||||
|
||||
- (void)poke {
|
||||
_mr1 = [MinRep1 new];
|
||||
@try {
|
||||
printf("Poking from minRepM\n");
|
||||
if (_mr1) {
|
||||
[_mr1 poke];
|
||||
}
|
||||
printf("Poked from minRepM\n");
|
||||
} @catch (MyException *localException) {
|
||||
printf("In NS_HANDLER block, %s %s\n",
|
||||
[localException name], [localException reason]);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Reference in New Issue