mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-26 21:47:04 +00:00
Fixed a few bugs in CPArray and added many new tests for CPArray.
Reviewed by me.
This commit is contained in:
@@ -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