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

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

Issue 10824276: Register toString dynamic invocation in the presence of string interpolation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
Index: tests/compiler/dart2js/resolver_test.dart
diff --git a/tests/compiler/dart2js/resolver_test.dart b/tests/compiler/dart2js/resolver_test.dart
index b6044da86b667d5cab6eff2c330124f813c8201e..d6b1043dc0d71c400598f42d223f359e6e7bce7d 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -2,8 +2,11 @@
// 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.
+#import('dart:uri');
+
#import("../../../lib/compiler/implementation/leg.dart");
#import("../../../lib/compiler/implementation/elements/elements.dart");
+#import('../../../lib/compiler/implementation/source_file.dart');
#import("../../../lib/compiler/implementation/tree/tree.dart");
#import("../../../lib/compiler/implementation/util/util.dart");
#import("mock_compiler.dart");
@@ -69,6 +72,7 @@ main() {
testThis();
testSuperCalls();
testTypeVariables();
+ testToString();
}
testTypeVariables() {
@@ -718,3 +722,24 @@ List<String> asSortedStrings(Link link) {
result.sort((s1, s2) => s1.compareTo(s2));
return result;
}
+
+testToString() {
+ String fileName = 'p.dart';
+ MockCompiler compiler = new MockCompiler();
+ compiler.sourceFiles[fileName] = new SourceFile(
+ fileName,
+ @"class C { toString() => 'C'; } main() { '${new C()}'; }");
ahe 2012/08/13 13:26:55 Why can't this test use compiler.parseScript?
Anton Muhin 2012/08/13 13:49:42 Something like this: testToString() { MockCompi
ahe 2012/08/13 15:05:56 Try: compiler.parseScript("class C { toString() =
+
+ final mainApp = compiler.scanner.loadLibrary(new Uri(fileName), null);
+ final Element main = mainApp.find(buildSourceString('main'));
+ compiler.phase = Compiler.PHASE_RESOLVING;
+ compiler.processQueue(compiler.enqueuer.resolution, main);
+
+ ClassElement classC = mainApp.find(buildSourceString('C'));
+ Element toStringMethod =
+ classC.lookupLocalMember(buildSourceString('toString'));
+ Expect.isNotNull(toStringMethod);
+
+ final resolvedElements = compiler.enqueuer.resolution.resolvedElements;
+ Expect.isTrue(resolvedElements.containsKey(toStringMethod));
+}

Powered by Google App Engine
This is Rietveld 408576698