diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaObjC/property-13.m | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaObjC/property-13.m')
-rw-r--r-- | clang/test/SemaObjC/property-13.m | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/property-13.m b/clang/test/SemaObjC/property-13.m new file mode 100644 index 0000000..2ca3416 --- /dev/null +++ b/clang/test/SemaObjC/property-13.m @@ -0,0 +1,78 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code + +@interface NSObject ++ alloc; +- init; +@end + +@protocol Test + @property int required; + +@optional + @property int optional; + @property int optional1; + @property int optional_preexisting_setter_getter; + @property (setter = setOptional_preexisting_setter_getter: , + getter = optional_preexisting_setter_getter) int optional_with_setter_getter_attr; +@required + @property int required1; +@optional + @property int optional_to_be_defined; + @property (readonly, getter = optional_preexisting_setter_getter) int optional_getter_attr; +@end + +@interface Test : NSObject <Test> { + int ivar; + int ivar1; + int ivar2; +} +@property int required; +@property int optional_to_be_defined; +- (int) optional_preexisting_setter_getter; +- (void) setOptional_preexisting_setter_getter:(int)value; +@end + +@implementation Test +@synthesize required = ivar; +@synthesize required1 = ivar1; +@synthesize optional_to_be_defined = ivar2; +- (int) optional_preexisting_setter_getter { return ivar; } +- (void) setOptional_preexisting_setter_getter:(int)value + { + ivar = value; + } +- (void) setOptional_getter_attr:(int)value { ivar = value; } +@end + +void abort(void); +int main () +{ + Test *x = [[Test alloc] init]; + /* 1. Test of a required property */ + x.required1 = 100; + if (x.required1 != 100) + abort (); + + /* 2. Test of a synthesize optional property */ + x.optional_to_be_defined = 123; + if (x.optional_to_be_defined != 123) + abort (); + + /* 3. Test of optional property with pre-sxisting defined setter/getter */ + x.optional_preexisting_setter_getter = 200; + if (x.optional_preexisting_setter_getter != 200) + abort (); + + /* 4. Test of optional property with setter/getter attribute */ + if (x.optional_with_setter_getter_attr != 200) + abort (); + return 0; + + /* 5. Test of optional property with getter attribute and default setter method. */ + x.optional_getter_attr = 1000; + if (x.optional_getter_attr != 1000) + abort (); + + return 0; +} + |