Merge pull request #3273 from enquora/add-property-copy-test

Add test for @accessors(copy)
This commit is contained in:
David Richardson authored and GitHub committed 2026-08-13 16:51:51 -06:00
commit 907ff374e6
1 file changed
+48
+48
View File
@@ -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