2 #include <objc/runtime.h>
5 #include "cacheflush.h"
7 @interface Sub : Super @end
8 @implementation Sub @end
15 buf[0] = (uintptr_t)[Super class];
16 buf2[0] = (uintptr_t)[Sub class];
19 testassert(1 == [Super classMethod]);
20 testassert(1 == [(Super *)buf instanceMethod]);
21 testassert(1 == [Super classMethod]);
22 testassert(1 == [(Super *)buf instanceMethod]);
24 testassert(1 == [Sub classMethod]);
25 testassert(1 == [(Sub *)buf2 instanceMethod]);
26 testassert(1 == [Sub classMethod]);
27 testassert(1 == [(Sub *)buf2 instanceMethod]);
29 // Dynamically load a category
30 dlopen("cacheflush2.out", 0);
32 // Make sure old cache results are gone
33 testassert(2 == [Super classMethod]);
34 testassert(2 == [(Super *)buf instanceMethod]);
36 testassert(2 == [Sub classMethod]);
37 testassert(2 == [(Sub *)buf2 instanceMethod]);
39 // Dynamically load another category
40 dlopen("cacheflush3.out", 0);
42 // Make sure old cache results are gone
43 testassert(3 == [Super classMethod]);
44 testassert(3 == [(Super *)buf instanceMethod]);
46 testassert(3 == [Sub classMethod]);
47 testassert(3 == [(Sub *)buf2 instanceMethod]);
49 // fixme test subclasses
51 // fixme test objc_flush_caches(), class_addMethod(), class_addMethods()