| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:observe/observe.dart'; | 6 import 'package:observe/observe.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'observe_test_utils.dart'; | 8 import 'observe_test_utils.dart'; |
| 9 | 9 |
| 10 // This file contains code ported from: | 10 // This file contains code ported from: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 // apply deltas to the copy | 70 // apply deltas to the copy |
| 71 for (var delta in summary) { | 71 for (var delta in summary) { |
| 72 copy.removeRange(delta.index, delta.index + delta.removedCount); | 72 copy.removeRange(delta.index, delta.index + delta.removedCount); |
| 73 for (int i = delta.addedCount - 1; i >= 0; i--) { | 73 for (int i = delta.addedCount - 1; i >= 0; i--) { |
| 74 copy.insert(delta.index, model[delta.index + i]); | 74 copy.insert(delta.index, model[delta.index + i]); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Note: compare strings for easier debugging. | 78 // Note: compare strings for easier debugging. |
| 79 expect('$copy', '$model', reason: '!!! summary $summary'); | 79 expect('$copy', '$model', reason: 'summary $summary'); |
| 80 } | 80 } |
| 81 | 81 |
| 82 observeTest('Contained', () { | 82 observeTest('Contained', () { |
| 83 var model = toObservable(['a', 'b']); | 83 var model = toObservable(['a', 'b']); |
| 84 var copy = model.toList(); | 84 var copy = model.toList(); |
| 85 observeArray(model); | 85 observeArray(model); |
| 86 | 86 |
| 87 model.removeAt(1); | 87 model.removeAt(1); |
| 88 model.insertAll(0, ['c', 'd', 'e']); | 88 model.insertAll(0, ['c', 'd', 'e']); |
| 89 model.removeRange(1, 3); | 89 model.removeRange(1, 3); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 model.insert(0, 5); | 285 model.insert(0, 5); |
| 286 model[2] = 6; | 286 model[2] = 6; |
| 287 model.add(7); | 287 model.add(7); |
| 288 assertEditDistance(model, 4); | 288 assertEditDistance(model, 4); |
| 289 }); | 289 }); |
| 290 }); | 290 }); |
| 291 } | 291 } |
| 292 | 292 |
| 293 _delta(i, r, a) => new ListChangeRecord(i, removedCount: r, addedCount: a); | 293 _delta(i, r, a) => new ListChangeRecord(i, removedCount: r, addedCount: a); |
| 294 _filter(records) => records.where((r) => r is ListChangeRecord).toList(); | 294 _filter(records) => records.where((r) => r is ListChangeRecord).toList(); |
| OLD | NEW |