OLD | NEW |
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'; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 }), prints("Hello\nWorld!\n")); | 72 }), prints("Hello\nWorld!\n")); |
73 }); | 73 }); |
74 | 74 |
75 test("works with a Matcher", () { | 75 test("works with a Matcher", () { |
76 shouldPass(() => new Future(() => print("Hello, world!")), | 76 shouldPass(() => new Future(() => print("Hello, world!")), |
77 prints(contains("Hello"))); | 77 prints(contains("Hello"))); |
78 }); | 78 }); |
79 | 79 |
80 test("describes a failure nicely", () { | 80 test("describes a failure nicely", () { |
81 shouldFail(() => new Future(() => print("Hello, world!")), | 81 shouldFail(() => new Future(() => print("Hello, world!")), |
82 prints("Goodbye, world!\n"), | 82 prints("Goodbye, world!\n"), "Expected: 'Goodbye, world!\\n' ''" |
83 "Expected: 'Goodbye, world!\\n' ''" | |
84 " Actual: 'Hello, world!\\n' ''" | 83 " Actual: 'Hello, world!\\n' ''" |
85 " Which: is different. " | 84 " Which: is different. " |
86 "Expected: Goodbye, w ... " | 85 "Expected: Goodbye, w ... " |
87 " Actual: Hello, wor ... " | 86 " Actual: Hello, wor ... " |
88 " ^ Differ at offset 0", | 87 " ^ Differ at offset 0", isAsync: true); |
89 isAsync: true); | |
90 }); | 88 }); |
91 | 89 |
92 test("describes a failure with a non-descriptive Matcher nicely", () { | 90 test("describes a failure with a non-descriptive Matcher nicely", () { |
93 shouldFail(() => new Future(() => print("Hello, world!")), | 91 shouldFail(() => new Future(() => print("Hello, world!")), |
94 prints(contains("Goodbye")), | 92 prints(contains("Goodbye")), "Expected: contains 'Goodbye'" |
95 "Expected: contains 'Goodbye'" | 93 " Actual: 'Hello, world!\\n' ''", isAsync: true); |
96 " Actual: 'Hello, world!\\n' ''", | |
97 isAsync: true); | |
98 }); | 94 }); |
99 | 95 |
100 test("describes a failure with no text nicely", () { | 96 test("describes a failure with no text nicely", () { |
101 shouldFail(() => new Future.value(), prints(contains("Goodbye")), | 97 shouldFail(() => new Future.value(), prints(contains("Goodbye")), |
102 "Expected: contains 'Goodbye'" | 98 "Expected: contains 'Goodbye'" |
103 " Actual: ''", | 99 " Actual: ''", isAsync: true); |
104 isAsync: true); | |
105 }); | 100 }); |
106 }); | 101 }); |
107 } | 102 } |
OLD | NEW |