| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "package:expect/expect.dart"; | |
| 6 | |
| 7 // Tests for the contains methods on lists. | |
| 8 | |
| 9 test(list, notInList) { | |
| 10 testList(list) { | |
| 11 for (int i = 0; i < list.length; i++) { | |
| 12 var elem = list[i]; | |
| 13 Expect.isTrue(list.contains(list[i]), "$list.contains($elem)"); | |
| 14 } | |
| 15 Expect.isFalse(list.contains(notInList), "!$list.contains($notInList)"); | |
| 16 } | |
| 17 List fixedList = new List(list.length); | |
| 18 List growList = new List(); | |
| 19 for (int i = 0; i < list.length; i++) { | |
| 20 fixedList[i] = list[i]; | |
| 21 growList.add(list[i]); | |
| 22 } | |
| 23 testList(list); | |
| 24 testList(fixedList); | |
| 25 testList(growList); | |
| 26 } | |
| 27 | |
| 28 class C { | |
| 29 const C(); | |
| 30 } | |
| 31 | |
| 32 class Niet { | |
| 33 bool operator==(other) => false; | |
| 34 } | |
| 35 | |
| 36 main() { | |
| 37 test(const <String>["a", "b", "c", null], "d"); | |
| 38 test(const <int>[1, 2, 3, null], 0); | |
| 39 test(const <bool>[true, false], null); | |
| 40 test(const <C>[const C(), const C(), null], new C()); | |
| 41 test(<C>[new C(), new C(), new C(), null], new C()); | |
| 42 test(const <double>[ 0.0, 1.0, 5e-324, 1e+308, double.INFINITY ], 2.0); | |
| 43 Expect.isTrue(const <double>[-0.0].contains(0.0)); | |
| 44 Expect.isFalse(const <double>[double.NAN].contains(double.NAN)); | |
| 45 var niet = new Niet(); | |
| 46 Expect.isFalse([niet].contains(niet)); | |
| 47 } | |
| OLD | NEW |