1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 /* This test is identical to load-category-2, but the classes and
6 categories are created in inverted order in the modules, to test
7 that you can load classes first, or categories first, and it all
8 still works in both cases. */
12 #include <objc/objc.h>
14 #include "load-category-3.h"
16 @implementation TestClass2 (Category)
19 printf ("[TestClass2(Category) +load]\n");
21 /* Check that the corresponding class's +load was done. */
22 check_that_load_step_was_completed (1);
24 complete_load_step (4);
28 @implementation TestClass3 (Category)
31 printf ("[TestClass3(Category) +load]\n");
33 /* Check that the corresponding class's +load was done. */
34 check_that_load_step_was_completed (2);
36 complete_load_step (5);
40 @implementation TestClass1 (Category)
43 printf ("[TestClass1(Category) +load]\n");
45 /* Check that the corresponding class's +load was done. */
46 check_that_load_step_was_completed (0);
48 complete_load_step (3);
52 static BOOL load_step_completed[6] = { NO, NO, NO, NO, NO, NO };
54 void complete_load_step (int load_step)
56 load_step_completed[load_step] = YES;
59 void check_that_load_step_was_completed (int load_step)
61 if (load_step_completed[load_step] == NO)
63 printf ("Load step %d was not completed but should have been\n", load_step);
68 void check_that_load_step_was_not_completed (int load_step)
70 if (load_step_completed[load_step] == YES)
72 printf ("Load step %d was completed but shouldn't have been\n", load_step);
79 check_that_load_step_was_completed (0);
80 check_that_load_step_was_completed (1);
81 check_that_load_step_was_completed (2);
82 check_that_load_step_was_completed (3);
83 check_that_load_step_was_completed (4);
84 check_that_load_step_was_completed (5);