Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: pkg/analyzer/test/reflective_tests.dart

Issue 1607103003: Tweak reflective_tests _invokeSymbolIfExists to not swallow exceptions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 analyzer.test.reflective_tests; 5 library analyzer.test.reflective_tests;
6 6
7 @MirrorsUsed(metaTargets: 'ReflectiveTest') 7 @MirrorsUsed(metaTargets: 'ReflectiveTest')
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 solo_test(memberName, () { 66 solo_test(memberName, () {
67 return _runFailingTest(classMirror, symbol); 67 return _runFailingTest(classMirror, symbol);
68 }); 68 });
69 } 69 }
70 }); 70 });
71 }); 71 });
72 } 72 }
73 73
74 Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) { 74 Future _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
75 var invocationResult = null; 75 var invocationResult = null;
76 InstanceMirror closure;
76 try { 77 try {
77 invocationResult = instanceMirror.invoke(symbol, []).reflectee; 78 closure = instanceMirror.getField(symbol);
Jennifer Messerly 2016/01/19 23:53:54 Basically, we get the tearoff: https://api.dartlan
78 } on NoSuchMethodError {} 79 } on NoSuchMethodError {}
79 if (invocationResult is Future) { 80
80 return invocationResult; 81 if (closure is ClosureMirror) {
81 } else { 82 invocationResult = closure.apply([]).reflectee;
82 return new Future.value(invocationResult);
83 } 83 }
84 return new Future.value(invocationResult);
84 } 85 }
85 86
86 /** 87 /**
87 * Run a test that is expected to fail, and confirm that it fails. 88 * Run a test that is expected to fail, and confirm that it fails.
88 * 89 *
89 * This properly handles the following cases: 90 * This properly handles the following cases:
90 * - The test fails by throwing an exception 91 * - The test fails by throwing an exception
91 * - The test returns a future which completes with an error. 92 * - The test returns a future which completes with an error.
92 * 93 *
93 * However, it does not handle the case where the test creates an asynchronous 94 * However, it does not handle the case where the test creates an asynchronous
(...skipping 18 matching lines...) Expand all
112 */ 113 */
113 class ReflectiveTest { 114 class ReflectiveTest {
114 const ReflectiveTest(); 115 const ReflectiveTest();
115 } 116 }
116 117
117 /** 118 /**
118 * A marker annotation used to instruct dart2js to keep reflection information 119 * A marker annotation used to instruct dart2js to keep reflection information
119 * for the annotated classes. 120 * for the annotated classes.
120 */ 121 */
121 const ReflectiveTest reflectiveTest = const ReflectiveTest(); 122 const ReflectiveTest reflectiveTest = const ReflectiveTest();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698