-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update a test to fail #14843 #15110
Update a test to fail #14843 #15110
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,17 +142,23 @@ export function arrayContentDidChange(array, startIdx, removeAmt, addAmt) { | |
let cache = meta && meta.readableCache(); | ||
|
||
if (cache) { | ||
let length = get(array, 'length') + removeAmt - addAmt; | ||
if (cache.firstObject !== undefined && | ||
objectAt(array, 0) !== cacheFor.get(cache, 'firstObject')) { | ||
((startIdx === 0 && (addAmt > 0 || removeAmt > 0)) || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we still include |
||
(startIdx <= -length && (addAmt > 0 || removeAmt > 0)))) { | ||
propertyWillChange(array, 'firstObject'); | ||
propertyDidChange(array, 'firstObject'); | ||
} | ||
|
||
if (cache.lastObject !== undefined && | ||
objectAt(array, get(array, 'length') - 1) !== cacheFor.get(cache, 'lastObject')) { | ||
((startIdx >= length && addAmt > 0) || | ||
(startIdx >= 0 && (startIdx + removeAmt >= length)) || | ||
(startIdx < 0 && (removeAmt >= -startIdx)))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we still include |
||
propertyWillChange(array, 'lastObject'); | ||
propertyDidChange(array, 'lastObject'); | ||
} | ||
} | ||
|
||
return array; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,11 +135,22 @@ suite.test('[A,B,C].insertAt(1,X) => [A,X,B,C] + notify', function() { | |
let after = [before[0], item, before[1], before[2]]; | ||
let obj = this.newObject(before); | ||
let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject'); | ||
let objectAtCalls = []; | ||
|
||
let objectAt = obj.objectAt; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we will require more test permutations, as the above code has many bounds |
||
obj.objectAt = (ix) => { | ||
objectAtCalls.push(ix); | ||
return objectAt.call(obj, ix); | ||
} | ||
|
||
obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */ | ||
|
||
objectAtCalls.splice(0, objectAtCalls.length); | ||
|
||
obj.insertAt(1, item); | ||
|
||
deepEqual(objectAtCalls, [], 'objectAt is not called when only inserting items'); | ||
|
||
deepEqual(this.toArray(obj), after, 'post item results'); | ||
equal(get(obj, 'length'), after.length, 'length'); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should likely avoid this
get
if we are not needing it.This is getting complicated, if we go down this path we should do a helper function that can be unit tested (and more readable).