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

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

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

Powered by Google App Engine
This is Rietveld 408576698