| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 testObservableList() { | 5 testObservableList() { |
| 6 test('ObservableList', () { | 6 test('ObservableList', () { |
| 7 final arr = new ObservableList<int>(); | 7 final arr = new ObservableList<int>(); |
| 8 | 8 |
| 9 // Add some initial data before listening | 9 // Add some initial data before listening |
| 10 arr.add(1); | 10 arr.add(1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 bool called = false; | 29 bool called = false; |
| 30 EventBatch.wrap((e) { | 30 EventBatch.wrap((e) { |
| 31 expect(arr, hasLength(6)); | 31 expect(arr, hasLength(6)); |
| 32 expect(arr[0], equals(1)); | 32 expect(arr[0], equals(1)); |
| 33 // TODO(sigmund): why we need write startIndex? it should be optional. | 33 // TODO(sigmund): why we need write startIndex? it should be optional. |
| 34 expect(arr.indexOf(4, 0), equals(5)); | 34 expect(arr.indexOf(4, 0), equals(5)); |
| 35 expect(arr.indexOf(1, 0), equals(0)); | 35 expect(arr.indexOf(1, 0), equals(0)); |
| 36 expect(arr.indexOf(1, 1), equals(3)); | 36 expect(arr.indexOf(1, 1), equals(3)); |
| 37 // TODO(rnystrom): Get rid of second arg when lastIndexOf has default. | 37 // TODO(rnystrom): Get rid of second arg when lastIndexOf has default. |
| 38 expect(arr.lastIndexOf(1, arr.length - 1), equals(3)); | 38 expect(arr.lastIndexOf(1, arr.length - 1), equals(3)); |
| 39 expect(arr.last(), equals(4)); | 39 expect(arr.last, equals(4)); |
| 40 final copy = new List<int>(); | 40 final copy = new List<int>(); |
| 41 arr.forEach(f(i) { | 41 arr.forEach(f(i) { |
| 42 copy.add(i); | 42 copy.add(i); |
| 43 }); | 43 }); |
| 44 expect(copy, orderedEquals([1, 2, 3, 1, 3, 4])); | 44 expect(copy, orderedEquals([1, 2, 3, 1, 3, 4])); |
| 45 called = true; | 45 called = true; |
| 46 })(null); | 46 })(null); |
| 47 expect(called, isTrue); | 47 expect(called, isTrue); |
| 48 expect(res, isNull); // no change from read-only operators | 48 expect(res, isNull); // no change from read-only operators |
| 49 | 49 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 arr.clear(); | 109 arr.clear(); |
| 110 called = true; | 110 called = true; |
| 111 })(null); | 111 })(null); |
| 112 expect(called, isTrue); | 112 expect(called, isTrue); |
| 113 expect(res, isNotNull); | 113 expect(res, isNotNull); |
| 114 expect(res.events, hasLength(1)); | 114 expect(res.events, hasLength(1)); |
| 115 validateGlobal(res.events[0], arr); | 115 validateGlobal(res.events[0], arr); |
| 116 expect(arr, orderedEquals([])); | 116 expect(arr, orderedEquals([])); |
| 117 }); | 117 }); |
| 118 } | 118 } |
| OLD | NEW |