Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Unified Diff: tests/lib/async/stream_min_max_test.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/lib/async/stream_controller_test.dart ('k') | tests/lib/async/stream_single_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/stream_min_max_test.dart
diff --git a/tests/lib/async/stream_min_max_test.dart b/tests/lib/async/stream_min_max_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..471f3095e794fe382daf1f1a30568b435f336987
--- /dev/null
+++ b/tests/lib/async/stream_min_max_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:isolate';
+import '../../../pkg/unittest/lib/unittest.dart';
+import 'event_helper.dart';
+
+const int big = 1000000;
+const double inf = double.INFINITY;
+List intList = const [-0, 0, -1, 1, -10, 10, -big, big];
+List doubleList = const [-0.0, 0.0, -1.0, 1.0, -10.0, 10.0, -inf, inf];
+
+main() {
+ testMinMax(name, iterable, min, max, [int compare(a, b)]) {
+ test("$name-min", () {
+ StreamController c = new StreamController();
+ Future f = c.min(compare);
+ f.then(expectAsync1((v) { Expect.equals(min, v);}));
+ new Events.fromIterable(iterable).replay(c);
+ });
+ test("$name-max", () {
+ StreamController c = new StreamController();
+ Future f = c.max(compare);
+ f.then(expectAsync1((v) { Expect.equals(max, v);}));
+ new Events.fromIterable(iterable).replay(c);
+ });
+ }
+
+ testMinMax("const-int", intList, -big, big);
+ testMinMax("list-int", intList.toList(), -big, big);
+ testMinMax("set-int", intList.toSet(), -big, big);
+
+ testMinMax("const-double", doubleList, -inf, inf);
+ testMinMax("list-double", doubleList.toList(), -inf, inf);
+ testMinMax("set-double", doubleList.toSet(), -inf, inf);
+
+ int reverse(a, b) => b.compareTo(a);
+ testMinMax("rev-int", intList, big, -big, reverse);
+ testMinMax("rev-double", doubleList, inf, -inf, reverse);
+}
« no previous file with comments | « tests/lib/async/stream_controller_test.dart ('k') | tests/lib/async/stream_single_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698