mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-07 17:38:02 +00:00
Merge pull request #3273 from enquora/add-property-copy-test
Add test for @accessors(copy)
This commit is contained in:
1 file changed
+48
@@ -0,0 +1,48 @@
|
||||
@import <Foundation/Foundation.j>
|
||||
|
||||
@implementation CopyAccessorTestClass : CPObject
|
||||
{
|
||||
CPMutableArray ivar @accessors(copy);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CopyAccessorTest : OJTestCase
|
||||
{
|
||||
CopyAccessorTestClass testClass;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
testClass = [[CopyAccessorTestClass alloc] init];
|
||||
}
|
||||
|
||||
- (void)testCopyAccessorStoresDistinctObject
|
||||
{
|
||||
var original = [@"a", @"b"];
|
||||
|
||||
[testClass setIvar:original];
|
||||
|
||||
[self assertFalse:[testClass ivar] === original];
|
||||
}
|
||||
|
||||
- (void)testCopyAccessorIsUnaffectedByLaterMutation
|
||||
{
|
||||
var original = [@"a", @"b"];
|
||||
|
||||
[testClass setIvar:original];
|
||||
[original addObject:@"c"];
|
||||
|
||||
[self assert:2 equals:[[testClass ivar] count]];
|
||||
}
|
||||
|
||||
- (void)testCopyAccessorPreservesContentAtAssignment
|
||||
{
|
||||
var original = [@"a", @"b"];
|
||||
|
||||
[testClass setIvar:original];
|
||||
|
||||
[self assert:original equals:[testClass ivar]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user