mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Added test that makes sure that void* doesn't catch id. Currently crashes on OS X, but is a known bug.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32666 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7d9c3baf64
commit
d54a3d44fb
1 changed files with 52 additions and 0 deletions
52
Tests/base/NSException/skipCatchall.mm
Normal file
52
Tests/base/NSException/skipCatchall.mm
Normal file
|
@ -0,0 +1,52 @@
|
|||
#import <ObjectTesting.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
#if !__has_feature(objc_nonfragile_abi)
|
||||
int main(void)
|
||||
{
|
||||
START_SET("Unified exception model")
|
||||
SKIP("Unified exception model not supported")
|
||||
END_SET("Unified exception model")
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Tests whether void* catches Objective-C objects thrown as exceptions.
|
||||
* According to John McCall at Apple, the correct behaviour is not to catch
|
||||
* them in void* (which makes sense - void* is effectively a restricted
|
||||
* catchall, and we don't want to be catching foreign exceptions there because
|
||||
* we don't know what to do with them). In fact, the current behaviour on OS X
|
||||
* (with g++, not tested with clang++) is not simply to not catch them, it is
|
||||
* also to crash with a segfault. Current behaviour with clang + libobjc2 is
|
||||
* to do the Right Thing™.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
NSString *foo = @"foo";
|
||||
id caught = nil;
|
||||
int final = 0;
|
||||
int wrongCatch = 0;
|
||||
try
|
||||
{
|
||||
@throw foo;
|
||||
}
|
||||
catch (void *foo)
|
||||
{
|
||||
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
|
Loading…
Reference in a new issue