From 108d4e19c0ed5443419279ab9998bc93da7d3f19 Mon Sep 17 00:00:00 2001 From: Rupert Daniel Date: Thu, 3 Oct 2019 11:51:11 +0100 Subject: [PATCH] Updated BlockImpTest asserts. Fixes #126 assert now directly compares block self with expected class, avoiding objc_msgSend. --- Test/BlockImpTest.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Test/BlockImpTest.m b/Test/BlockImpTest.m index 4ccd05b..aa07499 100644 --- a/Test/BlockImpTest.m +++ b/Test/BlockImpTest.m @@ -24,9 +24,10 @@ __attribute__((objc_root_class)) int main(void) { + __block Class cls = objc_getClass("Foo"); __block int b = 0; void* blk = ^(id self, int a) { - assert([self class] == [Foo class]); + assert(self == cls); b += a; return b; }; blk = Block_copy(blk); @@ -34,7 +35,6 @@ int main(void) char *type = block_copyIMPTypeEncoding_np(blk); assert(NULL != type); class_addMethod((objc_getMetaClass("Foo")), @selector(count:), imp, type); - Class cls = objc_getClass("Foo"); assert(2 == ((int(*)(id,SEL,int))imp)(cls, @selector(count:), 2)); free(type); assert(4 == [Foo count: 2]); @@ -46,7 +46,7 @@ int main(void) assert(imp_getBlock(imp) != (blk)); blk = ^(id self) { - assert([self class] == [Foo class]); + assert(self == cls); struct big b = {1, 2, 3, 4, 5}; return b; };