Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1; | 715 length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1; |
| 712 | 716 |
| 713 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); | 717 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); |
| 714 | 718 |
| 715 List<String> asSortedStrings(Link link) { | 719 List<String> asSortedStrings(Link link) { |
| 716 List<String> result = <String>[]; | 720 List<String> result = <String>[]; |
| 717 for (; !link.isEmpty(); link = link.tail) result.add(link.head.toString()); | 721 for (; !link.isEmpty(); link = link.tail) result.add(link.head.toString()); |
| 718 result.sort((s1, s2) => s1.compareTo(s2)); | 722 result.sort((s1, s2) => s1.compareTo(s2)); |
| 719 return result; | 723 return result; |
| 720 } | 724 } |
| 725 | |
| 726 testToString() { | |
| 727 Uri uri = new Uri.fromComponents(scheme: 'source'); | |
| 728 MockCompiler compiler = compilerFor( | |
| 729 @"class C { toString() => 'C'; } main() { '${new C()}'; }", | |
| 730 uri); | |
| 731 compiler.runCompiler(uri); | |
| 732 | |
| 733 Element toStringMethod = findElement(compiler, 'C') | |
| 734 .lookupLocalMember(buildSourceString('toString')); | |
| 735 Expect.isNotNull(toStringMethod); | |
| 736 | |
| 737 final resolvedElements = compiler.enqueuer.resolution.resolvedElements; | |
|
ahe
2012/08/13 15:55:53
Please use:
Expect.isNotNull(compiler.enqueuer.re
Anton Muhin
2012/08/13 16:09:14
Done.
| |
| 738 Expect.isTrue(resolvedElements.containsKey(toStringMethod)); | |
| 739 } | |
| OLD | NEW |