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

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

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

Powered by Google App Engine
This is Rietveld 408576698