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

Unified Diff: tests/compiler/dart2js/simple_inferrer_callers_test.dart

Issue 23956007: Fix bug in inferrer for the computation of callers: we need to keep track of what is the called nod… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | « sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/simple_inferrer_callers_test.dart
===================================================================
--- tests/compiler/dart2js/simple_inferrer_callers_test.dart (revision 0)
+++ tests/compiler/dart2js/simple_inferrer_callers_test.dart (revision 0)
@@ -0,0 +1,53 @@
+// 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.
+
+// Test that computation of callers of an element works when two
+// elements of the same name are being invoked in the same method.
+
+import 'package:expect/expect.dart';
+import "package:async_helper/async_helper.dart";
+import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart';
+import '../../../sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart';
+
+import 'compiler_helper.dart';
+import 'parser_helper.dart';
+
+const String TEST = """
+class A {
+ var field;
+}
+
+class B {
+ var field;
+}
+
+main() {
+ new A().field;
+ new B().field;
+}
+""";
+
+// Create our own type inferrer to avoid clearing out the internal
+// data structures.
+class MyInferrer extends SimpleTypesInferrer {
+ MyInferrer(compiler) : super(compiler);
+ clear() {}
+}
+
+void main() {
+ Uri uri = new Uri(scheme: 'source');
+ var compiler = compilerFor(TEST, uri);
+ var inferrer = new MyInferrer(compiler);
+ compiler.typesTask.typesInferrer = inferrer;
+ asyncTest(() => compiler.runCompiler(uri).then((_) {
+ var mainElement = findElement(compiler, 'main');
+ var classA = findElement(compiler, 'A');
+ var fieldA = classA.lookupLocalMember(buildSourceString('field'));
+ var classB = findElement(compiler, 'B');
+ var fieldB = classB.lookupLocalMember(buildSourceString('field'));;
+
+ Expect.isTrue(inferrer.getCallersOf(fieldA).contains(mainElement));
+ Expect.isTrue(inferrer.getCallersOf(fieldB).contains(mainElement));
+ }));
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698