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

Unified Diff: tests/compiler/dart2js_extra/mirrors_used_closure_test.dart

Issue 217963002: Allow getField of methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address typo-comment. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js_extra/dart2js_extra.status ('k') | tests/lib/lib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_extra/mirrors_used_closure_test.dart
diff --git a/tests/compiler/dart2js_extra/mirrors_used_closure_test.dart b/tests/compiler/dart2js_extra/mirrors_used_closure_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..28c19a81be33c4a4251cf0a96f78928f5bc2968c
--- /dev/null
+++ b/tests/compiler/dart2js_extra/mirrors_used_closure_test.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2014, 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 MirrorsTest;
+
+import 'package:expect/expect.dart';
+
+@MirrorsUsed(targets: const ['A.foo', 'B.bar'])
+import 'dart:mirrors';
+
+class A {
+ foo() => 42;
+ bar() => 499;
+}
+
+class B {
+ bar() => 33;
+}
+
+// Uses DateTime.now to make it impossible to predict.
+// Uses recursive call to make it harder to inline.
+confuse(x) {
+ if (new DateTime.now().millisecondsSinceEpoch == 42) return confuse(x + 1);
+ return x;
+}
+
+main() {
+ var f = [new A(), new B()][confuse(0)].bar;
+ Expect.throws(() => reflect(f).invoke(#call, [], {}),
+ (e) => e is UnsupportedError);
+}
« no previous file with comments | « tests/compiler/dart2js_extra/dart2js_extra.status ('k') | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698