Added tests for ensuring that blocks work as NSObject subclasses. I'm not sure if GNUstep Make is correctly adding -fblocks yet - if it isn't, you can run the test with:

CC=clang ADDITIONAL_OBJCFLAGS='-fblocks' gnustep-tests NSBlock

(I have -make configured to use GCC, and just override this explicitly when building, because doing it the other way around breaks building with GCC)



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32333 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2011-02-23 18:27:49 +00:00
parent 40a8c57b42
commit c461a9914b

View file

@ -0,0 +1,27 @@
#import "Testing.h"
#import <Foundation/Foundation.h>
int main (int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
#if __has_feature(blocks)
BOOL (^hello)(void) = ^() { return YES; };
PASS(hello(), "Calling a block");
BOOL (^helloCopy)(void) = Block_copy(hello);
Block_release(hello);
PASS(helloCopy(), "Calling a copy of a block");
NSArray *blockArr = [NSArray arrayWithObject:helloCopy];
PASS([blockArr count] == 1, "Block used as object in an array");
void (^helloArr)(void) = [blockArr objectAtIndex:0];
PASS(helloCopy(), "Block successfully retrived from array");
Block_release(helloCopy);
#elif defined(__clang__)
unsupported("Your compiler supports blocks, but this support was disabled for some reason.");
#else
unsupported("Your compiler does not support blocks.");
#endif
[pool drain];
return 0;
}