| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| library matcher.test_utils; |
| |
| import 'package:unittest/unittest.dart'; |
| |
| void shouldFail(value, Matcher matcher, expected) { |
| var failed = false; |
| try { |
| expect(value, matcher); |
| } on TestFailure catch (err) { |
| failed = true; |
| |
| var _errorString = err.message; |
| |
| if (expected is String) { |
| expect(_errorString, equalsIgnoringWhitespace(expected)); |
| } else { |
| expect(_errorString.replaceAll('\n', ''), expected); |
| } |
| } |
| |
| expect(failed, isTrue, reason: 'Expected to fail.'); |
| } |
| |
| void shouldPass(value, Matcher matcher) { |
| expect(value, matcher); |
| } |
| |
| doesNotThrow() {} |
| doesThrow() { |
| throw 'X'; |
| } |