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

Side by Side Diff: tests/lib/async/future_constructor2_test.dart

Issue 1296623004: Accept a computation that returns a Future for Future.delayed. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments. Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « sdk/lib/async/future.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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 library future_delayed_test;
6
7 import 'package:async_helper/async_helper.dart';
8 import "package:expect/expect.dart";
9 import 'dart:async';
10
11 Future<int> createIntFuture() {
12 return new Future<int>.value(499);
13 }
14
15 unnamed() {
16 asyncStart();
17 new Future<int>(createIntFuture)
18 .then((x) {
19 Expect.equals(499, x);
20 asyncEnd();
21 });
22 }
23
24 delayed() {
25 asyncStart();
26 new Future<int>.delayed(const Duration(milliseconds: 2), createIntFuture)
27 .then((x) {
28 Expect.equals(499, x);
29 asyncEnd();
30 });
31 }
32
33 microtask() {
34 asyncStart();
35 new Future<int>.microtask(createIntFuture)
36 .then((x) {
37 Expect.equals(499, x);
38 asyncEnd();
39 });
40 }
41
42 sync() {
43 asyncStart();
44 new Future<int>.sync(createIntFuture)
45 .then((x) {
46 Expect.equals(499, x);
47 asyncEnd();
48 });
49 }
50
51 main() {
52 asyncStart();
53 // Test that all the Future constructors take functions that return a Future
54 // as argument.
55 // In particular the constructors must not type their argument as
56 // `T computation()`.
57 unnamed();
58 delayed();
59 microtask();
60 sync();
61 asyncEnd();
62 }
OLDNEW
« no previous file with comments | « sdk/lib/async/future.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698