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
This commit is contained in:
Nicola Pero 2010-10-16 14:07:29 +00:00 committed by Nicola Pero
parent 1cde73d75d
commit 5b7cd33063
2 changed files with 84 additions and 0 deletions

View file

@ -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.

View file

@ -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;
}