diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-12-24 17:00:19 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-12-24 17:00:19 +0000 |
commit | 5750872c618185a2f1161d24510ad2be8669338a (patch) | |
tree | ee1e4e206c47305a511d45251f60fad046dd3233 /gcc | |
parent | e66d38fe0510d448d35968205fdb79a6a1b2f675 (diff) | |
download | gcc-5750872c618185a2f1161d24510ad2be8669338a.zip gcc-5750872c618185a2f1161d24510ad2be8669338a.tar.gz gcc-5750872c618185a2f1161d24510ad2be8669338a.tar.bz2 |
In libobjc/: 2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com>
In libobjc/:
2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com>
* objc/runtime.h (sel_getType): Renamed to sel_getTypeEncoding to
be consistent with method_getTypeEncoding and
ivar_getTypeEncoding.
(sel_copyTypedSelectorList, sel_getTypedSelector): New.
* selector.c (sel_getType): Renamed to sel_getTypeEncoding.
(sel_copyTypedSelectorList, sel_getTypedSelector): New.
(sel_get_type): Updated call to sel_getType.
In gcc/testsuite/:
2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/gnu-api-2-sel.m: Updated for renaming of sel_getType to
sel_getTypeEncoding. Test that sel_getTypeEncoding returns NULL
when called with a NULL argument. Added test for
sel_copyTypedSelectorList and sel_getTypedSelector.
* obj-c++.dg/gnu-api-2-sel.mm: Same changes.
From-SVN: r168229
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm | 70 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/gnu-api-2-sel.m | 68 |
3 files changed, 139 insertions, 7 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 87bc46f..0140ced 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2010-12-24 Nicola Pero <nicola.pero@meta-innovation.com> + + * objc.dg/gnu-api-2-sel.m: Updated for renaming of sel_getType to + sel_getTypeEncoding. Test that sel_getTypeEncoding returns NULL + when called with a NULL argument. Added test for + sel_copyTypedSelectorList and sel_getTypedSelector. + * obj-c++.dg/gnu-api-2-sel.mm: Same changes. + 2010-12-24 Eric Botcazou <ebotcazou@adacore.com> * gnat.dg/opt13_pkg.ad[sb]: Fix line ending. diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm index 66cf072..956ba29 100644 --- a/gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm +++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm @@ -35,11 +35,13 @@ { id variable_ivar; } - (void) setVariable: (id)value; - (id) variable; +- (void) method; @end @implementation MySubClass - (void) setVariable: (id)value { variable_ivar = value; } - (id) variable { return variable_ivar; } +- (void) method { return; } @end @@ -47,6 +49,30 @@ int main () { /* Functions are tested in alphabetical order. */ + std::cout << "Testing sel_copyTypedSelectorList ()...\n"; + { + unsigned int count; + SEL * list = sel_copyTypedSelectorList ("method", &count); + + /* There should only be two, since 'method' is referenced twice, + once with types and once without (in this very test). */ + if (count != 2) + abort (); + + /* Check that both selectors are not-NULL, and have the correct + name. We use @selector() here, which wouldn't really be + needed, just to register a second, untyped selector with name + 'method'. */ + if (std::strcmp (sel_getName (list[0]), sel_getName (@selector (method))) != 0) + abort (); + + if (std::strcmp (sel_getName (list[1]), sel_getName (@selector (method))) != 0) + abort (); + + if (list[2] != NULL) + abort (); + } + std::cout << "Testing sel_getName () ...\n"; { if (std::strcmp (sel_getName (@selector (variable)), "variable") != 0) @@ -56,14 +82,50 @@ int main () abort (); } - std::cout << "Testing sel_getType () ...\n"; + std::cout << "Testing sel_getTypeEncoding () ...\n"; { /* Get a selector from a real class, so it has interesting types. */ Method method = class_getInstanceMethod (objc_getClass ("MySubClass"), @selector (variable)); - if (std::strcmp (sel_getType (method_getName (method)), method_getTypeEncoding (method)) != 0) + if (std::strcmp (sel_getTypeEncoding (method_getName (method)), + method_getTypeEncoding (method)) != 0) + abort (); + + if (sel_getTypeEncoding (NULL) != NULL) + abort (); + } + + std::cout << "Testing sel_getTypedSelector () ...\n"; + { + /* First try with a selector where we know that a typed one has + been registered. */ + SEL selector = sel_getTypedSelector ("variable"); + + if (selector == NULL) + abort (); + + if (sel_getTypeEncoding (selector) == NULL) + abort (); + + /* Now try a selector which was never registered. */ + selector = sel_getTypedSelector ("not_registered"); + + if (selector != NULL) + abort (); + + /* Now try registering a selector with no types. The following + line is just a way to have an unused '@selector()' expression + without the compiler complaining. */ + if (@selector (registered_with_no_types) == NULL) + abort (); + + /* Try getting it. Nothing should be returned because it is + untyped. */ + selector = sel_getTypedSelector ("registered_with_no_types"); + + if (selector != NULL) abort (); } @@ -91,11 +153,11 @@ int main () (objc_getClass ("MySubClass"), @selector (variable))); SEL selector = sel_registerTypedName ("aMethod", types); - + if (std::strcmp (sel_getName (selector), "aMethod") != 0) abort (); - if (std::strcmp (sel_getType (selector), types) != 0) + if (std::strcmp (sel_getTypeEncoding (selector), types) != 0) abort (); } diff --git a/gcc/testsuite/objc.dg/gnu-api-2-sel.m b/gcc/testsuite/objc.dg/gnu-api-2-sel.m index e710083..db2dcd3 100644 --- a/gcc/testsuite/objc.dg/gnu-api-2-sel.m +++ b/gcc/testsuite/objc.dg/gnu-api-2-sel.m @@ -35,11 +35,13 @@ { id variable_ivar; } - (void) setVariable: (id)value; - (id) variable; +- (void) method; @end @implementation MySubClass - (void) setVariable: (id)value { variable_ivar = value; } - (id) variable { return variable_ivar; } +- (void) method { return; } @end @@ -47,6 +49,30 @@ int main(int argc, void **args) { /* Functions are tested in alphabetical order. */ + printf ("Testing sel_copyTypedSelectorList ()...\n"); + { + unsigned int count; + SEL * list = sel_copyTypedSelectorList ("method", &count); + + /* There should only be two, since 'method' is referenced twice, + once with types and once without (in this very test). */ + if (count != 2) + abort (); + + /* Check that both selectors are not-NULL, and have the correct + name. We use @selector() here, which wouldn't really be + needed, just to register a second, untyped selector with name + 'method'. */ + if (strcmp (sel_getName (list[0]), sel_getName (@selector (method))) != 0) + abort (); + + if (strcmp (sel_getName (list[1]), sel_getName (@selector (method))) != 0) + abort (); + + if (list[2] != NULL) + abort (); + } + printf ("Testing sel_getName () ...\n"); { if (strcmp (sel_getName (@selector (variable)), "variable") != 0) @@ -56,14 +82,50 @@ int main(int argc, void **args) abort (); } - printf ("Testing sel_getType () ...\n"); + printf ("Testing sel_getTypeEncoding () ...\n"); { /* Get a selector from a real class, so it has interesting types. */ Method method = class_getInstanceMethod (objc_getClass ("MySubClass"), @selector (variable)); - if (strcmp (sel_getType (method_getName (method)), method_getTypeEncoding (method)) != 0) + if (strcmp (sel_getTypeEncoding (method_getName (method)), + method_getTypeEncoding (method)) != 0) + abort (); + + if (sel_getTypeEncoding (NULL) != NULL) + abort (); + } + + printf ("Testing sel_getTypedSelector () ...\n"); + { + /* First try with a selector where we know that a typed one has + been registered. */ + SEL selector = sel_getTypedSelector ("variable"); + + if (selector == NULL) + abort (); + + if (sel_getTypeEncoding (selector) == NULL) + abort (); + + /* Now try a selector which was never registered. */ + selector = sel_getTypedSelector ("not_registered"); + + if (selector != NULL) + abort (); + + /* Now try registering a selector with no types. The following + line is just a way to have an unused '@selector()' expression + without the compiler complaining. */ + if (@selector (registered_with_no_types) == NULL) + abort (); + + /* Try getting it. Nothing should be returned because it is + untyped. */ + selector = sel_getTypedSelector ("registered_with_no_types"); + + if (selector != NULL) abort (); } @@ -95,7 +157,7 @@ int main(int argc, void **args) if (strcmp (sel_getName (selector), "aMethod") != 0) abort (); - if (strcmp (sel_getType (selector), types) != 0) + if (strcmp (sel_getTypeEncoding (selector), types) != 0) abort (); } |