| Index: tests/corelib/list_test.dart
|
| diff --git a/tests/corelib/list_test.dart b/tests/corelib/list_test.dart
|
| index 5187ee84ccce4cb210548b52923e1db406914798..cf7ca5aa3c0e6b32b654551bb1da63655b00fcd3 100644
|
| --- a/tests/corelib/list_test.dart
|
| +++ b/tests/corelib/list_test.dart
|
| @@ -46,6 +46,65 @@ void main() {
|
| testTypedGrowableList(new Int32List(0).toList());
|
|
|
| testListConstructor();
|
| +
|
| + // Regression for issue http://dartbug.com/24295
|
| + testIndex(list, name) {
|
| + try {
|
| + list[list.length];
|
| + } catch (err, s) {
|
| + Expect.isTrue(err is RangeError, name);
|
| + Expect.equals(list.length, err.invalidValue, "$name value");
|
| + Expect.equals(list.length - 1, err.end, "$name end");
|
| + Expect.equals(0, err.start, "$name start");
|
| + }
|
| + }
|
| + // Slices.
|
| + testSlice(list, name) {
|
| + try {
|
| + list.sublist(0, list.length + 1);
|
| + } catch (err) {
|
| + Expect.isTrue(err is RangeError, "$name[0:l+1] is-error");
|
| + Expect.equals("end", err.name, "$name[0:l+1] name");
|
| + Expect.equals(list.length + 1, err.invalidValue, "$name[0:l+1] value");
|
| + Expect.equals(0, err.start, "$name[0:l+1] start");
|
| + Expect.equals(list.length, err.end, "$name[0:l+1] end");
|
| + }
|
| + try {
|
| + list.sublist(list.length + 1, list.length + 1);
|
| + } catch (err) {
|
| + Expect.isTrue(err is RangeError, "$name[l+1:l+1] is-error");
|
| + Expect.equals("start", err.name, "$name[l+1:l+1] name");
|
| + Expect.equals(list.length + 1, err.invalidValue, "$name[l+1:l+1] value");
|
| + Expect.equals(0, err.start, "$name[l+1:l+1] start");
|
| + Expect.equals(list.length, err.end, "$name[l+1:l+1] end");
|
| + }
|
| + if (list.length == 0) return;
|
| + try {
|
| + list.sublist(1, list.length + 1);
|
| + } catch (err) {
|
| + Expect.isTrue(err is RangeError, "$name[1:l+1] is-error");
|
| + Expect.equals("end", err.name, "$name[1:l+1] name");
|
| + Expect.equals(list.length + 1, err.invalidValue, "$name[1:l+1] value");
|
| + Expect.equals(1, err.start, "$name[1:l+1] start");
|
| + Expect.equals(list.length, err.end, "$name[1:l+1] end");
|
| + }
|
| + }
|
| + testRangeErrors(list, name) {
|
| + testIndex(list, "$name#${list.length} index");
|
| + testSlice(list, "$name#${list.length} slice");
|
| + }
|
| + // Empty lists.
|
| + testRangeErrors([], "list");
|
| + testRangeErrors(new List(0), "fixed-list");
|
| + testRangeErrors(const [], "const-list");
|
| + testRangeErrors(new Uint8List(0), "typed-list");
|
| + testRangeErrors([1, 2, 3].sublist(1, 1), "sub-list");
|
| + // Non-empty lists.
|
| + testRangeErrors([1, 2, 3], "list");
|
| + testRangeErrors(new List(3), "fixed-list");
|
| + testRangeErrors(const [1, 2, 3], "const-list");
|
| + testRangeErrors(new Uint8List(3), "typed-list");
|
| + testRangeErrors([1, 2, 3, 4, 5].sublist(1, 3), "sub-list");
|
| }
|
|
|
| void testLength(int length, List list) {
|
|
|