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"; | |
6 | |
7 main() { | 5 main() { |
8 test(expectation, iterable) { | 6 test(expectation, iterable) { |
9 Expect.listEquals(expectation, iterable.toList()); | 7 Expect.listEquals(expectation, iterable.toList()); |
10 } | 8 } |
11 | 9 |
12 // Function not called on empty iterable. | 10 // Function not called on empty iterable. |
13 test([], [].expand((x) { throw "not called"; })); | 11 test([], [].expand((x) { throw "not called"; })); |
14 | 12 |
15 // Creating the iterable doesn't call the function. | 13 // Creating the iterable doesn't call the function. |
16 [1].expand((x) { throw "not called"; }); | 14 [1].expand((x) { throw "not called"; }); |
(...skipping 16 matching lines...) Expand all Loading... |
33 Iterator it = iterable.iterator; | 31 Iterator it = iterable.iterator; |
34 Expect.isTrue(it.moveNext()); | 32 Expect.isTrue(it.moveNext()); |
35 Expect.equals(1, it.current); | 33 Expect.equals(1, it.current); |
36 Expect.isTrue(it.moveNext()); | 34 Expect.isTrue(it.moveNext()); |
37 Expect.equals(1, it.current); | 35 Expect.equals(1, it.current); |
38 Expect.throws(it.moveNext, (e) => e == "FAIL"); | 36 Expect.throws(it.moveNext, (e) => e == "FAIL"); |
39 // After throwing, iteration is ended. | 37 // After throwing, iteration is ended. |
40 Expect.equals(null, it.current); | 38 Expect.equals(null, it.current); |
41 Expect.isFalse(it.moveNext()); | 39 Expect.isFalse(it.moveNext()); |
42 } | 40 } |
OLD | NEW |