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

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

Issue 2944843002: All strong mode cleaning of dart2js. (Closed)
Patch Set: More issues discovered during testing. Created 3 years, 6 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 Expect.equals('[ B, L1, A, J2, J1, I2, I1, K2, K1, Object ]', 127 Expect.equals('[ B, L1, A, J2, J1, I2, I1, K2, K1, Object ]',
128 classC.allSupertypes.toString()); 128 classC.allSupertypes.toString());
129 }), 129 }),
130 MockCompiler.create((MockCompiler compiler) { 130 MockCompiler.create((MockCompiler compiler) {
131 compiler.parseScript(""" 131 compiler.parseScript("""
132 class X<T> {} 132 class X<T> {}
133 class Foo extends X<Foo> {} 133 class Foo extends X<Foo> {}
134 class Bar extends Foo implements X<Bar> {} 134 class Bar extends Foo implements X<Bar> {}
135 """); 135 """);
136 compiler.resolveStatement("Bar bar;"); 136 compiler.resolveStatement("Bar bar;");
137 LibraryElement mainApp = compiler.mainApp;
138 ClassElement classBar = mainApp.find("Bar");
139 DiagnosticCollector collector = compiler.diagnosticCollector; 137 DiagnosticCollector collector = compiler.diagnosticCollector;
140 Expect.equals(0, collector.warnings.length); 138 Expect.equals(0, collector.warnings.length);
141 Expect.equals(1, collector.errors.length); 139 Expect.equals(1, collector.errors.length);
142 Expect.equals( 140 Expect.equals(
143 MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind); 141 MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind);
144 Expect.equals(0, collector.crashes.length); 142 Expect.equals(0, collector.crashes.length);
145 }), 143 }),
146 ]); 144 ]);
147 } 145 }
148 146
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 ResolverVisitor visitor = new ResolverVisitor( 280 ResolverVisitor visitor = new ResolverVisitor(
283 compiler.resolution, 281 compiler.resolution,
284 funElement, 282 funElement,
285 new ResolutionRegistry( 283 new ResolutionRegistry(
286 compiler.backend.target, new CollectingTreeElements(funElement)), 284 compiler.backend.target, new CollectingTreeElements(funElement)),
287 scope: new MockTypeVariablesScope(fooElement.buildScope())); 285 scope: new MockTypeVariablesScope(fooElement.buildScope()));
288 FunctionExpression function = 286 FunctionExpression function =
289 (funElement as FunctionElementX).parseNode(compiler.parsingContext); 287 (funElement as FunctionElementX).parseNode(compiler.parsingContext);
290 visitor.visit(function.body); 288 visitor.visit(function.body);
291 Map mapping = map(visitor); 289 Map mapping = map(visitor);
292 List<Element> values = mapping.values.toList();
293 DiagnosticCollector collector = compiler.diagnosticCollector; 290 DiagnosticCollector collector = compiler.diagnosticCollector;
294 Expect.equals(0, mapping.length); 291 Expect.equals(0, mapping.length);
295 Expect.equals(0, collector.warnings.length); 292 Expect.equals(0, collector.warnings.length);
296 }), 293 }),
297 MockCompiler.create((MockCompiler compiler) { 294 MockCompiler.create((MockCompiler compiler) {
298 compiler.resolveStatement("main() { return this; }"); 295 compiler.resolveStatement("main() { return this; }");
299 DiagnosticCollector collector = compiler.diagnosticCollector; 296 DiagnosticCollector collector = compiler.diagnosticCollector;
300 Expect.equals(0, collector.warnings.length); 297 Expect.equals(0, collector.warnings.length);
301 Expect.equals(1, collector.errors.length); 298 Expect.equals(1, collector.errors.length);
302 Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, 299 Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE,
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 Expect.equals( 618 Expect.equals(
622 new Message(MessageTemplate.TEMPLATES[MessageKind.CANNOT_RESOLVE_TYPE], 619 new Message(MessageTemplate.TEMPLATES[MessageKind.CANNOT_RESOLVE_TYPE],
623 {'typeName': 'bar'}, false), 620 {'typeName': 'bar'}, false),
624 collector.errors.first.message); 621 collector.errors.first.message);
625 collector.clear(); 622 collector.clear();
626 623
627 // Add the abstract class to the world and make sure everything is setup 624 // Add the abstract class to the world and make sure everything is setup
628 // correctly. 625 // correctly.
629 compiler.parseScript("abstract class Bar {}"); 626 compiler.parseScript("abstract class Bar {}");
630 627
631 ResolverVisitor visitor = new ResolverVisitor(
632 compiler.resolution,
633 null,
634 new ResolutionRegistry(
635 compiler.backend.target, new CollectingTreeElements(null)));
636 compiler.resolveStatement("Foo bar;"); 628 compiler.resolveStatement("Foo bar;");
637 629
638 LibraryElement mainApp = compiler.mainApp; 630 LibraryElement mainApp = compiler.mainApp;
639 ClassElement fooElement = mainApp.find('Foo'); 631 ClassElement fooElement = mainApp.find('Foo');
640 ClassElement barElement = mainApp.find('Bar'); 632 ClassElement barElement = mainApp.find('Bar');
641 633
642 Expect.equals(null, barElement.supertype); 634 Expect.equals(null, barElement.supertype);
643 Expect.isTrue(barElement.interfaces.isEmpty); 635 Expect.isTrue(barElement.interfaces.isEmpty);
644 636
645 Expect.equals(barElement.computeType(compiler.resolution), 637 Expect.equals(barElement.computeType(compiler.resolution),
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 functionName: 'm'); 1560 functionName: 'm');
1569 check( 1561 check(
1570 ''' 1562 '''
1571 class A { 1563 class A {
1572 m() => () => await - 3; 1564 m() => () => await - 3;
1573 } 1565 }
1574 main() => new A().m(); 1566 main() => new A().m();
1575 ''', 1567 ''',
1576 className: 'A'); 1568 className: 'A');
1577 } 1569 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/related_types_test.dart ('k') | tests/compiler/dart2js/serialization/duplicate_library_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698