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

Side by Side Diff: pkg/matcher/test/prints_matcher_test.dart

Issue 793163002: Fix the prints matcher test on dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | Annotate | Revision Log
« no previous file with comments | « pkg/matcher/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
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 library matcher.prints_matchers_test; 5 library matcher.prints_matchers_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:matcher/matcher.dart'; 9 import 'package:matcher/matcher.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import 'test_utils.dart'; 12 import 'test_utils.dart';
13 13
14 /// The VM and dart2js have different toStrings for closures.
15 final closureToString = (() {}).toString();
16
14 void main() { 17 void main() {
15 initUtils(); 18 initUtils();
16 19
17 group('synchronous', () { 20 group('synchronous', () {
18 test("passes with an expected print", () { 21 test("passes with an expected print", () {
19 shouldPass(() => print("Hello, world!"), prints("Hello, world!\n")); 22 shouldPass(() => print("Hello, world!"), prints("Hello, world!\n"));
20 }); 23 });
21 24
22 test("combines multiple prints", () { 25 test("combines multiple prints", () {
23 shouldPass(() { 26 shouldPass(() {
24 print("Hello"); 27 print("Hello");
25 print("World!"); 28 print("World!");
26 }, prints("Hello\nWorld!\n")); 29 }, prints("Hello\nWorld!\n"));
27 }); 30 });
28 31
29 test("works with a Matcher", () { 32 test("works with a Matcher", () {
30 shouldPass(() => print("Hello, world!"), prints(contains("Hello"))); 33 shouldPass(() => print("Hello, world!"), prints(contains("Hello")));
31 }); 34 });
32 35
33 test("describes a failure nicely", () { 36 test("describes a failure nicely", () {
34 shouldFail(() => print("Hello, world!"), prints("Goodbye, world!\n"), 37 shouldFail(() => print("Hello, world!"), prints("Goodbye, world!\n"),
35 "Expected: prints 'Goodbye, world!\\n' ''" 38 "Expected: prints 'Goodbye, world!\\n' ''"
36 " Actual: <Closure: () => dynamic> " 39 " Actual: <$closureToString> "
37 " Which: printed 'Hello, world!\\n' ''" 40 " Which: printed 'Hello, world!\\n' ''"
38 " Which: is different. " 41 " Which: is different. "
39 "Expected: Goodbye, w ... " 42 "Expected: Goodbye, w ... "
40 " Actual: Hello, wor ... " 43 " Actual: Hello, wor ... "
41 " ^ Differ at offset 0"); 44 " ^ Differ at offset 0");
42 }); 45 });
43 46
44 test("describes a failure with a non-descriptive Matcher nicely", () { 47 test("describes a failure with a non-descriptive Matcher nicely", () {
45 shouldFail(() => print("Hello, world!"), prints(contains("Goodbye")), 48 shouldFail(() => print("Hello, world!"), prints(contains("Goodbye")),
46 "Expected: prints contains 'Goodbye'" 49 "Expected: prints contains 'Goodbye'"
47 " Actual: <Closure: () => dynamic> " 50 " Actual: <$closureToString> "
48 " Which: printed 'Hello, world!\\n' ''"); 51 " Which: printed 'Hello, world!\\n' ''");
49 }); 52 });
50 53
51 test("describes a failure with no text nicely", () { 54 test("describes a failure with no text nicely", () {
52 shouldFail(() {}, prints(contains("Goodbye")), 55 shouldFail(() {}, prints(contains("Goodbye")),
53 "Expected: prints contains 'Goodbye'" 56 "Expected: prints contains 'Goodbye'"
54 " Actual: <Closure: () => dynamic> " 57 " Actual: <$closureToString> "
55 " Which: printed nothing."); 58 " Which: printed nothing.");
56 }); 59 });
57 }); 60 });
58 61
59 group('asynchronous', () { 62 group('asynchronous', () {
60 test("passes with an expected print", () { 63 test("passes with an expected print", () {
61 shouldPass(() => new Future(() => print("Hello, world!")), 64 shouldPass(() => new Future(() => print("Hello, world!")),
62 prints("Hello, world!\n")); 65 prints("Hello, world!\n"));
63 }); 66 });
64 67
(...skipping 30 matching lines...) Expand all
95 }); 98 });
96 99
97 test("describes a failure with no text nicely", () { 100 test("describes a failure with no text nicely", () {
98 shouldFail(() => new Future.value(), prints(contains("Goodbye")), 101 shouldFail(() => new Future.value(), prints(contains("Goodbye")),
99 "Expected: contains 'Goodbye'" 102 "Expected: contains 'Goodbye'"
100 " Actual: ''", 103 " Actual: ''",
101 isAsync: true); 104 isAsync: true);
102 }); 105 });
103 }); 106 });
104 } 107 }
OLDNEW
« no previous file with comments | « pkg/matcher/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698