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

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

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library type_test_helper; 5 library type_test_helper;
6 6
7 import 'dart:async';
7 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
8 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; 9 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
9 import "parser_helper.dart" show SourceString; 10 import "parser_helper.dart" show SourceString;
10 import "compiler_helper.dart"; 11 import "compiler_helper.dart";
11 12
12 GenericType instantiate(TypeDeclarationElement element, 13 GenericType instantiate(TypeDeclarationElement element,
13 List<DartType> arguments) { 14 List<DartType> arguments) {
14 if (element.isClass()) { 15 if (element.isClass()) {
15 return new InterfaceType(element, new Link<DartType>.fromList(arguments)); 16 return new InterfaceType(element, new Link<DartType>.fromList(arguments));
16 } else { 17 } else {
17 assert(element.isTypedef()); 18 assert(element.isTypedef());
18 return new TypedefType(element, new Link<DartType>.fromList(arguments)); 19 return new TypedefType(element, new Link<DartType>.fromList(arguments));
19 } 20 }
20 } 21 }
21 22
22 class TypeEnvironment { 23 class TypeEnvironment {
23 final MockCompiler compiler; 24 final MockCompiler compiler;
24 25
25 factory TypeEnvironment(String source) { 26 static Future<TypeEnvironment> create(String source) {
26 var uri = new Uri(scheme: 'source'); 27 var uri = new Uri(scheme: 'source');
27 MockCompiler compiler = compilerFor(''' 28 MockCompiler compiler = compilerFor('''
28 main() {} 29 main() {}
29 $source''', 30 $source''',
30 uri, 31 uri,
31 analyzeAll: true, 32 analyzeAll: true,
32 analyzeOnly: true); 33 analyzeOnly: true);
33 compiler.runCompiler(uri); 34 return compiler.runCompiler(uri).then((_) {
34 return new TypeEnvironment._(compiler); 35 return new TypeEnvironment._(compiler);
36 });
35 } 37 }
36 38
37 TypeEnvironment._(MockCompiler this.compiler); 39 TypeEnvironment._(MockCompiler this.compiler);
38 40
39 Element getElement(String name) { 41 Element getElement(String name) {
40 var element = findElement(compiler, name); 42 var element = findElement(compiler, name);
41 Expect.isNotNull(element); 43 Expect.isNotNull(element);
42 if (element.isClass()) { 44 if (element.isClass()) {
43 element.ensureResolved(compiler); 45 element.ensureResolved(compiler);
44 } else if (element.isTypedef()) { 46 } else if (element.isTypedef()) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 namedParameterNames.addLast(sourceString(name)); 85 namedParameterNames.addLast(sourceString(name));
84 namedParameterTypes.addLast(type); 86 namedParameterTypes.addLast(type);
85 }); 87 });
86 } 88 }
87 FunctionType type = new FunctionType( 89 FunctionType type = new FunctionType(
88 compiler.functionClass, 90 compiler.functionClass,
89 returnType, parameterTypes, optionalParameterTypes, 91 returnType, parameterTypes, optionalParameterTypes,
90 namedParameterNames.toLink(), namedParameterTypes.toLink()); 92 namedParameterNames.toLink(), namedParameterTypes.toLink());
91 } 93 }
92 } 94 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/type_substitution_test.dart ('k') | tests/compiler/dart2js/type_variable_bound_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698