1 /* Test out '@catch(id foo) {...}', which should catch all uncaught
3 /* Developed by Ziemowit Laski <zlaski@apple.com>. */
5 #include <objc/Object.h>
8 /* The following is not required in actual user code; we include it
9 here to check that the compiler generates an internal definition of
10 _setjmp that is consistent with what <setjmp.h> provides. */
13 extern void abort(void);
14 #define CHECK_IF(expr) if(!(expr)) abort()
16 @interface Frob: Object
19 @implementation Frob: Object
22 static Frob* _connection = nil;
24 //--------------------------------------------------------------------
27 void test (Object* sendPort)
30 Frob* receivePort = nil;
33 printf ("receivePort = %p\n", receivePort);
34 printf ("sendPort = %p\n", sendPort);
35 printf ("cleanupPorts = %d\n", cleanupPorts);
38 receivePort = (Frob *) -1;
39 _connection = (Frob *) -1;
40 printf ("receivePort = %p\n", receivePort);
41 printf ("sendPort = %p\n", sendPort);
42 printf ("cleanupPorts = %d\n", cleanupPorts);
49 printf ("receivePort = %p\n", receivePort);
50 printf ("sendPort = %p\n", sendPort);
51 printf ("cleanupPorts = %d\n", cleanupPorts);
57 printf ("Exception caught by incorrect handler!\n");
61 printf ("Exception caught by correct handler.\n");
62 printf ("receivePort = %p (expected 0x0)\n", receivePort);
63 printf ("sendPort = %p (expected 0x0)\n", sendPort);
64 printf ("cleanupPorts = %d (expected 0)\n", cleanupPorts);
66 CHECK_IF(!receivePort);
68 CHECK_IF(!cleanupPorts);