3 $C{COMPILE} $DIR/cacheflush0.m -o cacheflush0.dylib -dynamiclib
4 $C{COMPILE} $DIR/cacheflush2.m -x none cacheflush0.dylib -o cacheflush2.dylib -dynamiclib
5 $C{COMPILE} $DIR/cacheflush3.m -x none cacheflush0.dylib -o cacheflush3.dylib -dynamiclib
6 $C{COMPILE} $DIR/cacheflush.m -x none cacheflush0.dylib -o cacheflush.out
11 #include <objc/runtime.h>
14 #include "cacheflush.h"
16 @interface Sub : TestRoot @end
17 @implementation Sub @end
22 TestRoot *sup = [TestRoot new];
26 testassert(1 == [TestRoot classMethod]);
27 testassert(1 == [sup instanceMethod]);
28 testassert(1 == [TestRoot classMethod]);
29 testassert(1 == [sup instanceMethod]);
31 testassert(1 == [Sub classMethod]);
32 testassert(1 == [sub instanceMethod]);
33 testassert(1 == [Sub classMethod]);
34 testassert(1 == [sub instanceMethod]);
36 // Dynamically load a category
37 dlopen("cacheflush2.dylib", 0);
39 // Make sure old cache results are gone
40 testassert(2 == [TestRoot classMethod]);
41 testassert(2 == [sup instanceMethod]);
43 testassert(2 == [Sub classMethod]);
44 testassert(2 == [sub instanceMethod]);
46 // Dynamically load another category
47 dlopen("cacheflush3.dylib", 0);
49 // Make sure old cache results are gone
50 testassert(3 == [TestRoot classMethod]);
51 testassert(3 == [sup instanceMethod]);
53 testassert(3 == [Sub classMethod]);
54 testassert(3 == [sub instanceMethod]);
56 // fixme test subclasses
58 // fixme test objc_flush_caches(), class_addMethod(), class_addMethods()