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 dynamicCheck(input, {isInt, isString}) { | 7 dynamicCheck(input, {isInt, isString}) { |
8 var copy = input.toList(); | 8 var copy = input.toList(); |
9 Expect.isTrue(isInt == copy is List<int>); | 9 Expect.isTrue(isInt == copy is List<int>); |
10 Expect.isTrue(isString == copy is List<String>); | 10 Expect.isTrue(isString == copy is List<String>); |
11 } | 11 } |
12 | 12 |
13 main() { | 13 main() { |
14 List<int> list1 = <int>[1, 2, 3]; | 14 List<int> list1 = <int>[1, 2, 3]; |
15 List<int> list2 = const <int>[4, 5]; | 15 List<int> list2 = const <int>[4, 5]; |
16 List<String> list3 = <String>[]; | 16 List<String> list3 = <String>[]; |
17 Set<int> set1 = new Set<int>(); | 17 Set<int> set1 = new Set<int>(); |
18 set1..add(11) | 18 set1..add(11)..add(12)..add(13); |
19 ..add(12) | |
20 ..add(13); | |
21 Set<String> set2 = new Set<String>(); | 19 Set<String> set2 = new Set<String>(); |
22 set2..add("foo") | 20 set2..add("foo")..add("bar")..add("toto"); |
23 ..add("bar") | |
24 ..add("toto"); | |
25 Set set3 = new Set(); | 21 Set set3 = new Set(); |
26 | 22 |
27 var listCopy = list1.toList(); | 23 var listCopy = list1.toList(); |
28 Expect.listEquals(list1, listCopy); | 24 Expect.listEquals(list1, listCopy); |
29 Expect.isTrue(listCopy is List<int>); | 25 Expect.isTrue(listCopy is List<int>); |
30 Expect.isFalse(listCopy is List<String>); | 26 Expect.isFalse(listCopy is List<String>); |
31 Expect.isFalse(identical(list1, listCopy)); | 27 Expect.isFalse(identical(list1, listCopy)); |
32 dynamicCheck(list1, isInt: true, isString: false); | 28 dynamicCheck(list1, isInt: true, isString: false); |
33 | 29 |
34 listCopy = list2.toList(); | 30 listCopy = list2.toList(); |
(...skipping 27 matching lines...) Expand all Loading... |
62 Expect.isTrue(listCopy is List<String>); | 58 Expect.isTrue(listCopy is List<String>); |
63 Expect.isFalse(listCopy is List<int>); | 59 Expect.isFalse(listCopy is List<int>); |
64 dynamicCheck(set2, isInt: false, isString: true); | 60 dynamicCheck(set2, isInt: false, isString: true); |
65 | 61 |
66 listCopy = set3.toList(); | 62 listCopy = set3.toList(); |
67 Expect.isTrue(listCopy.isEmpty); | 63 Expect.isTrue(listCopy.isEmpty); |
68 Expect.isTrue(listCopy is List<int>); | 64 Expect.isTrue(listCopy is List<int>); |
69 Expect.isTrue(listCopy is List<String>); | 65 Expect.isTrue(listCopy is List<String>); |
70 dynamicCheck(set3, isInt: true, isString: true); | 66 dynamicCheck(set3, isInt: true, isString: true); |
71 } | 67 } |
OLD | NEW |