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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:matcher/matcher.dart'; | 7 import 'package:matcher/matcher.dart'; |
8 | 8 |
9 import '../backend/invoker.dart'; | 9 import '../backend/invoker.dart'; |
10 import '../utils.dart'; | 10 import '../utils.dart'; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 Invoker.current.addOutstandingCallback(); | 51 Invoker.current.addOutstandingCallback(); |
52 // Queue up an asynchronous expectation that validates when the future | 52 // Queue up an asynchronous expectation that validates when the future |
53 // completes. | 53 // completes. |
54 item.then((value) { | 54 item.then((value) { |
55 fail("Expected future to fail, but succeeded with '$value'."); | 55 fail("Expected future to fail, but succeeded with '$value'."); |
56 }, onError: (error, trace) { | 56 }, onError: (error, trace) { |
57 if (_matcher == null) return; | 57 if (_matcher == null) return; |
58 | 58 |
59 var reason; | 59 var reason; |
60 if (trace != null) { | 60 if (trace != null) { |
61 var stackTrace = terseChain(trace, | 61 var chain = terseChain(trace, |
62 verbose: Invoker.current.liveTest.test.metadata.verboseTrace); | 62 verbose: Invoker.current.liveTest.test.metadata.verboseTrace); |
63 stackTrace = " ${stackTrace.toString().replaceAll("\n", "\n ")}"; | 63 reason = "Actual exception trace:\n" |
64 reason = "Actual exception trace:\n$stackTrace"; | 64 " ${chain.toString().replaceAll("\n", "\n ")}"; |
65 } | 65 } |
66 | 66 |
67 // Re-run [expect] to get the proper formatting. | 67 // Re-run [expect] to get the proper formatting. |
68 expect(() => throw error, this, reason: reason); | 68 expect(() => throw error, this, reason: reason); |
69 }).then((_) => Invoker.current.removeOutstandingCallback()); | 69 }).then((_) => Invoker.current.removeOutstandingCallback()); |
70 // It hasn't failed yet. | 70 // It hasn't failed yet. |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 try { | 74 try { |
(...skipping 27 matching lines...) Expand all Loading... |
102 mismatchDescription | 102 mismatchDescription |
103 .add('threw ') | 103 .add('threw ') |
104 .addDescriptionOf(matchState['exception']); | 104 .addDescriptionOf(matchState['exception']); |
105 if (verbose) { | 105 if (verbose) { |
106 mismatchDescription.add(' at ').add(matchState['stack'].toString()); | 106 mismatchDescription.add(' at ').add(matchState['stack'].toString()); |
107 } | 107 } |
108 return mismatchDescription; | 108 return mismatchDescription; |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
OLD | NEW |