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

Side by Side Diff: test/async_thunk_test.dart

Issue 1220963002: Add an AsyncThunk class. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 5 years, 5 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
« lib/src/future_group.dart ('K') | « pubspec.yaml ('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 async.test.async_thunk_test;
6
7 import 'dart:async';
8
9 import 'package:async/async.dart';
10 import 'package:test/test.dart';
11
12 main() {
13 var thunk;
14 setUp(() => thunk = new AsyncThunk());
15
16 test("runs the function only the first time run() is called", () async {
17 var count = 0;
18 await thunk.run(() => count++);
19 expect(count, equals(1));
20
21 await thunk.run(() => count++);
22 expect(count, equals(1));
23 });
24
25 test("forwards the return value from the function", () async {
26 expect(thunk.run(() => "value"), completion(equals("value")));
27 expect(thunk.run(() {}), completion(equals("value")));
28 });
29
30 test("forwards the error from the function", () async {
31 expect(thunk.run(() => throw "error"), throwsA("error"));
32 expect(thunk.run(() {}), throwsA("error"));
33 });
34 }
OLDNEW
« lib/src/future_group.dart ('K') | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698