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

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

Issue 29413003: Fix VM crash when ClosureMirror.findInContext operates on a fake function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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/lib.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/find_in_context_fake_function_test.dart
diff --git a/tests/lib/mirrors/find_in_context_fake_function_test.dart b/tests/lib/mirrors/find_in_context_fake_function_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5ccfaee44f7e6489992b8b993925dd7533e9bd0d
--- /dev/null
+++ b/tests/lib/mirrors/find_in_context_fake_function_test.dart
@@ -0,0 +1,77 @@
+// Copyright (c) 2013, 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.
+
+// Regression test: this used to crash the VM.
+
+library test.find_in_context_fake_function;
+
+import "dart:mirrors";
+import "package:expect/expect.dart";
+
+var topLevelField = 1;
+get topLevelGetter => 2;
+topLevelFunction() => 3;
+
+class FakeFunction1 {
+ var field = 4;
+ get getter => 5;
+ method() => 6;
+ static var staticField = 7;
+ static get staticGetter => 8;
+ staticFunction() => 9;
+ call(x) {
+ var local = x * 2;
+ return local;
+ }
+}
+
+class FakeFunction2 implements Function {
+ var field = 10;
+ get getter => 11;
+ method() => 12;
+ static var staticField = 13;
+ static get staticGetter => 14;
+ staticFunction() => 15;
+ noSuchMethod(msg) {
+ var local = msg.positionalArguments;
+ if (msg.memberName != #call) return super.noSuchMethod(msg);
+ return local.join('+');
+ }
+}
+
+doFindInContext(cm, name, value) {
+ Expect.equals(value,
+ cm.findInContext(name).reflectee);
+}
+dontFindInContext(cm, name) {
+ Expect.isNull(cm.findInContext(name));
+}
+
+main() {
+ ClosureMirror cm = reflect(new FakeFunction1());
+ dontFindInContext(cm, #local);
+ dontFindInContext(cm, const Symbol('this'));
+ dontFindInContext(cm, #field);
+ dontFindInContext(cm, #getter);
+ dontFindInContext(cm, #method);
+ dontFindInContext(cm, #staticField);
+ dontFindInContext(cm, #staticGetter);
+ dontFindInContext(cm, #staticFunction);
+ dontFindInContext(cm, #topLevelField);
+ dontFindInContext(cm, #topLevelGetter);
+ dontFindInContext(cm, #topLevelFunction);
+
+ cm = reflect(new FakeFunction2());
+ dontFindInContext(cm, #local);
+ dontFindInContext(cm, const Symbol('this'));
+ dontFindInContext(cm, #field);
+ dontFindInContext(cm, #getter);
+ dontFindInContext(cm, #method);
+ dontFindInContext(cm, #staticField);
+ dontFindInContext(cm, #staticGetter);
+ dontFindInContext(cm, #staticFunction);
+ dontFindInContext(cm, #topLevelField);
+ dontFindInContext(cm, #topLevelGetter);
+ dontFindInContext(cm, #topLevelFunction);
+}
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698