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

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

Issue 2567133002: Add support for the new function-type syntax. (Closed)
Patch Set: Fixes after rebase. Created 3 years, 10 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
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: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
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;
152 Expect.equals( 153 Expect.equals(
153 definition.type.typeArguments.slowLength(), type.typeArguments.length); 154 annotation.typeArguments.slowLength(), type.typeArguments.length);
154 int index = 0; 155 int index = 0;
155 for (ResolutionDartType argument in type.typeArguments) { 156 for (ResolutionDartType argument in type.typeArguments) {
156 Expect.equals(true, index < expectedElements.length); 157 Expect.equals(true, index < expectedElements.length);
157 Expect.equals(expectedElements[index], argument.element); 158 Expect.equals(expectedElements[index], argument.element);
158 index++; 159 index++;
159 } 160 }
160 Expect.equals(index, expectedElements.length); 161 Expect.equals(index, expectedElements.length);
161 } 162 }
162 163
163 return Future.wait([ 164 return Future.wait([
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 }); 694 });
694 } 695 }
695 696
696 Future testTopLevelFields() { 697 Future testTopLevelFields() {
697 return MockCompiler.create((MockCompiler compiler) { 698 return MockCompiler.create((MockCompiler compiler) {
698 compiler.parseScript("int a;"); 699 compiler.parseScript("int a;");
699 VariableElementX element = compiler.mainApp.find("a"); 700 VariableElementX element = compiler.mainApp.find("a");
700 Expect.equals(ElementKind.FIELD, element.kind); 701 Expect.equals(ElementKind.FIELD, element.kind);
701 VariableDefinitions node = 702 VariableDefinitions node =
702 element.variables.parseNode(element, compiler.parsingContext); 703 element.variables.parseNode(element, compiler.parsingContext);
703 Identifier typeName = node.type.typeName; 704 NominalTypeAnnotation annotation = node.type;
705 Identifier typeName = annotation.typeName;
704 Expect.equals(typeName.source, 'int'); 706 Expect.equals(typeName.source, 'int');
705 707
706 compiler.parseScript("var b, c;"); 708 compiler.parseScript("var b, c;");
707 VariableElementX bElement = compiler.mainApp.find("b"); 709 VariableElementX bElement = compiler.mainApp.find("b");
708 VariableElementX cElement = compiler.mainApp.find("c"); 710 VariableElementX cElement = compiler.mainApp.find("c");
709 Expect.equals(ElementKind.FIELD, bElement.kind); 711 Expect.equals(ElementKind.FIELD, bElement.kind);
710 Expect.equals(ElementKind.FIELD, cElement.kind); 712 Expect.equals(ElementKind.FIELD, cElement.kind);
711 Expect.isTrue(bElement != cElement); 713 Expect.isTrue(bElement != cElement);
712 714
713 VariableDefinitions bNode = 715 VariableDefinitions bNode =
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 functionName: 'm'); 1539 functionName: 'm');
1538 check( 1540 check(
1539 ''' 1541 '''
1540 class A { 1542 class A {
1541 m() => () => await - 3; 1543 m() => () => await - 3;
1542 } 1544 }
1543 main() => new A().m(); 1545 main() => new A().m();
1544 ''', 1546 ''',
1545 className: 'A'); 1547 className: 'A');
1546 } 1548 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698