mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32723 72102866-910b-0410-8b05-ffd578937521
75 lines
1.4 KiB
Text
75 lines
1.4 KiB
Text
#import "Testing.h"
|
|
#import <Foundation/NSObject.h>
|
|
|
|
#if defined(TESTDEV)
|
|
|
|
#if !__has_feature(objc_nonfragile_abi)
|
|
int main(void)
|
|
{
|
|
START_SET("String throwing")
|
|
SKIP("Unified exception model not supported")
|
|
END_SET("String throwing");
|
|
return 0;
|
|
}
|
|
|
|
#else
|
|
|
|
/**
|
|
* Tests throwing an exception with the C++ exception throwing mechanism and
|
|
* catching it with the Objective-C exception handling mechanism. This
|
|
* behaviour is required for compatibility with Apple's new exception model.
|
|
* The converse should also work - throwing an object with @throw and catching
|
|
* it with catch().
|
|
*/
|
|
int main(void)
|
|
{
|
|
NSString *foo = @"foo";
|
|
id caught = nil;
|
|
int final = 0;
|
|
int wrongCatch = 0;
|
|
|
|
@try
|
|
{
|
|
throw foo;
|
|
}
|
|
@catch(NSString *f)
|
|
{
|
|
caught = f;
|
|
}
|
|
@finally
|
|
{
|
|
final = 1;
|
|
}
|
|
PASS(caught == foo, "Unified exception model works correctly");
|
|
PASS(1==final, "@finally works in ObjC++");
|
|
final = 0;
|
|
caught = nil;
|
|
try
|
|
{
|
|
@throw foo;
|
|
}
|
|
catch (NSArray *a)
|
|
{
|
|
wrongCatch = 1;
|
|
}
|
|
catch (NSString *f)
|
|
{
|
|
caught = f;
|
|
}
|
|
catch(...)
|
|
{
|
|
final = 1;
|
|
}
|
|
PASS(0==final, "catchall not used to catch object");
|
|
PASS(0==wrongCatch, "Incorrect object catch not used to catch object");
|
|
PASS(caught == foo, "Unified exception model works correctly");
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#else
|
|
int main(void)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|