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 // Tests for the contains methods on lists. | 7 // Tests for the contains methods on lists. |
8 | 8 |
9 class A { const A(); } | 9 class A { |
10 class B extends A { const B(); } | 10 const A(); |
| 11 } |
| 12 |
| 13 class B extends A { |
| 14 const B(); |
| 15 } |
11 | 16 |
12 main() { | 17 main() { |
13 var list = <B>[ new B() ]; | 18 var list = <B>[new B()]; |
14 var set = new Set<B>(); | 19 var set = new Set<B>(); |
15 set.add(new B()); | 20 set.add(new B()); |
16 var iterable1 = list.map((x) => x); | 21 var iterable1 = list.map((x) => x); |
17 var iterable2 = list.take(1); | 22 var iterable2 = list.take(1); |
18 var list2 = const <B>[ const B() ]; | 23 var list2 = const <B>[const B()]; |
19 var iterable3 = list2.map((x) => x); | 24 var iterable3 = list2.map((x) => x); |
20 var iterable4 = list2.take(1); | 25 var iterable4 = list2.take(1); |
21 var iterables = | 26 var iterables = [ |
22 [ list, set, iterable1, iterable2, list2, iterable3, iterable4 ]; | 27 list, |
| 28 set, |
| 29 iterable1, |
| 30 iterable2, |
| 31 list2, |
| 32 iterable3, |
| 33 iterable4 |
| 34 ]; |
23 for (var iterable in iterables) { | 35 for (var iterable in iterables) { |
24 Expect.isFalse(iterable.contains(new A())); | 36 Expect.isFalse(iterable.contains(new A())); |
25 } | 37 } |
26 } | 38 } |
OLD | NEW |