OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library matcher.prints_matchers_test; | |
6 | |
7 import 'dart:async'; | |
8 | |
9 import 'package:matcher/matcher.dart'; | |
10 import 'package:unittest/unittest.dart'; | |
11 | |
12 import 'test_utils.dart'; | |
13 | |
14 void main() { | |
15 initUtils(); | |
16 | |
17 group('synchronous', () { | |
18 test("passes with an expected print", () { | |
19 shouldPass(() => print("Hello, world!"), prints("Hello, world!\n")); | |
20 }); | |
21 | |
22 test("combines multiple prints", () { | |
23 shouldPass(() { | |
24 print("Hello"); | |
25 print("World!"); | |
26 }, prints("Hello\nWorld!\n")); | |
Bob Nystrom
2014/12/05 18:14:53
Are the line endings the same on Windows?
nweiz
2014/12/09 01:01:01
I think so. I figure it's easier to test on the bo
| |
27 }); | |
28 | |
29 test("works with a Matcher", () { | |
30 shouldPass(() => print("Hello, world!"), prints(contains("Hello"))); | |
31 }); | |
32 | |
33 test("describes a failure nicely", () { | |
34 shouldFail(() => print("Hello, world!"), prints("Goodbye, world!\n"), | |
35 "Expected: prints 'Goodbye, world!\\n' ''" | |
36 " Actual: <Closure: () => dynamic> " | |
37 " Which: printed 'Hello, world!\\n' ''" | |
38 " Which: is different. " | |
39 "Expected: Goodbye, w ... " | |
40 " Actual: Hello, wor ... " | |
41 " ^ Differ at offset 0"); | |
42 }); | |
43 | |
44 test("describes a failure with a non-descriptive Matcher nicely", () { | |
45 shouldFail(() => print("Hello, world!"), prints(contains("Goodbye")), | |
46 "Expected: prints contains 'Goodbye'" | |
47 " Actual: <Closure: () => dynamic> " | |
48 " Which: printed 'Hello, world!\\n' ''"); | |
49 }); | |
50 | |
51 test("describes a failure with no text nicely", () { | |
52 shouldFail(() {}, prints(contains("Goodbye")), | |
53 "Expected: prints contains 'Goodbye'" | |
54 " Actual: <Closure: () => dynamic> " | |
55 " Which: printed nothing."); | |
56 }); | |
57 }); | |
58 | |
59 group('asynchronous', () { | |
60 test("passes with an expected print", () { | |
61 shouldPass(() => new Future(() => print("Hello, world!")), | |
62 prints("Hello, world!\n")); | |
63 }); | |
64 | |
65 test("combines multiple prints", () { | |
66 shouldPass(() => new Future(() { | |
67 print("Hello"); | |
68 print("World!"); | |
69 }), prints("Hello\nWorld!\n")); | |
70 }); | |
71 | |
72 test("works with a Matcher", () { | |
73 shouldPass(() => new Future(() => print("Hello, world!")), | |
74 prints(contains("Hello"))); | |
75 }); | |
76 | |
77 test("describes a failure nicely", () { | |
78 shouldFail(() => new Future(() => print("Hello, world!")), | |
79 prints("Goodbye, world!\n"), | |
80 "Expected: 'Goodbye, world!\\n' ''" | |
81 " Actual: 'Hello, world!\\n' ''" | |
82 " Which: is different. " | |
83 "Expected: Goodbye, w ... " | |
84 " Actual: Hello, wor ... " | |
85 " ^ Differ at offset 0", | |
86 isAsync: true); | |
87 }); | |
88 | |
89 test("describes a failure with a non-descriptive Matcher nicely", () { | |
90 shouldFail(() => new Future(() => print("Hello, world!")), | |
91 prints(contains("Goodbye")), | |
92 "Expected: contains 'Goodbye'" | |
93 " Actual: 'Hello, world!\\n' ''", | |
94 isAsync: true); | |
95 }); | |
96 | |
97 test("describes a failure with no text nicely", () { | |
98 shouldFail(() => new Future.value(), prints(contains("Goodbye")), | |
99 "Expected: contains 'Goodbye'" | |
100 " Actual: ''", | |
101 isAsync: true); | |
102 }); | |
103 }); | |
104 } | |
OLD | NEW |