mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-11 03:02:19 +00:00
Fixed a few bugs in CPArray and added many new tests for CPArray.
Reviewed by me.
This commit is contained in:
1 parent
2f86c0d9d2
commit
29301f440e
5 files changed
+736
-350
No files matched your search
@@ -2,7 +2,8 @@
|
||||
@import "CPMutableArray.j"
|
||||
|
||||
|
||||
var indexOf = Array.prototype.indexOf,
|
||||
var concat = Array.prototype.concat,
|
||||
indexOf = Array.prototype.indexOf,
|
||||
join = Array.prototype.join,
|
||||
pop = Array.prototype.pop,
|
||||
push = Array.prototype.push,
|
||||
@@ -172,6 +173,23 @@ var indexOf = Array.prototype.indexOf,
|
||||
objj_msgSend(self[index], aSelector);
|
||||
}
|
||||
|
||||
- (CPArray)arrayByAddingObject:(id)anObject
|
||||
{
|
||||
// concat flattens arrays, so wrap it in an *additional* array if anObject is an array itself.
|
||||
if ([anObject isKindOfClass:CPArray])
|
||||
return concat.call(self, [anObject]);
|
||||
|
||||
return concat.call(self, anObject);
|
||||
}
|
||||
|
||||
- (CPArray)arrayByAddingObjectsFromArray:(CPArray)anArray
|
||||
{
|
||||
if (!anArray)
|
||||
return [self copy];
|
||||
|
||||
return concat.call(self, anArray.isa === _CPJavaScriptArray ? anArray : [anArray _javaScriptArrayCopy]);
|
||||
}
|
||||
|
||||
- (CPArray)subarrayWithRange:(CPRange)aRange
|
||||
{
|
||||
if (aRange.location < 0 || CPMaxRange(aRange) > self.length)
|
||||
|
||||
Reference in new issue
Block a user