[K/N][Tests] Migrate objcSmoke & objcTests tests
^KT-61259
This commit is contained in:
committed by
Space Team
parent
58f7dd1c83
commit
524f0d335e
@@ -0,0 +1,36 @@
|
||||
#import "kt42482.h"
|
||||
#import "assert.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
BOOL kt42482Deallocated = NO;
|
||||
id kt42482Global = nil;
|
||||
|
||||
@implementation KT42482
|
||||
-(int)fortyTwo {
|
||||
return 41;
|
||||
}
|
||||
|
||||
-(void)dealloc {
|
||||
kt42482Deallocated = YES;
|
||||
}
|
||||
@end
|
||||
|
||||
int fortyTwoSwizzledImp(id self, SEL _cmd) {
|
||||
return 43;
|
||||
}
|
||||
|
||||
void kt42482Swizzle(id obj) {
|
||||
Class oldClass = object_getClass(obj);
|
||||
|
||||
SEL selector = @selector(fortyTwo);
|
||||
|
||||
Class newClass = objc_allocateClassPair(oldClass, "KT42482Swizzled", 0);
|
||||
assert(newClass != nil);
|
||||
objc_registerClassPair(newClass);
|
||||
|
||||
Method method = class_getInstanceMethod([KT42482 class], selector);
|
||||
assert(method != nil);
|
||||
class_addMethod(newClass, selector, (IMP)&fortyTwoSwizzledImp, method_getTypeEncoding(method));
|
||||
|
||||
object_setClass(obj, newClass);
|
||||
}
|
||||
Reference in New Issue
Block a user