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:async'; | 5 import 'dart:async'; |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 | 7 |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 import 'package:compiler/src/constants/expressions.dart'; | 10 import 'package:compiler/src/constants/expressions.dart'; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 }), | 142 }), |
143 ]); | 143 ]); |
144 } | 144 } |
145 | 145 |
146 Future testTypeVariables() { | 146 Future testTypeVariables() { |
147 matchResolvedTypes(visitor, text, name, expectedElements) { | 147 matchResolvedTypes(visitor, text, name, expectedElements) { |
148 VariableDefinitions definition = parseStatement(text); | 148 VariableDefinitions definition = parseStatement(text); |
149 visitor.visit(definition.type); | 149 visitor.visit(definition.type); |
150 ResolutionInterfaceType type = | 150 ResolutionInterfaceType type = |
151 visitor.registry.mapping.getType(definition.type); | 151 visitor.registry.mapping.getType(definition.type); |
152 NominalTypeAnnotation annotation = definition.type; | |
153 Expect.equals( | 152 Expect.equals( |
154 annotation.typeArguments.slowLength(), type.typeArguments.length); | 153 definition.type.typeArguments.slowLength(), type.typeArguments.length); |
155 int index = 0; | 154 int index = 0; |
156 for (ResolutionDartType argument in type.typeArguments) { | 155 for (ResolutionDartType argument in type.typeArguments) { |
157 Expect.equals(true, index < expectedElements.length); | 156 Expect.equals(true, index < expectedElements.length); |
158 Expect.equals(expectedElements[index], argument.element); | 157 Expect.equals(expectedElements[index], argument.element); |
159 index++; | 158 index++; |
160 } | 159 } |
161 Expect.equals(index, expectedElements.length); | 160 Expect.equals(index, expectedElements.length); |
162 } | 161 } |
163 | 162 |
164 return Future.wait([ | 163 return Future.wait([ |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 }); | 693 }); |
695 } | 694 } |
696 | 695 |
697 Future testTopLevelFields() { | 696 Future testTopLevelFields() { |
698 return MockCompiler.create((MockCompiler compiler) { | 697 return MockCompiler.create((MockCompiler compiler) { |
699 compiler.parseScript("int a;"); | 698 compiler.parseScript("int a;"); |
700 VariableElementX element = compiler.mainApp.find("a"); | 699 VariableElementX element = compiler.mainApp.find("a"); |
701 Expect.equals(ElementKind.FIELD, element.kind); | 700 Expect.equals(ElementKind.FIELD, element.kind); |
702 VariableDefinitions node = | 701 VariableDefinitions node = |
703 element.variables.parseNode(element, compiler.parsingContext); | 702 element.variables.parseNode(element, compiler.parsingContext); |
704 NominalTypeAnnotation annotation = node.type; | 703 Identifier typeName = node.type.typeName; |
705 Identifier typeName = annotation.typeName; | |
706 Expect.equals(typeName.source, 'int'); | 704 Expect.equals(typeName.source, 'int'); |
707 | 705 |
708 compiler.parseScript("var b, c;"); | 706 compiler.parseScript("var b, c;"); |
709 VariableElementX bElement = compiler.mainApp.find("b"); | 707 VariableElementX bElement = compiler.mainApp.find("b"); |
710 VariableElementX cElement = compiler.mainApp.find("c"); | 708 VariableElementX cElement = compiler.mainApp.find("c"); |
711 Expect.equals(ElementKind.FIELD, bElement.kind); | 709 Expect.equals(ElementKind.FIELD, bElement.kind); |
712 Expect.equals(ElementKind.FIELD, cElement.kind); | 710 Expect.equals(ElementKind.FIELD, cElement.kind); |
713 Expect.isTrue(bElement != cElement); | 711 Expect.isTrue(bElement != cElement); |
714 | 712 |
715 VariableDefinitions bNode = | 713 VariableDefinitions bNode = |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 functionName: 'm'); | 1537 functionName: 'm'); |
1540 check( | 1538 check( |
1541 ''' | 1539 ''' |
1542 class A { | 1540 class A { |
1543 m() => () => await - 3; | 1541 m() => () => await - 3; |
1544 } | 1542 } |
1545 main() => new A().m(); | 1543 main() => new A().m(); |
1546 ''', | 1544 ''', |
1547 className: 'A'); | 1545 className: 'A'); |
1548 } | 1546 } |
OLD | NEW |