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

Unified Diff: tests/lib/mirrors/mirrors_nsm_test.dart

Issue 195793013: Add support for closure calls through getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix status file and remove bad type.wq Created 6 years, 8 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/lib/mirrors/invoke_closurization_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/mirrors_nsm_test.dart
diff --git a/tests/lib/mirrors/mirrors_nsm_test.dart b/tests/lib/mirrors/mirrors_nsm_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..88ad27c468b5c59a6cee3236fe333233946c181e
--- /dev/null
+++ b/tests/lib/mirrors/mirrors_nsm_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2011, 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 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+bool isNSMContainingFieldName(e, String fieldName, bool isSetter) {
+ print(e);
+ if (e is! NoSuchMethodError) return false;
+ String needle = fieldName;
+ if (isSetter) needle += "=";
+ return "$e".contains(needle) && ! "$e".contains(needle + "=");
+}
+
+class A {}
+
+main() {
+ var mirrors = currentMirrorSystem();
+ var libMirror = mirrors.findLibrary(#MirrorsTest);
+ Expect.throws(() => libMirror.invoke(#foo, []),
+ (e) => isNSMContainingFieldName(e, "foo", false));
+ Expect.throws(() => libMirror.getField(#foo),
+ (e) => isNSMContainingFieldName(e, "foo", false));
+ Expect.throws(() => libMirror.setField(#foo, null), /// vm: ok
+ (e) => isNSMContainingFieldName(e, "foo", true)); /// vm: continued
+
+ var classMirror = reflect(A);
+ Expect.throws(() => classMirror.invoke(#foo, []),
+ (e) => isNSMContainingFieldName(e, "foo", false));
+ Expect.throws(() => classMirror.getField(#foo),
+ (e) => isNSMContainingFieldName(e, "foo", false));
+ Expect.throws(() => classMirror.setField(#foo, null),
+ (e) => isNSMContainingFieldName(e, "foo", true));
+
+ var instanceMirror = reflect(new A());
+ Expect.throws(() => instanceMirror.invoke(#foo, []),
+ (e) => isNSMContainingFieldName(e, "foo", false));
+ Expect.throws(() => instanceMirror.getField(#foo),
+ (e) => isNSMContainingFieldName(e, "foo", false));
+ Expect.throws(() => instanceMirror.setField(#foo, null),
+ (e) => isNSMContainingFieldName(e, "foo", true));
+
+}
« no previous file with comments | « tests/lib/mirrors/invoke_closurization_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698