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

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

Issue 1031063003: Fix tests that were broken in Chrome. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 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 | « no previous file | test/frontend/matcher/throws_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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 8
9 import '../../utils.dart'; 9 import '../../utils.dart';
10 10
(...skipping 14 matching lines...) Expand all
25 expect(() => print("Hello, world!"), prints(contains("Hello"))); 25 expect(() => print("Hello, world!"), prints(contains("Hello")));
26 }); 26 });
27 27
28 test("describes a failure nicely", () { 28 test("describes a failure nicely", () {
29 return runTest(() { 29 return runTest(() {
30 expect(() => print("Hello, world!"), prints("Goodbye, world!\n")); 30 expect(() => print("Hello, world!"), prints("Goodbye, world!\n"));
31 }).then((liveTest) { 31 }).then((liveTest) {
32 expectTestFailed(liveTest, 32 expectTestFailed(liveTest,
33 "Expected: prints 'Goodbye, world!\\n'\n" 33 "Expected: prints 'Goodbye, world!\\n'\n"
34 " ''\n" 34 " ''\n"
35 " Actual: <Closure: () => dynamic>\n" 35 " Actual: <$closureString>\n"
36 " Which: printed 'Hello, world!\\n'\n" 36 " Which: printed 'Hello, world!\\n'\n"
37 " ''\n" 37 " ''\n"
38 " Which: is different.\n" 38 " Which: is different.\n"
39 "Expected: Goodbye, w ...\n" 39 "Expected: Goodbye, w ...\n"
40 " Actual: Hello, wor ...\n" 40 " Actual: Hello, wor ...\n"
41 " ^\n" 41 " ^\n"
42 " Differ at offset 0\n"); 42 " Differ at offset 0\n");
43 }); 43 });
44 }); 44 });
45 45
46 test("describes a failure with a non-descriptive Matcher nicely", () { 46 test("describes a failure with a non-descriptive Matcher nicely", () {
47 return runTest(() { 47 return runTest(() {
48 expect(() => print("Hello, world!"), prints(contains("Goodbye"))); 48 expect(() => print("Hello, world!"), prints(contains("Goodbye")));
49 }).then((liveTest) { 49 }).then((liveTest) {
50 expectTestFailed(liveTest, 50 expectTestFailed(liveTest,
51 "Expected: prints contains 'Goodbye'\n" 51 "Expected: prints contains 'Goodbye'\n"
52 " Actual: <Closure: () => dynamic>\n" 52 " Actual: <$closureString>\n"
53 " Which: printed 'Hello, world!\\n'\n" 53 " Which: printed 'Hello, world!\\n'\n"
54 " ''\n"); 54 " ''\n");
55 }); 55 });
56 }); 56 });
57 57
58 test("describes a failure with no text nicely", () { 58 test("describes a failure with no text nicely", () {
59 return runTest(() { 59 return runTest(() {
60 expect(() {}, prints(contains("Goodbye"))); 60 expect(() {}, prints(contains("Goodbye")));
61 }).then((liveTest) { 61 }).then((liveTest) {
62 expectTestFailed(liveTest, 62 expectTestFailed(liveTest,
63 "Expected: prints contains 'Goodbye'\n" 63 "Expected: prints contains 'Goodbye'\n"
64 " Actual: <Closure: () => dynamic>\n" 64 " Actual: <$closureString>\n"
65 " Which: printed nothing.\n"); 65 " Which: printed nothing.\n");
66 }); 66 });
67 }); 67 });
68 68
69 test("with a non-function", () { 69 test("with a non-function", () {
70 return runTest(() { 70 return runTest(() {
71 expect(10, prints(contains("Goodbye"))); 71 expect(10, prints(contains("Goodbye")));
72 }).then((liveTest) { 72 }).then((liveTest) {
73 expectTestFailed(liveTest, 73 expectTestFailed(liveTest,
74 "Expected: prints contains 'Goodbye'\n" 74 "Expected: prints contains 'Goodbye'\n"
(...skipping 21 matching lines...) Expand all
96 }); 96 });
97 97
98 test("describes a failure nicely", () { 98 test("describes a failure nicely", () {
99 return runTest(() { 99 return runTest(() {
100 expect(() => new Future(() => print("Hello, world!")), 100 expect(() => new Future(() => print("Hello, world!")),
101 prints("Goodbye, world!\n")); 101 prints("Goodbye, world!\n"));
102 }).then((liveTest) { 102 }).then((liveTest) {
103 expectTestFailed(liveTest, startsWith( 103 expectTestFailed(liveTest, startsWith(
104 "Expected: prints 'Goodbye, world!\\n'\n" 104 "Expected: prints 'Goodbye, world!\\n'\n"
105 " ''\n" 105 " ''\n"
106 " Actual: <Closure: () => dynamic>\n" 106 " Actual: <$closureString>\n"
107 " Which: printed 'Hello, world!\\n'\n" 107 " Which: printed 'Hello, world!\\n'\n"
108 " ''\n" 108 " ''\n"
109 " Which: is different.\n" 109 " Which: is different.\n"
110 "Expected: Goodbye, w ...\n" 110 "Expected: Goodbye, w ...\n"
111 " Actual: Hello, wor ...\n" 111 " Actual: Hello, wor ...\n"
112 " ^\n" 112 " ^\n"
113 " Differ at offset 0")); 113 " Differ at offset 0"));
114 }); 114 });
115 }); 115 });
116 116
117 test("describes a failure with a non-descriptive Matcher nicely", () { 117 test("describes a failure with a non-descriptive Matcher nicely", () {
118 return runTest(() { 118 return runTest(() {
119 expect(() => new Future(() => print("Hello, world!")), 119 expect(() => new Future(() => print("Hello, world!")),
120 prints(contains("Goodbye"))); 120 prints(contains("Goodbye")));
121 }).then((liveTest) { 121 }).then((liveTest) {
122 expectTestFailed(liveTest, startsWith( 122 expectTestFailed(liveTest, startsWith(
123 "Expected: prints contains 'Goodbye'\n" 123 "Expected: prints contains 'Goodbye'\n"
124 " Actual: <Closure: () => dynamic>\n" 124 " Actual: <$closureString>\n"
125 " Which: printed 'Hello, world!\\n'\n" 125 " Which: printed 'Hello, world!\\n'\n"
126 " ''")); 126 " ''"));
127 }); 127 });
128 }); 128 });
129 129
130 test("describes a failure with no text nicely", () { 130 test("describes a failure with no text nicely", () {
131 return runTest(() { 131 return runTest(() {
132 expect(() => new Future.value(), prints(contains("Goodbye"))); 132 expect(() => new Future.value(), prints(contains("Goodbye")));
133 }).then((liveTest) { 133 }).then((liveTest) {
134 expectTestFailed(liveTest, startsWith( 134 expectTestFailed(liveTest, startsWith(
135 "Expected: prints contains 'Goodbye'\n" 135 "Expected: prints contains 'Goodbye'\n"
136 " Actual: <Closure: () => dynamic>\n" 136 " Actual: <$closureString>\n"
137 " Which: printed nothing.")); 137 " Which: printed nothing."));
138 }); 138 });
139 }); 139 });
140 140
141 test("won't let the test end until the Future completes", () { 141 test("won't let the test end until the Future completes", () {
142 return expectTestBlocks(() { 142 return expectTestBlocks(() {
143 var completer = new Completer(); 143 var completer = new Completer();
144 expect(() => completer.future, prints(isEmpty)); 144 expect(() => completer.future, prints(isEmpty));
145 return completer; 145 return completer;
146 }, (completer) => completer.complete()); 146 }, (completer) => completer.complete());
147 }); 147 });
148 }); 148 });
149 } 149 }
OLDNEW
« no previous file with comments | « no previous file | test/frontend/matcher/throws_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698