./:
[official-gcc.git] / gcc / testsuite / objc / execute / formal_protocol-3.m
blob9fc2a768ded1738b512094bbfab9f99f81bde154
1 /* Contributed by Nicola Pero - Fri Mar  9 21:35:47 CET 2001 */
2 #include <objc/objc.h>
3 #include <objc/Object.h>
5 /* Test defining two protocol, a class adopting both of them, 
6    and using an object of type `id <Protocol1, Protocol2>' */ 
8 @protocol Enabling
9 - (BOOL) isEnabled;
10 - (void) setEnabled: (BOOL)flag;
11 @end
13 @protocol Evaluating
14 - (int) importance;
15 @end
17 @interface Feature : Object <Enabling, Evaluating>
19   const char *name;
20   BOOL isEnabled;
22 @end
24 @implementation Feature
25 - (BOOL) isEnabled
27   return isEnabled;
29 - (void) setEnabled: (BOOL)flag
31   isEnabled = flag;
33 - (int) importance
35   return 1000;
37 @end
39 int main (void)
41   id <Enabling, Evaluating> object;
43   object = [Feature new];
45   [object setEnabled: YES];
46   if (![object isEnabled])
47     {
48       abort ();
49     }
51   if ([object importance] != 1000)
52     {
53       abort ();
54     }
56   return 0;