@@ -271,6 +271,33 @@ void testWithGetterFactory(FieldGetterFactory getterFactory) {
271
271
removals: []));
272
272
});
273
273
274
+ it ('should support switching refs - gh 1158' , async (() {
275
+ var list = [0 ];
276
+
277
+ var record = detector.watch (list, null , null );
278
+ if (detector.collectChanges ().moveNext ()) {
279
+ detector.collectChanges ();
280
+ }
281
+
282
+ record.object = [1 , 0 ];
283
+ var iterator = detector.collectChanges ()..moveNext ();
284
+ expect (iterator.current.currentValue, toEqualCollectionRecord (
285
+ collection: ['1[null -> 0]' , '0[0 -> 1]' ],
286
+ previous: ['0[0 -> 1]' ],
287
+ additions: ['1[null -> 0]' ],
288
+ moves: ['0[0 -> 1]' ],
289
+ removals: []));
290
+
291
+ record.object = [2 , 1 , 0 ];
292
+ iterator = detector.collectChanges ()..moveNext ();
293
+ expect (iterator.current.currentValue, toEqualCollectionRecord (
294
+ collection: ['2[null -> 0]' , '1[null -> 1]' , '0[0 -> 2]' ],
295
+ previous: ['0[0 -> 2]' ],
296
+ additions: ['2[null -> 0]' , '1[null -> 1]' ],
297
+ moves: ['0[0 -> 2]' ],
298
+ removals: []));
299
+ }));
300
+
274
301
it ('should handle swapping elements correctly' , () {
275
302
var list = [1 , 2 ];
276
303
var record = detector.watch (list, null , null );
0 commit comments