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

Unified Diff: test/frontend/matcher/prints_test.dart

Issue 1180613008: Fix prints/throws tests on the latest dart2js. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/frontend/matcher/throws_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/frontend/matcher/prints_test.dart
diff --git a/test/frontend/matcher/prints_test.dart b/test/frontend/matcher/prints_test.dart
index 93466dee24633c44188cb781b84234b241860eb1..11eac47ddb3e074b37c16f162f3b34c33c18201f 100644
--- a/test/frontend/matcher/prints_test.dart
+++ b/test/frontend/matcher/prints_test.dart
@@ -26,44 +26,56 @@ void main() {
});
test("describes a failure nicely", () async {
+ var closure = () => print("Hello, world!");
var liveTest = await runTestBody(() {
- expect(() => print("Hello, world!"), prints("Goodbye, world!\n"));
+ expect(closure, prints("Goodbye, world!\n"));
});
- expectTestFailed(liveTest,
- "Expected: prints 'Goodbye, world!\\n'\n"
- " ''\n"
- " Actual: <$closureString>\n"
- " Which: printed 'Hello, world!\\n'\n"
- " ''\n"
- " Which: is different.\n"
- "Expected: Goodbye, w ...\n"
- " Actual: Hello, wor ...\n"
- " ^\n"
- " Differ at offset 0\n");
+ expectTestFailed(liveTest, allOf([
+ startsWith(
+ "Expected: prints 'Goodbye, world!\\n'\n"
+ " ''\n"
+ " Actual: <"),
+ endsWith(">\n"
+ " Which: printed 'Hello, world!\\n'\n"
+ " ''\n"
+ " Which: is different.\n"
+ "Expected: Goodbye, w ...\n"
+ " Actual: Hello, wor ...\n"
+ " ^\n"
+ " Differ at offset 0\n")
+ ]));
});
test("describes a failure with a non-descriptive Matcher nicely", () async {
+ var closure = () => print("Hello, world!");
var liveTest = await runTestBody(() {
- expect(() => print("Hello, world!"), prints(contains("Goodbye")));
+ expect(closure, prints(contains("Goodbye")));
});
- expectTestFailed(liveTest,
- "Expected: prints contains 'Goodbye'\n"
- " Actual: <$closureString>\n"
- " Which: printed 'Hello, world!\\n'\n"
- " ''\n");
+ expectTestFailed(liveTest, allOf([
+ startsWith(
+ "Expected: prints contains 'Goodbye'\n"
+ " Actual: <"),
+ endsWith(">\n"
+ " Which: printed 'Hello, world!\\n'\n"
+ " ''\n")
+ ]));
});
test("describes a failure with no text nicely", () async {
+ var closure = () {};
var liveTest = await runTestBody(() {
- expect(() {}, prints(contains("Goodbye")));
+ expect(closure, prints(contains("Goodbye")));
});
- expectTestFailed(liveTest,
- "Expected: prints contains 'Goodbye'\n"
- " Actual: <$closureString>\n"
- " Which: printed nothing.\n");
+ expectTestFailed(liveTest, allOf([
+ startsWith(
+ "Expected: prints contains 'Goodbye'\n"
+ " Actual: <"),
+ endsWith(">\n"
+ " Which: printed nothing.\n")
+ ]));
});
test("with a non-function", () async {
@@ -96,46 +108,56 @@ void main() {
});
test("describes a failure nicely", () async {
+ var closure = () => new Future(() => print("Hello, world!"));
var liveTest = await runTestBody(() {
- expect(() => new Future(() => print("Hello, world!")),
- prints("Goodbye, world!\n"));
+ expect(closure, prints("Goodbye, world!\n"));
});
- expectTestFailed(liveTest, startsWith(
- "Expected: prints 'Goodbye, world!\\n'\n"
- " ''\n"
- " Actual: <$closureString>\n"
- " Which: printed 'Hello, world!\\n'\n"
- " ''\n"
- " Which: is different.\n"
- "Expected: Goodbye, w ...\n"
- " Actual: Hello, wor ...\n"
- " ^\n"
- " Differ at offset 0"));
+ expectTestFailed(liveTest, allOf([
+ startsWith(
+ "Expected: prints 'Goodbye, world!\\n'\n"
+ " ''\n"
+ " Actual: <"),
+ contains(">\n"
+ " Which: printed 'Hello, world!\\n'\n"
+ " ''\n"
+ " Which: is different.\n"
+ "Expected: Goodbye, w ...\n"
+ " Actual: Hello, wor ...\n"
+ " ^\n"
+ " Differ at offset 0")
+ ]));
});
test("describes a failure with a non-descriptive Matcher nicely", () async {
+ var closure = () => new Future(() => print("Hello, world!"));
var liveTest = await runTestBody(() {
- expect(() => new Future(() => print("Hello, world!")),
- prints(contains("Goodbye")));
+ expect(closure, prints(contains("Goodbye")));
});
- expectTestFailed(liveTest, startsWith(
- "Expected: prints contains 'Goodbye'\n"
- " Actual: <$closureString>\n"
- " Which: printed 'Hello, world!\\n'\n"
- " ''"));
+ expectTestFailed(liveTest, allOf([
+ startsWith(
+ "Expected: prints contains 'Goodbye'\n"
+ " Actual: <"),
+ contains(">\n"
+ " Which: printed 'Hello, world!\\n'\n"
+ " ''")
+ ]));
});
test("describes a failure with no text nicely", () async {
+ var closure = () => new Future.value();
var liveTest = await runTestBody(() {
- expect(() => new Future.value(), prints(contains("Goodbye")));
+ expect(closure, prints(contains("Goodbye")));
});
- expectTestFailed(liveTest, startsWith(
- "Expected: prints contains 'Goodbye'\n"
- " Actual: <$closureString>\n"
- " Which: printed nothing."));
+ expectTestFailed(liveTest, allOf([
+ startsWith(
+ "Expected: prints contains 'Goodbye'\n"
+ " Actual: <"),
+ contains(">\n"
+ " Which: printed nothing.")
+ ]));
});
test("won't let the test end until the Future completes", () {
« 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