imageorder1.m 834 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "test.h"
  2. #include "imageorder.h"
  3. int state = -1;
  4. int cstate = 0;
  5. static void c1(void) __attribute__((constructor));
  6. static void c1(void)
  7. {
  8. testassert(state == 1); // +load before C/C++
  9. testassert(cstate == 0);
  10. cstate = 1;
  11. }
  12. #if __clang__
  13. #pragma clang diagnostic push
  14. #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
  15. #endif
  16. @implementation Super (cat1)
  17. +(void) method {
  18. fail("+[Super(cat1) method] not replaced!");
  19. }
  20. +(void) method1 {
  21. state = 1;
  22. }
  23. +(void) load {
  24. testassert(state == 0);
  25. state = 1;
  26. }
  27. @end
  28. #if __clang__
  29. #pragma clang diagnostic pop
  30. #endif
  31. @implementation Super
  32. +(void) initialize { }
  33. +(void) method {
  34. fail("+[Super method] not replaced!");
  35. }
  36. +(void) method0 {
  37. state = 0;
  38. }
  39. +(void) load {
  40. testassert(state == -1);
  41. state = 0;
  42. }
  43. @end