OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 6 |
7 class IC { | 7 class IC { |
8 int count = 0; | 8 int count = 0; |
9 String toString() => "${count++}"; | 9 String toString() => "${count++}"; |
10 } | 10 } |
11 | 11 |
12 testJoin(String expect, Iterable iterable, [String separator]) { | 12 testJoin(String expect, Iterable iterable, [String separator = ""]) { |
13 Expect.equals(expect, iterable.join(separator)); | 13 if (?separator) { |
| 14 Expect.equals(expect, iterable.join(separator)); |
| 15 } else { |
| 16 Expect.equals(expect, iterable.join()); |
| 17 } |
14 } | 18 } |
15 | 19 |
16 testCollections() { | 20 testCollections() { |
17 testJoin("", [], ","); | 21 testJoin("", [], ","); |
18 testJoin("", [], ""); | 22 testJoin("", [], ""); |
19 testJoin("", []); | 23 testJoin("", []); |
20 testJoin("", new Set(), ","); | 24 testJoin("", new Set(), ","); |
21 testJoin("", new Set(), ""); | 25 testJoin("", new Set(), ""); |
22 testJoin("", new Set()); | 26 testJoin("", new Set()); |
23 | 27 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 testJoin("abcd", ["a", "b", "c", "d"].map((x) => x)); | 67 testJoin("abcd", ["a", "b", "c", "d"].map((x) => x)); |
64 testJoin("null,b,c,d", [null,"b","c","d"].map((x) => x), ","); | 68 testJoin("null,b,c,d", [null,"b","c","d"].map((x) => x), ","); |
65 testJoin("1,2,3,4", [1, 2, 3, 4].map((x) => x), ","); | 69 testJoin("1,2,3,4", [1, 2, 3, 4].map((x) => x), ","); |
66 testJoin("4,5,6,7", [ic, ic, ic, ic].map((x) => x), ","); | 70 testJoin("4,5,6,7", [ic, ic, ic, ic].map((x) => x), ","); |
67 } | 71 } |
68 | 72 |
69 main() { | 73 main() { |
70 testCollections(); | 74 testCollections(); |
71 // TODO(lrn): test scalar lists. | 75 // TODO(lrn): test scalar lists. |
72 } | 76 } |
OLD | NEW |