| 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "dart:collection"; | 6 import "dart:collection"; |
| 7 | 7 |
| 8 test(List list, int index, Iterable iterable) { | 8 test(List<int> list, int index, Iterable<int> iterable) { |
| 9 List copy = list.toList(); | 9 List copy = list.toList(); |
| 10 list.insertAll(index, iterable); | 10 list.insertAll(index, iterable); |
| 11 List iterableList = iterable.toList(); | 11 List iterableList = iterable.toList(); |
| 12 Expect.equals(copy.length + iterableList.length, list.length); | 12 Expect.equals(copy.length + iterableList.length, list.length); |
| 13 for (int i = 0; i < index; i++) { | 13 for (int i = 0; i < index; i++) { |
| 14 Expect.equals(copy[i], list[i]); | 14 Expect.equals(copy[i], list[i]); |
| 15 } | 15 } |
| 16 for (int i = 0; i < iterableList.length; i++) { | 16 for (int i = 0; i < iterableList.length; i++) { |
| 17 Expect.equals(iterableList[i], list[i + index]); | 17 Expect.equals(iterableList[i], list[i + index]); |
| 18 } | 18 } |
| 19 for (int i = index + iterableList.length; i < copy.length; i++) { | 19 for (int i = index + iterableList.length; i < copy.length; i++) { |
| 20 Expect.equals(copy[i], list[i + iterableList.length]); | 20 Expect.equals(copy[i], list[i + iterableList.length]); |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 class MyList extends ListBase { | 24 class MyList<T> extends ListBase<T> { |
| 25 List list; | 25 List<T> list; |
| 26 MyList(this.list); | 26 MyList(this.list); |
| 27 get length => list.length; | 27 get length => list.length; |
| 28 set length(value) { | 28 set length(value) { |
| 29 list.length = value; | 29 list.length = value; |
| 30 } | 30 } |
| 31 | 31 |
| 32 operator [](index) => list[index]; | 32 operator [](index) => list[index]; |
| 33 operator []=(index, val) { | 33 operator []=(index, val) { |
| 34 list[index] = val; | 34 list[index] = val; |
| 35 } | 35 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 expectUE(() => test([1, 2, 3].toList(growable: false), 0, [4, 5])); | 81 expectUE(() => test([1, 2, 3].toList(growable: false), 0, [4, 5])); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void expectRE(void f()) { | 84 void expectRE(void f()) { |
| 85 Expect.throws(f, (e) => e is RangeError); | 85 Expect.throws(f, (e) => e is RangeError); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void expectUE(void f()) { | 88 void expectUE(void f()) { |
| 89 Expect.throws(f, (e) => e is UnsupportedError); | 89 Expect.throws(f, (e) => e is UnsupportedError); |
| 90 } | 90 } |
| OLD | NEW |