OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011, 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 'dart:async'; |
| 6 import 'dart:isolate'; |
| 7 import '../../../pkg/unittest/lib/unittest.dart'; |
| 8 import 'event_helper.dart'; |
| 9 |
| 10 const int big = 1000000; |
| 11 const double inf = double.INFINITY; |
| 12 List intList = const [-0, 0, -1, 1, -10, 10, -big, big]; |
| 13 List doubleList = const [-0.0, 0.0, -1.0, 1.0, -10.0, 10.0, -inf, inf]; |
| 14 |
| 15 main() { |
| 16 testMinMax(name, iterable, min, max, [int compare(a, b)]) { |
| 17 test("$name-min", () { |
| 18 StreamController c = new StreamController(); |
| 19 Future f = c.min(compare); |
| 20 f.then(expectAsync1((v) { Expect.equals(min, v);})); |
| 21 new Events.fromIterable(iterable).replay(c); |
| 22 }); |
| 23 test("$name-max", () { |
| 24 StreamController c = new StreamController(); |
| 25 Future f = c.max(compare); |
| 26 f.then(expectAsync1((v) { Expect.equals(max, v);})); |
| 27 new Events.fromIterable(iterable).replay(c); |
| 28 }); |
| 29 } |
| 30 |
| 31 testMinMax("const-int", intList, -big, big); |
| 32 testMinMax("list-int", intList.toList(), -big, big); |
| 33 testMinMax("set-int", intList.toSet(), -big, big); |
| 34 |
| 35 testMinMax("const-double", doubleList, -inf, inf); |
| 36 testMinMax("list-double", doubleList.toList(), -inf, inf); |
| 37 testMinMax("set-double", doubleList.toSet(), -inf, inf); |
| 38 |
| 39 int reverse(a, b) => b.compareTo(a); |
| 40 testMinMax("rev-int", intList, big, -big, reverse); |
| 41 testMinMax("rev-double", doubleList, inf, -inf, reverse); |
| 42 } |
OLD | NEW |