From 7f7571a2d1d4876b3a572a14d50a881c504f3a12 Mon Sep 17 00:00:00 2001 From: Derek Hammer Date: Mon, 6 Sep 2010 11:44:27 -0500 Subject: [PATCH] Adding tests to verify the behavior of CPDictionary when subclassed. --- .../Foundation/CPSubclassableDictionaryTest.j | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Tests/Foundation/CPSubclassableDictionaryTest.j diff --git a/Tests/Foundation/CPSubclassableDictionaryTest.j b/Tests/Foundation/CPSubclassableDictionaryTest.j new file mode 100644 index 000000000..bc410b858 --- /dev/null +++ b/Tests/Foundation/CPSubclassableDictionaryTest.j @@ -0,0 +1,62 @@ +@import + +@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 \ No newline at end of file