Get new test to run with older compilers.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35107 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2012-04-23 20:19:36 +00:00
parent 47969b4af6
commit 3e8e98b4b2
2 changed files with 35 additions and 29 deletions

View file

@ -1,10 +1,15 @@
2012-04-23 Fred Kiefer <FredKiefer@gmx.de>
* Tests/base/NSAutoreleasePool/autorelease_eh.m:
Get new test to run with older compilers.
2012-04-23 12:47 theraven
* libs/base/trunk/Source/NSAutoreleasePool.m,
libs/base/trunk/Tests/base/NSAutoreleasePool/autorelease_eh.m:
Fix a bug in the new autorelease pool implementation when pools
are destroyed in the wrong order.
Test cast by Chris Armstrong!
2012-04-22 Riccardo Mottola <rm@gnu.org>
@ -26,7 +31,7 @@
2012-04-16 Richard Frith-Macdonald <rfm@gnu.org>
* configure.ac: Add tests for lossy conversion using iconv and
* configure.ac: Add tests for lossy conversion using iconv and
provide options to disable use of iconv or allow use of iconv
where //TRANSLIT is missing.
* configure: regenerate.

View file

@ -1,6 +1,7 @@
#import "ObjectTesting.h"
#import <Foundation/Foundation.h>
#import <Foundation/NSException.h>
@interface TestClass : NSObject
- (void)runTest;
- (void)exceptionThrowingMethod;
@ -10,40 +11,40 @@
@implementation TestClass
- (void)runTest
{
int c = 0;
for (int i=0; i < 10; i++)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int c = 0;
int i;
@try
{
[self exceptionThrowingMethod];
}
@catch (NSException *e)
{
c++;
}
[pool release];
}
PASS(c == 10, "Caught the correct number of exceptions without breaking the autorelease pool\n");
for (i = 0; i < 10; i++)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NS_DURING
[self exceptionThrowingMethod];
NS_HANDLER
c++;
NS_ENDHANDLER
[pool release];
}
PASS(c == 10, "Caught the correct number of exceptions without breaking the autorelease pool\n");
}
- (void)exceptionThrowingMethod
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[@"Hello" stringByAppendingString: @" something to create a autoreleased object"];
NSLog(@"Throwing an exception");
@throw [NSException exceptionWithName: @"MyFunException" reason: @"it was always meant to happen" userInfo: [NSDictionary dictionary]];
[pool release]; // Obviously this doesn't get run, but the [NSAutorelease new] at the top causes the problem
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[@"Hello" stringByAppendingString: @" something to create a autoreleased object"];
NSLog(@"Throwing an exception");
@throw [NSException exceptionWithName: @"MyFunException" reason: @"it was always meant to happen" userInfo: [NSDictionary dictionary]];
[pool release]; // Obviously this doesn't get run, but the [NSAutorelease new] at the top causes the problem
}
@end
int main(int argc, char** argv)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
TestClass *testClass = [[TestClass new] autorelease];
[testClass runTest];
[pool release];
PASS(1, "Destroying pools in the wrong order didn't break anything...");
return 0;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
TestClass *testClass = [[TestClass new] autorelease];
[testClass runTest];
[pool release];
PASS(1, "Destroying pools in the wrong order didn't break anything...");
return 0;
}