| Index: tests/compiler/dart2js/type_test_helper.dart
|
| diff --git a/tests/compiler/dart2js/type_test_helper.dart b/tests/compiler/dart2js/type_test_helper.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..94faaced6fc73d986ecabb64dd008ee8fa42094c
|
| --- /dev/null
|
| +++ b/tests/compiler/dart2js/type_test_helper.dart
|
| @@ -0,0 +1,50 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +library type_test_helper;
|
| +
|
| +import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
|
| +import "compiler_helper.dart";
|
| +
|
| +InterfaceType instantiate(ClassElement element, List<DartType> arguments) {
|
| + return new InterfaceType(element, new Link<DartType>.fromList(arguments));
|
| +}
|
| +
|
| +class TypeEnvironment {
|
| + final MockCompiler compiler;
|
| +
|
| + factory TypeEnvironment(String source) {
|
| + var uri = new Uri.fromComponents(scheme: 'source');
|
| + MockCompiler compiler = compilerFor('''
|
| + main() {}
|
| + $source''',
|
| + uri);
|
| + compiler.runCompiler(uri);
|
| + return new TypeEnvironment._(compiler);
|
| + }
|
| +
|
| + TypeEnvironment._(MockCompiler this.compiler);
|
| +
|
| + Element getElement(String name) {
|
| + var element = findElement(compiler, name);
|
| + Expect.isNotNull(element);
|
| + if (identical(element.kind, ElementKind.CLASS)) {
|
| + element.ensureResolved(compiler);
|
| + }
|
| + return element;
|
| + }
|
| +
|
| + DartType getElementType(String name) {
|
| + return getElement(name).computeType(compiler);
|
| + }
|
| +
|
| + DartType operator[] (String name) {
|
| + if (name == 'dynamic') return compiler.types.dynamicType;
|
| + return getElementType(name);
|
| + }
|
| +
|
| + bool isSubtype(DartType T, DartType S) {
|
| + return compiler.types.isSubtype(T, S);
|
| + }
|
| +}
|
|
|