1/* 2TEST_BUILD 3 $C{COMPILE} $DIR/imageorder1.m -o imageorder1.dylib -dynamiclib 4 $C{COMPILE} $DIR/imageorder2.m -x none imageorder1.dylib -o imageorder2.dylib -dynamiclib 5 $C{COMPILE} $DIR/imageorder3.m -x none imageorder2.dylib imageorder1.dylib -o imageorder3.dylib -dynamiclib 6 $C{COMPILE} $DIR/imageorder.m -x none imageorder3.dylib imageorder2.dylib imageorder1.dylib -o imageorder.out 7END 8*/ 9 10#include "test.h" 11#include "imageorder.h" 12#include <objc/runtime.h> 13#include <dlfcn.h> 14 15int main() 16{ 17 // +load methods and C static initializers 18 testassert(state == 3); 19 testassert(cstate == 3); 20 21 Class cls = objc_getClass("Super"); 22 testassert(cls); 23 24 // make sure all categories arrived 25 state = -1; 26 [Super method0]; 27 testassert(state == 0); 28 [Super method1]; 29 testassert(state == 1); 30 [Super method2]; 31 testassert(state == 2); 32 [Super method3]; 33 testassert(state == 3); 34 35 // make sure imageorder3.dylib is the last category to attach 36 state = 0; 37 [Super method]; 38 testassert(state == 3); 39 40 succeed(__FILE__); 41} 42