| 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}) { | |
| 8 var copy = input.toList(); | |
| 9 Expect.isTrue(isInt == copy is List<int>); | |
| 10 Expect.isTrue(isString == copy is List<String>); | |
| 11 } | |
| 12 | |
| 13 main() { | 7 main() { |
| 14 List<int> list1 = <int>[1, 2, 3]; | 8 List<int> list1 = <int>[1, 2, 3]; |
| 15 List<int> list2 = const <int>[4, 5]; | 9 List<int> list2 = const <int>[4, 5]; |
| 16 List<String> list3 = <String>[]; | 10 List<String> list3 = <String>[]; |
| 17 Set<int> set1 = new Set<int>(); | 11 Set<int> set1 = new Set<int>(); |
| 18 set1..add(11) | 12 set1..add(11) |
| 19 ..add(12) | 13 ..add(12) |
| 20 ..add(13); | 14 ..add(13); |
| 21 Set<String> set2 = new Set<String>(); | 15 Set<String> set2 = new Set<String>(); |
| 22 set2..add("foo") | 16 set2..add("foo") |
| 23 ..add("bar") | 17 ..add("bar") |
| 24 ..add("toto"); | 18 ..add("toto"); |
| 25 Set set3 = new Set(); | 19 Set set3 = new Set(); |
| 26 | 20 |
| 27 var listCopy = list1.toList(); | 21 var listCopy = list1.toList(); |
| 28 Expect.listEquals(list1, listCopy); | 22 Expect.listEquals(list1, listCopy); |
| 29 Expect.isTrue(listCopy is List<int>); | 23 Expect.isTrue(listCopy is List<int>); |
| 30 Expect.isFalse(listCopy is List<String>); | 24 Expect.isFalse(listCopy is List<String>); |
| 31 Expect.isFalse(identical(list1, listCopy)); | 25 Expect.isFalse(identical(list1, listCopy)); |
| 32 dynamicCheck(list1, isInt: true, isString: false); | |
| 33 | 26 |
| 34 listCopy = list2.toList(); | 27 listCopy = list2.toList(); |
| 35 Expect.listEquals(list2, listCopy); | 28 Expect.listEquals(list2, listCopy); |
| 36 Expect.isTrue(listCopy is List<int>); | 29 Expect.isTrue(listCopy is List<int>); |
| 37 Expect.isFalse(listCopy is List<String>); | 30 Expect.isFalse(listCopy is List<String>); |
| 38 Expect.isFalse(identical(list2, listCopy)); | 31 Expect.isFalse(identical(list2, listCopy)); |
| 39 dynamicCheck(list2, isInt: true, isString: false); | |
| 40 | 32 |
| 41 listCopy = list3.toList(); | 33 listCopy = list3.toList(); |
| 42 Expect.listEquals(list3, listCopy); | 34 Expect.listEquals(list3, listCopy); |
| 43 Expect.isTrue(listCopy is List<String>); | 35 Expect.isTrue(listCopy is List<String>); |
| 44 Expect.isFalse(listCopy is List<int>); | 36 Expect.isFalse(listCopy is List<int>); |
| 45 Expect.isFalse(identical(list3, listCopy)); | 37 Expect.isFalse(identical(list3, listCopy)); |
| 46 dynamicCheck(list3, isInt: false, isString: true); | |
| 47 | 38 |
| 48 listCopy = set1.toList(); | 39 listCopy = set1.toList(); |
| 49 Expect.equals(3, listCopy.length); | 40 Expect.equals(3, listCopy.length); |
| 50 Expect.isTrue(listCopy.contains(11)); | 41 Expect.isTrue(listCopy.contains(11)); |
| 51 Expect.isTrue(listCopy.contains(12)); | 42 Expect.isTrue(listCopy.contains(12)); |
| 52 Expect.isTrue(listCopy.contains(13)); | 43 Expect.isTrue(listCopy.contains(13)); |
| 53 Expect.isTrue(listCopy is List<int>); | 44 Expect.isTrue(listCopy is List<int>); |
| 54 Expect.isFalse(listCopy is List<String>); | 45 Expect.isFalse(listCopy is List<String>); |
| 55 dynamicCheck(set1, isInt: true, isString: false); | |
| 56 | 46 |
| 57 listCopy = set2.toList(); | 47 listCopy = set2.toList(); |
| 58 Expect.equals(3, listCopy.length); | 48 Expect.equals(3, listCopy.length); |
| 59 Expect.isTrue(listCopy.contains("foo")); | 49 Expect.isTrue(listCopy.contains("foo")); |
| 60 Expect.isTrue(listCopy.contains("bar")); | 50 Expect.isTrue(listCopy.contains("bar")); |
| 61 Expect.isTrue(listCopy.contains("toto")); | 51 Expect.isTrue(listCopy.contains("toto")); |
| 62 Expect.isTrue(listCopy is List<String>); | 52 Expect.isTrue(listCopy is List<String>); |
| 63 Expect.isFalse(listCopy is List<int>); | 53 Expect.isFalse(listCopy is List<int>); |
| 64 dynamicCheck(set2, isInt: false, isString: true); | |
| 65 | 54 |
| 66 listCopy = set3.toList(); | 55 listCopy = set3.toList(); |
| 67 Expect.isTrue(listCopy.isEmpty); | 56 Expect.isTrue(listCopy.isEmpty); |
| 68 Expect.isTrue(listCopy is List<int>); | 57 Expect.isTrue(listCopy is List<int>); |
| 69 Expect.isTrue(listCopy is List<String>); | 58 Expect.isTrue(listCopy is List<String>); |
| 70 dynamicCheck(set3, isInt: true, isString: true); | |
| 71 } | 59 } |
| OLD | NEW |