mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Add a test case for notifications using dynamic lookup. Currently passes on OS
X, fails on GNUstep. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36605 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3a6d8a9bc9
commit
6ca63cef45
1 changed files with 27 additions and 0 deletions
27
Tests/base/NSNotification/dynamic.m
Normal file
27
Tests/base/NSNotification/dynamic.m
Normal file
|
@ -0,0 +1,27 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#include <objc/runtime.h>
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
@interface Toggle : NSObject @end
|
||||
@implementation Toggle
|
||||
- (void)foo: (NSNotification*)n
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
- (void)bar: (NSNotification*)n {}
|
||||
@end
|
||||
|
||||
int main(void)
|
||||
{
|
||||
[NSAutoreleasePool new];
|
||||
NSNotificationCenter *nc = [NSNotificationCenter new];
|
||||
id t = [Toggle new];
|
||||
[nc addObserver: t selector: @selector(foo:) name: nil object: nil];
|
||||
class_replaceMethod([Toggle class],
|
||||
@selector(foo:),
|
||||
class_getMethodImplementation([Toggle class],
|
||||
@selector(bar:)),
|
||||
"v@:@");
|
||||
[nc postNotificationName: @"foo" object: t];
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue