diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-10-16 14:07:29 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-10-16 14:07:29 +0000 |
commit | 5b7cd330631768b3904137db17104127eca9a9bf (patch) | |
tree | b8ab200e1b38517d17e416c80029508c2488e1ca /gcc | |
parent | 1cde73d75d94428876d2924763acd292b2f4b632 (diff) | |
download | gcc-5b7cd330631768b3904137db17104127eca9a9bf.zip gcc-5b7cd330631768b3904137db17104127eca9a9bf.tar.gz gcc-5b7cd330631768b3904137db17104127eca9a9bf.tar.bz2 |
In gcc/testsuite/: 2010-10-16 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/testsuite/:
2010-10-16 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/gnu-api-2-ivar.m: New.
From-SVN: r165543
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/gnu-api-2-ivar.m | 80 |
2 files changed, 84 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2556f00..4a3aa42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-10-16 Nicola Pero <nicola.pero@meta-innovation.com> + + * objc.dg/gnu-api-2-ivar.m: New. + 2010-10-15 Nicola Pero <nicola.pero@meta-innovation.com> * objc.dg/gnu-api-2-property.m: New. diff --git a/gcc/testsuite/objc.dg/gnu-api-2-ivar.m b/gcc/testsuite/objc.dg/gnu-api-2-ivar.m new file mode 100644 index 0000000..914a439 --- /dev/null +++ b/gcc/testsuite/objc.dg/gnu-api-2-ivar.m @@ -0,0 +1,80 @@ +/* Test the Modern GNU Objective-C Runtime API. + + This is test 'ivar', covering all functions starting with 'ivar'. */ + +/* { dg-do run } */ +/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ + +/* To get the modern GNU Objective-C Runtime API, you include + objc/runtime.h. */ +#include <objc/runtime.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +@interface MyRootClass +{ Class isa; } ++ alloc; +- init; +@end + +@implementation MyRootClass ++ alloc { return class_createInstance (self, 0); } +- init { return self; } +@end + +@protocol MyProtocol +- (id) variable; +@end + +@protocol MySecondProtocol +- (id) setVariable: (id)value; +@end + +@interface MySubClass : MyRootClass <MyProtocol> +{ id variable_ivar; } +- (void) setVariable: (id)value; +- (id) variable; +@end + +@implementation MySubClass +- (void) setVariable: (id)value { variable_ivar = value; } +- (id) variable { return variable_ivar; } +@end + + +int main(int argc, void **args) +{ + /* Functions are tested in alphabetical order. */ + + printf ("Testing ivar_getName () ...\n"); + { + Ivar ivar = class_getInstanceVariable (objc_getClass ("MySubClass"), + "variable_ivar"); + if (strcmp (ivar_getName (ivar), "variable_ivar") != 0) + abort (); + + ivar = class_getInstanceVariable (objc_getClass ("MySubClass"), + "variable"); + if (ivar != 0) + abort (); + } + + printf ("Testing ivar_getOffset () ...\n"); + { + Ivar ivar = class_getInstanceVariable (objc_getClass ("MyRootClass"), + "isa"); + if (ivar_getOffset (ivar) != 0) + abort (); + } + + printf ("Testing ivar_getTypeEncoding () ...\n"); + { + Ivar ivar = class_getInstanceVariable (objc_getClass ("MySubClass"), + "variable_ivar"); + if (strcmp (ivar_getTypeEncoding (ivar), "@") != 0) + abort (); + } + + return 0; +} |