3 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
4 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
5 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
6 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
7 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
8 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
9 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
10 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
11 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
12 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
13 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
14 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
15 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
16 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
17 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
18 .*exchangeImp.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'checkExchange')?
24 #include <objc/runtime.h>
33 @interface Super : TestRoot @end
35 +(void) one { state = ONE; }
36 +(void) two { state = TWO; }
37 +(void) length { state = LENGTH; }
38 +(void) count { state = COUNT; }
41 #define checkExchange(s1, v1, s2, v2) \
45 testprintf("Check unexchanged version\n"); \
48 testassert(state == v1); \
51 testassert(state == v2); \
53 testprintf("Exchange\n"); \
54 m1 = class_getClassMethod([Super class], @selector(s1)); \
55 m2 = class_getClassMethod([Super class], @selector(s2)); \
58 method_exchangeImplementations(m1, m2); \
60 testprintf("Check exchanged version\n"); \
63 testassert(state == v2); \
66 testassert(state == v1); \
68 testprintf("NULL should do nothing\n"); \
69 method_exchangeImplementations(m1, NULL); \
70 method_exchangeImplementations(NULL, m2); \
71 method_exchangeImplementations(NULL, NULL); \
73 testprintf("Make sure NULL did nothing\n"); \
76 testassert(state == v2); \
79 testassert(state == v1); \
81 testprintf("Put them back\n"); \
82 method_exchangeImplementations(m1, m2); \
84 testprintf("Check restored version\n"); \
87 testassert(state == v1); \
90 testassert(state == v2); \
95 // Check ordinary selectors
96 checkExchange(one, ONE, two, TWO);
98 // Check vtable selectors
99 checkExchange(length, LENGTH, count, COUNT);
101 // Check ordinary<->vtable and vtable<->ordinary
102 checkExchange(count, COUNT, one, ONE);
103 checkExchange(two, TWO, length, LENGTH);