mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-28 06:27:02 +00:00
Merge remote branch 'hammerdr/subclassable'
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
@import <Foundation/CPDictionary.j>
|
||||
|
||||
@implementation MyDict : CPDictionary
|
||||
{
|
||||
int a;
|
||||
}
|
||||
|
||||
+ (id)alloc
|
||||
{
|
||||
return class_createInstance(self);
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if(self)
|
||||
{
|
||||
_a = "Bob";
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPString)secondaryName
|
||||
{
|
||||
return "Saget";
|
||||
}
|
||||
|
||||
- (CPString)name
|
||||
{
|
||||
return _a;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TestSubclassableDictionary : OJTestCase
|
||||
|
||||
- (void)testThatMyDictContainsReplacedNameSelector
|
||||
{
|
||||
var target = [[MyDict alloc] init];
|
||||
[OJAssert assert:@"Bob" equals:[target name]];
|
||||
}
|
||||
|
||||
- (void)testThatMyDictDoesHaveNewSelector
|
||||
{
|
||||
var target = [[MyDict alloc] init];
|
||||
[OJAssert assert:@"Saget" equals:[target secondaryName]];
|
||||
}
|
||||
|
||||
- (void)testThatDictionaryDoesNotHaveReplacedName
|
||||
{
|
||||
var target = [[CPDictionary alloc] init];
|
||||
[OJAssert assert:@"Bob" notEqual:[target name]];
|
||||
}
|
||||
|
||||
- (void)testThatTollFreeDoesNotHaveNewSelector
|
||||
{
|
||||
var target = {};
|
||||
[OJAssert assertThrows:function() { [target secondaryName]; }];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user