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

Side by Side Diff: tests/compiler/dart2js/resolver_test.dart

Issue 10826279: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #import('dart:uri');
6
5 #import("../../../lib/compiler/implementation/leg.dart"); 7 #import("../../../lib/compiler/implementation/leg.dart");
6 #import("../../../lib/compiler/implementation/elements/elements.dart"); 8 #import("../../../lib/compiler/implementation/elements/elements.dart");
7 #import("../../../lib/compiler/implementation/tree/tree.dart"); 9 #import("../../../lib/compiler/implementation/tree/tree.dart");
8 #import("../../../lib/compiler/implementation/util/util.dart"); 10 #import("../../../lib/compiler/implementation/util/util.dart");
11 #import("compiler_helper.dart");
9 #import("mock_compiler.dart"); 12 #import("mock_compiler.dart");
10 #import("parser_helper.dart"); 13 #import("parser_helper.dart");
11 14
12 Node buildIdentifier(String name) => new Identifier(scan(name)); 15 Node buildIdentifier(String name) => new Identifier(scan(name));
13 16
14 Node buildInitialization(String name) => 17 Node buildInitialization(String name) =>
15 parseBodyCode('$name = 1', 18 parseBodyCode('$name = 1',
16 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens)); 19 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens));
17 20
18 createLocals(List variables) { 21 createLocals(List variables) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // testOneInterface(); // Generates unexpected error message. 65 // testOneInterface(); // Generates unexpected error message.
63 // testTwoInterfaces(); // Generates unexpected error message. 66 // testTwoInterfaces(); // Generates unexpected error message.
64 testFunctionExpression(); 67 testFunctionExpression();
65 testNewExpression(); 68 testNewExpression();
66 testTopLevelFields(); 69 testTopLevelFields();
67 testClassHierarchy(); 70 testClassHierarchy();
68 testInitializers(); 71 testInitializers();
69 testThis(); 72 testThis();
70 testSuperCalls(); 73 testSuperCalls();
71 testTypeVariables(); 74 testTypeVariables();
75 testToString();
72 } 76 }
73 77
74 testTypeVariables() { 78 testTypeVariables() {
75 matchResolvedTypes(visitor, text, name, expectedElements) { 79 matchResolvedTypes(visitor, text, name, expectedElements) {
76 VariableDefinitions definition = parseStatement(text); 80 VariableDefinitions definition = parseStatement(text);
77 visitor.visit(definition.type); 81 visitor.visit(definition.type);
78 InterfaceType type = visitor.mapping.getType(definition.type); 82 InterfaceType type = visitor.mapping.getType(definition.type);
79 Expect.equals(definition.type.typeArguments.length(), 83 Expect.equals(definition.type.typeArguments.length(),
80 length(type.arguments)); 84 length(type.arguments));
81 int index = 0; 85 int index = 0;
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1; 718 length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1;
715 719
716 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); 720 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1);
717 721
718 List<String> asSortedStrings(Link link) { 722 List<String> asSortedStrings(Link link) {
719 List<String> result = <String>[]; 723 List<String> result = <String>[];
720 for (; !link.isEmpty(); link = link.tail) result.add(link.head.toString()); 724 for (; !link.isEmpty(); link = link.tail) result.add(link.head.toString());
721 result.sort((s1, s2) => s1.compareTo(s2)); 725 result.sort((s1, s2) => s1.compareTo(s2));
722 return result; 726 return result;
723 } 727 }
728
729 testToString() {
730 Uri uri = new Uri.fromComponents(scheme: 'source');
731 MockCompiler compiler = compilerFor(
732 @"class C { toString() => 'C'; } main() { '${new C()}'; }",
733 uri);
734 compiler.runCompiler(uri);
735
736 Element toStringMethod = findElement(compiler, 'C')
737 .lookupLocalMember(buildSourceString('toString'));
738 Expect.isNotNull(toStringMethod);
739
740 Expect.isNotNull(
741 compiler.enqueuer.resolution.getCachedElements(toStringMethod));
742 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/concrete_type_inference_test.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698