Fixed failing KVO tests.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I
2010-02-12 13:46:26 -08:00
parent da84964a33
commit 3a35ab449b
5 changed files with 13 additions and 26 deletions
+6 -19
View File
@@ -83,16 +83,17 @@
+ (id)alloc
{
var a = [];
a.isa = self;
var array = [];
array.isa = self;
var ivars = class_copyIvarList(self),
count = ivars.length;
while (count--)
a[ivar_getName(ivars[count])] = nil;
array[ivar_getName(ivars[count])] = nil;
return a;
return array;
}
-(id)initWithKey:(id)aKey forProxyObject:(id)anObject
@@ -293,20 +294,6 @@
[self _setRepresentedObject:target];
}
- (CPArray)objectsAtIndexes:(CPIndexSet)indexes
{
var index = [indexes firstIndex],
objects = [];
while(index != CPNotFound)
{
[objects addObject:[self objectAtIndex:index]];
index = [indexes indexGreaterThanIndex:index];
}
return objects;
}
@end
+2 -2
View File
@@ -657,7 +657,7 @@
rhs = anArray[index];
// If they're not equal, and either doesn't have an isa, or they're !isEqual (not isEqual)
if (lhs !== rhs && (!lhs.isa || !rhs.isa || ![lhs isEqual:rhs]))
if (lhs !== rhs && (lhs && !lhs.isa || rhs && !rhs.isa || ![lhs isEqual:rhs]))
return NO;
}
@@ -816,7 +816,7 @@
if (index === 0)
description += '\n';
var object = self[index],
var object = [self objectAtIndex:index],
objectDescription = object && object.isa ? [object description] : object + "";
description += "\t" + objectDescription.split('\n').join("\n\t");
+3 -4
View File
@@ -236,7 +236,6 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
var kvoClass = objj_allocateClassPair(currentClass, kvoClassName);
objj_registerClassPair(kvoClass);
_class_initialize(kvoClass);
//copy in the methods from our model subclass
var methodList = _CPKVOModelSubclass.method_list,
@@ -422,8 +421,8 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
if (type == CPKeyValueChangeReplacement || type == CPKeyValueChangeInsertion)
{
//FIXME: do we need to go through and replace "" with CPNull?
var oldValues = [[_targetObject mutableArrayValueForKeyPath:aKey] objectsAtIndexes:indexes];
[changes setValue:oldValues forKey:CPKeyValueChangeNewKey];
var newValues = [[_targetObject mutableArrayValueForKeyPath:aKey] objectsAtIndexes:indexes];
[changes setValue:newValues forKey:CPKeyValueChangeNewKey];
}
}
else
@@ -436,7 +435,7 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld,
[changes setObject:newValue forKey:CPKeyValueChangeNewKey];
}
}
var observers = [_observersForKey[aKey] allValues],
count = observers ? observers.length : 0;
+1 -1
View File
@@ -570,7 +570,7 @@ exports.objj_lookUpClass = objj_lookUpClass;
exports.objj_getClass = objj_getClass;
exports.objj_getMetaClass = objj_getMetaClass;
exports.ivar_getName = ivar_getTypeEncoding;
exports.ivar_getName = ivar_getName;
exports.ivar_getTypeEncoding = ivar_getTypeEncoding;
exports.objj_msgSend = objj_msgSend;
+1
View File
@@ -585,6 +585,7 @@
[self assertTrue: type == CPKeyValueChangeInsertion message: "Should have been an insertion, was: "+type];
var values = [changes objectForKey:CPKeyValueChangeNewKey];
[self assertTrue: [values isEqual:[5]] message: "array should have contained 5, was: "+values+" type: "+[values.isa description]+" length: "+values.length];
[self assert:aKeyPath equals:"tester.subviews"];