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