| Index: pkg/analyzer/test/reflective_tests.dart
|
| diff --git a/pkg/analyzer/test/reflective_tests.dart b/pkg/analyzer/test/reflective_tests.dart
|
| index ec90c28acef2125322660103a48745b25547fb6b..a48c962f95fd4155f539008c60b4aa0d0c4591bd 100644
|
| --- a/pkg/analyzer/test/reflective_tests.dart
|
| +++ b/pkg/analyzer/test/reflective_tests.dart
|
| @@ -49,11 +49,22 @@ void runReflectiveTests(Type type) {
|
| return _runTest(classMirror, symbol);
|
| });
|
| }
|
| + // fail_test_
|
| + if (memberName.startsWith('fail_')) {
|
| + test(memberName, () {
|
| + return _runFailingTest(classMirror, symbol);
|
| + });
|
| + }
|
| + // solo_fail_test_
|
| + if (memberName.startsWith('solo_fail_')) {
|
| + solo_test(memberName, () {
|
| + return _runFailingTest(classMirror, symbol);
|
| + });
|
| + }
|
| });
|
| });
|
| }
|
|
|
| -
|
| Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
|
| var invocationResult = null;
|
| try {
|
| @@ -68,6 +79,23 @@ Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
|
| }
|
|
|
|
|
| +/**
|
| + * Run a test that is expected to fail, and confirm that it fails.
|
| + *
|
| + * This properly handles the following cases:
|
| + * - The test fails by throwing an exception
|
| + * - The test returns a future which completes with an error.
|
| + *
|
| + * However, it does not handle the case where the test creates an asynchronous
|
| + * callback using expectAsync(), and that callback generates a failure.
|
| + */
|
| +Future _runFailingTest(ClassMirror classMirror, Symbol symbol) {
|
| + return new Future(() => _runTest(classMirror, symbol)).then((_) {
|
| + fail('Test passed - expected to fail.');
|
| + }, onError: (_) {});
|
| +}
|
| +
|
| +
|
| _runTest(ClassMirror classMirror, Symbol symbol) {
|
| InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(''), []);
|
| return _invokeSymbolIfExists(
|
|
|