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

Side by Side Diff: test/matcher/completion_test.dart

Issue 934413002: Replace the existing unittest APIs with the new runner infrastructure. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 years, 10 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 | « test/loader_test.dart ('k') | test/matcher/prints_test.dart » ('j') | 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 import 'dart:async';
6
7 import 'package:unittest/unittest.dart';
8
9 import '../utils.dart';
10
11 void main() {
12 group("[completes]", () {
13 test("blocks the test until the Future completes", () {
14 return expectTestBlocks(() {
15 var completer = new Completer();
16 expect(completer.future, completes);
17 return completer;
18 }, (completer) => completer.complete());
19 });
20
21 test("with an error", () {
22 return runTest(() {
23 expect(new Future.error('X'), completes);
24 }).then((liveTest) {
25 expectTestFailed(liveTest, startsWith(
26 "Expected future to complete successfully, but it failed with X"));
27 });
28 });
29
30 test("with a failure", () {
31 return runTest(() {
32 expect(new Future.error(new TestFailure('oh no')), completes);
33 }).then((liveTest) {
34 expectTestFailed(liveTest, "oh no");
35 });
36 });
37
38 test("with a non-function", () {
39 return runTest(() {
40 expect(10, completes);
41 }).then((liveTest) {
42 expectTestFailed(liveTest,
43 "Expected: completes successfully\n"
44 " Actual: <10>\n");
45 });
46 });
47
48 test("with a successful future", () {
49 expect(new Future.value('1'), completes);
50 });
51 });
52
53 group("[completion]", () {
54 test("blocks the test until the Future completes", () {
55 return expectTestBlocks(() {
56 var completer = new Completer();
57 expect(completer.future, completion(isNull));
58 return completer;
59 }, (completer) => completer.complete());
60 });
61
62 test("with an error", () {
63 return runTest(() {
64 expect(new Future.error('X'), completion(isNull));
65 }).then((liveTest) {
66 expectTestFailed(liveTest, startsWith(
67 "Expected future to complete successfully, but it failed with X"));
68 });
69 });
70
71 test("with a failure", () {
72 return runTest(() {
73 expect(new Future.error(new TestFailure('oh no')), completion(isNull));
74 }).then((liveTest) {
75 expectTestFailed(liveTest, "oh no");
76 });
77 });
78
79 test("with a non-function", () {
80 return runTest(() {
81 expect(10, completion(equals(10)));
82 }).then((liveTest) {
83 expectTestFailed(liveTest,
84 "Expected: completes to a value that <10>\n"
85 " Actual: <10>\n");
86 });
87 });
88
89 test("with an incorrect value", () {
90 return runTest(() {
91 expect(new Future.value('a'), completion(equals('b')));
92 }).then((liveTest) {
93 expectTestFailed(liveTest, startsWith(
94 "Expected: 'b'\n"
95 " Actual: 'a'\n"
96 " Which: is different."));;
97 });
98 });
99 });
100 }
OLDNEW
« no previous file with comments | « test/loader_test.dart ('k') | test/matcher/prints_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698