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 import "dart:collection"; | 5 import "dart:collection"; |
6 import "dart:typed_data"; | 6 import "dart:typed_data"; |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 void main() { | 9 void main() { |
10 // Typed lists - fixed length and can only contain integers. | 10 // Typed lists - fixed length and can only contain integers. |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 List<E> _source; | 575 List<E> _source; |
576 MyFixedList(this._source); | 576 MyFixedList(this._source); |
577 int get length => _source.length; | 577 int get length => _source.length; |
578 void set length(int length) { throw new UnsupportedError("Fixed length!"); } | 578 void set length(int length) { throw new UnsupportedError("Fixed length!"); } |
579 E operator[](int index) => _source[index]; | 579 E operator[](int index) => _source[index]; |
580 void operator[]=(int index, E value) { _source[index] = value; } | 580 void operator[]=(int index, E value) { _source[index] = value; } |
581 } | 581 } |
582 | 582 |
583 void testListConstructor() { | 583 void testListConstructor() { |
584 Expect.throws(() { new List(0).add(4); }); // Is fixed-length. | 584 Expect.throws(() { new List(0).add(4); }); // Is fixed-length. |
585 Expect.throws(() { new List(-2); }); // Not negative. /// 01: ok | 585 Expect.throws(() { new List(-2); }); // Not negative. //# 01: ok |
586 Expect.throws(() { new List(null); }); // Not null. | 586 Expect.throws(() { new List(null); }); // Not null. |
587 Expect.listEquals([4], new List()..add(4)); | 587 Expect.listEquals([4], new List()..add(4)); |
588 Expect.throws(() { new List.filled(0, 42).add(4); }); // Is fixed-length. | 588 Expect.throws(() { new List.filled(0, 42).add(4); }); // Is fixed-length. |
589 Expect.throws(() { new List.filled(-2, 42); }); // Not negative. | 589 Expect.throws(() { new List.filled(-2, 42); }); // Not negative. |
590 Expect.throws(() { new List.filled(null, 42); }); // Not null. | 590 Expect.throws(() { new List.filled(null, 42); }); // Not null. |
591 } | 591 } |
OLD | NEW |