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

Unified Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 853553005: Move the class TypeTestProvider from the test directory into the lib directory so that other tools … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/generated/element_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/resolver_test.dart
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index 823e5275fc9e43168287967936b49130e5b8eac9..380829c002e00bc40d3fc7304f1c6b1ee39e7112 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -23,6 +23,7 @@ import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk;
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/generated/static_type_analyzer.dart';
import 'package:analyzer/src/generated/testing/ast_factory.dart';
+import 'package:analyzer/src/generated/testing/test_type_provider.dart';
import 'package:analyzer/src/generated/testing/element_factory.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:unittest/unittest.dart';
@@ -11115,475 +11116,7 @@ class SubtypeManagerTest extends EngineTestCase {
}
}
-/**
- * Instances of the class `TestTypeProvider` implement a type provider that can be used by
- * tests without creating the element model for the core library.
- */
-class TestTypeProvider implements TypeProvider {
- /**
- * The type representing the built-in type 'bool'.
- */
- InterfaceType _boolType;
-
- /**
- * The type representing the type 'bottom'.
- */
- DartType _bottomType;
-
- /**
- * The type representing the built-in type 'double'.
- */
- InterfaceType _doubleType;
-
- /**
- * The type representing the built-in type 'deprecated'.
- */
- InterfaceType _deprecatedType;
-
- /**
- * The type representing the built-in type 'dynamic'.
- */
- DartType _dynamicType;
-
- /**
- * The type representing the built-in type 'Function'.
- */
- InterfaceType _functionType;
-
- /**
- * The type representing the built-in type 'int'.
- */
- InterfaceType _intType;
-
- /**
- * The type representing the built-in type 'Iterable'.
- */
- InterfaceType _iterableType;
-
- /**
- * The type representing the built-in type 'Iterator'.
- */
- InterfaceType _iteratorType;
-
- /**
- * The type representing the built-in type 'List'.
- */
- InterfaceType _listType;
-
- /**
- * The type representing the built-in type 'Map'.
- */
- InterfaceType _mapType;
-
- /**
- * The type representing the built-in type 'Null'.
- */
- InterfaceType _nullType;
- /**
- * The type representing the built-in type 'num'.
- */
- InterfaceType _numType;
-
- /**
- * The type representing the built-in type 'Object'.
- */
- InterfaceType _objectType;
-
- /**
- * The type representing the built-in type 'StackTrace'.
- */
- InterfaceType _stackTraceType;
-
- /**
- * The type representing the built-in type 'String'.
- */
- InterfaceType _stringType;
-
- /**
- * The type representing the built-in type 'Symbol'.
- */
- InterfaceType _symbolType;
-
- /**
- * The type representing the built-in type 'Type'.
- */
- InterfaceType _typeType;
-
- /**
- * The type representing typenames that can't be resolved.
- */
- DartType _undefinedType;
-
- @override
- InterfaceType get boolType {
- if (_boolType == null) {
- ClassElementImpl boolElement = ElementFactory.classElement2("bool");
- _boolType = boolElement.type;
- ConstructorElementImpl fromEnvironment =
- ElementFactory.constructorElement(boolElement, "fromEnvironment", true);
- fromEnvironment.parameters = <ParameterElement>[
- ElementFactory.requiredParameter2("name", stringType),
- ElementFactory.namedParameter2("defaultValue", _boolType)];
- fromEnvironment.factory = true;
- boolElement.constructors = <ConstructorElement>[fromEnvironment];
- }
- return _boolType;
- }
-
- @override
- DartType get bottomType {
- if (_bottomType == null) {
- _bottomType = BottomTypeImpl.instance;
- }
- return _bottomType;
- }
-
- @override
- InterfaceType get deprecatedType {
- if (_deprecatedType == null) {
- ClassElementImpl deprecatedElement =
- ElementFactory.classElement2("Deprecated");
- deprecatedElement.constructors = <ConstructorElement>[
- ElementFactory.constructorElement(deprecatedElement, null, true, [stringType])];
- _deprecatedType = deprecatedElement.type;
- }
- return _deprecatedType;
- }
-
- @override
- InterfaceType get doubleType {
- if (_doubleType == null) {
- _initializeNumericTypes();
- }
- return _doubleType;
- }
-
- @override
- DartType get dynamicType {
- if (_dynamicType == null) {
- _dynamicType = DynamicTypeImpl.instance;
- }
- return _dynamicType;
- }
-
- @override
- InterfaceType get functionType {
- if (_functionType == null) {
- _functionType = ElementFactory.classElement2("Function").type;
- }
- return _functionType;
- }
-
- @override
- InterfaceType get intType {
- if (_intType == null) {
- _initializeNumericTypes();
- }
- return _intType;
- }
-
- InterfaceType get iterableType {
- if (_iterableType == null) {
- ClassElementImpl iterableElement =
- ElementFactory.classElement2("Iterable", ["E"]);
- _iterableType = iterableElement.type;
- DartType eType = iterableElement.typeParameters[0].type;
- iterableElement.accessors = <PropertyAccessorElement>[
- ElementFactory.getterElement(
- "iterator",
- false,
- iteratorType.substitute4(<DartType>[eType])),
- ElementFactory.getterElement("last", false, eType)];
- _propagateTypeArguments(iterableElement);
- }
- return _iterableType;
- }
-
- InterfaceType get iteratorType {
- if (_iteratorType == null) {
- ClassElementImpl iteratorElement =
- ElementFactory.classElement2("Iterator", ["E"]);
- _iteratorType = iteratorElement.type;
- DartType eType = iteratorElement.typeParameters[0].type;
- iteratorElement.accessors = <PropertyAccessorElement>[
- ElementFactory.getterElement("current", false, eType)];
- _propagateTypeArguments(iteratorElement);
- }
- return _iteratorType;
- }
-
- @override
- InterfaceType get listType {
- if (_listType == null) {
- ClassElementImpl listElement =
- ElementFactory.classElement2("List", ["E"]);
- listElement.constructors =
- <ConstructorElement>[ElementFactory.constructorElement2(listElement, null)];
- _listType = listElement.type;
- DartType eType = listElement.typeParameters[0].type;
- InterfaceType iterableType =
- this.iterableType.substitute4(<DartType>[eType]);
- listElement.interfaces = <InterfaceType>[iterableType];
- listElement.accessors = <PropertyAccessorElement>[
- ElementFactory.getterElement("length", false, intType)];
- listElement.methods = <MethodElement>[
- ElementFactory.methodElement("[]", eType, [intType]),
- ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [intType, eType]),
- ElementFactory.methodElement("add", VoidTypeImpl.instance, [eType])];
- _propagateTypeArguments(listElement);
- }
- return _listType;
- }
-
- @override
- InterfaceType get mapType {
- if (_mapType == null) {
- ClassElementImpl mapElement =
- ElementFactory.classElement2("Map", ["K", "V"]);
- _mapType = mapElement.type;
- DartType kType = mapElement.typeParameters[0].type;
- DartType vType = mapElement.typeParameters[1].type;
- mapElement.accessors = <PropertyAccessorElement>[
- ElementFactory.getterElement("length", false, intType)];
- mapElement.methods = <MethodElement>[
- ElementFactory.methodElement("[]", vType, [objectType]),
- ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [kType, vType])];
- _propagateTypeArguments(mapElement);
- }
- return _mapType;
- }
-
- @override
- InterfaceType get nullType {
- if (_nullType == null) {
- _nullType = ElementFactory.classElement2("Null").type;
- }
- return _nullType;
- }
-
- @override
- InterfaceType get numType {
- if (_numType == null) {
- _initializeNumericTypes();
- }
- return _numType;
- }
-
- @override
- InterfaceType get objectType {
- if (_objectType == null) {
- ClassElementImpl objectElement = ElementFactory.object;
- _objectType = objectElement.type;
- objectElement.constructors =
- <ConstructorElement>[ElementFactory.constructorElement2(objectElement, null)];
- objectElement.methods = <MethodElement>[
- ElementFactory.methodElement("toString", stringType),
- ElementFactory.methodElement("==", boolType, [_objectType]),
- ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType])];
- objectElement.accessors = <PropertyAccessorElement>[
- ElementFactory.getterElement("hashCode", false, intType),
- ElementFactory.getterElement("runtimeType", false, typeType)];
- }
- return _objectType;
- }
-
- @override
- InterfaceType get stackTraceType {
- if (_stackTraceType == null) {
- _stackTraceType = ElementFactory.classElement2("StackTrace").type;
- }
- return _stackTraceType;
- }
-
- @override
- InterfaceType get stringType {
- if (_stringType == null) {
- _stringType = ElementFactory.classElement2("String").type;
- ClassElementImpl stringElement = _stringType.element as ClassElementImpl;
- stringElement.accessors = <PropertyAccessorElement>[
- ElementFactory.getterElement("isEmpty", false, boolType),
- ElementFactory.getterElement("length", false, intType),
- ElementFactory.getterElement(
- "codeUnits",
- false,
- listType.substitute4(<DartType>[intType]))];
- stringElement.methods = <MethodElement>[
- ElementFactory.methodElement("+", _stringType, [_stringType]),
- ElementFactory.methodElement("toLowerCase", _stringType),
- ElementFactory.methodElement("toUpperCase", _stringType)];
- ConstructorElementImpl fromEnvironment =
- ElementFactory.constructorElement(stringElement, "fromEnvironment", true);
- fromEnvironment.parameters = <ParameterElement>[
- ElementFactory.requiredParameter2("name", stringType),
- ElementFactory.namedParameter2("defaultValue", _stringType)];
- fromEnvironment.factory = true;
- stringElement.constructors = <ConstructorElement>[fromEnvironment];
- }
- return _stringType;
- }
-
- @override
- InterfaceType get symbolType {
- if (_symbolType == null) {
- ClassElementImpl symbolClass = ElementFactory.classElement2("Symbol");
- ConstructorElementImpl constructor =
- ElementFactory.constructorElement(symbolClass, null, true, [stringType]);
- constructor.factory = true;
- symbolClass.constructors = <ConstructorElement>[constructor];
- _symbolType = symbolClass.type;
- }
- return _symbolType;
- }
-
- @override
- InterfaceType get typeType {
- if (_typeType == null) {
- _typeType = ElementFactory.classElement2("Type").type;
- }
- return _typeType;
- }
-
- @override
- DartType get undefinedType {
- if (_undefinedType == null) {
- _undefinedType = UndefinedTypeImpl.instance;
- }
- return _undefinedType;
- }
-
- /**
- * Initialize the numeric types. They are created as a group so that we can (a) create the right
- * hierarchy and (b) add members to them.
- */
- void _initializeNumericTypes() {
- //
- // Create the type hierarchy.
- //
- ClassElementImpl numElement = ElementFactory.classElement2("num");
- _numType = numElement.type;
- ClassElementImpl intElement = ElementFactory.classElement("int", _numType);
- _intType = intElement.type;
- ClassElementImpl doubleElement =
- ElementFactory.classElement("double", _numType);
- _doubleType = doubleElement.type;
- //
- // Force the referenced types to be cached.
- //
- objectType;
- boolType;
- stringType;
- //
- // Add the methods.
- //
- numElement.methods = <MethodElement>[
- ElementFactory.methodElement("+", _numType, [_numType]),
- ElementFactory.methodElement("-", _numType, [_numType]),
- ElementFactory.methodElement("*", _numType, [_numType]),
- ElementFactory.methodElement("%", _numType, [_numType]),
- ElementFactory.methodElement("/", _doubleType, [_numType]),
- ElementFactory.methodElement("~/", _numType, [_numType]),
- ElementFactory.methodElement("-", _numType),
- ElementFactory.methodElement("remainder", _numType, [_numType]),
- ElementFactory.methodElement("<", _boolType, [_numType]),
- ElementFactory.methodElement("<=", _boolType, [_numType]),
- ElementFactory.methodElement(">", _boolType, [_numType]),
- ElementFactory.methodElement(">=", _boolType, [_numType]),
- ElementFactory.methodElement("==", _boolType, [_objectType]),
- ElementFactory.methodElement("isNaN", _boolType),
- ElementFactory.methodElement("isNegative", _boolType),
- ElementFactory.methodElement("isInfinite", _boolType),
- ElementFactory.methodElement("abs", _numType),
- ElementFactory.methodElement("floor", _numType),
- ElementFactory.methodElement("ceil", _numType),
- ElementFactory.methodElement("round", _numType),
- ElementFactory.methodElement("truncate", _numType),
- ElementFactory.methodElement("toInt", _intType),
- ElementFactory.methodElement("toDouble", _doubleType),
- ElementFactory.methodElement("toStringAsFixed", _stringType, [_intType]),
- ElementFactory.methodElement("toStringAsExponential", _stringType, [_intType]),
- ElementFactory.methodElement("toStringAsPrecision", _stringType, [_intType]),
- ElementFactory.methodElement("toRadixString", _stringType, [_intType])];
- intElement.methods = <MethodElement>[
- ElementFactory.methodElement("&", _intType, [_intType]),
- ElementFactory.methodElement("|", _intType, [_intType]),
- ElementFactory.methodElement("^", _intType, [_intType]),
- ElementFactory.methodElement("~", _intType),
- ElementFactory.methodElement("<<", _intType, [_intType]),
- ElementFactory.methodElement(">>", _intType, [_intType]),
- ElementFactory.methodElement("-", _intType),
- ElementFactory.methodElement("abs", _intType),
- ElementFactory.methodElement("round", _intType),
- ElementFactory.methodElement("floor", _intType),
- ElementFactory.methodElement("ceil", _intType),
- ElementFactory.methodElement("truncate", _intType),
- ElementFactory.methodElement("toString", _stringType)];
- ConstructorElementImpl fromEnvironment =
- ElementFactory.constructorElement(intElement, "fromEnvironment", true);
- fromEnvironment.parameters = <ParameterElement>[
- ElementFactory.requiredParameter2("name", stringType),
- ElementFactory.namedParameter2("defaultValue", _intType)];
- fromEnvironment.factory = true;
- intElement.constructors = <ConstructorElement>[fromEnvironment];
- List<FieldElement> fields = <FieldElement>[
- ElementFactory.fieldElement("NAN", true, false, true, _doubleType),
- ElementFactory.fieldElement("INFINITY", true, false, true, _doubleType),
- ElementFactory.fieldElement(
- "NEGATIVE_INFINITY",
- true,
- false,
- true,
- _doubleType),
- ElementFactory.fieldElement("MIN_POSITIVE", true, false, true, _doubleType),
- ElementFactory.fieldElement("MAX_FINITE", true, false, true, _doubleType)];
- doubleElement.fields = fields;
- int fieldCount = fields.length;
- List<PropertyAccessorElement> accessors =
- new List<PropertyAccessorElement>(fieldCount);
- for (int i = 0; i < fieldCount; i++) {
- accessors[i] = fields[i].getter;
- }
- doubleElement.accessors = accessors;
- doubleElement.methods = <MethodElement>[
- ElementFactory.methodElement("remainder", _doubleType, [_numType]),
- ElementFactory.methodElement("+", _doubleType, [_numType]),
- ElementFactory.methodElement("-", _doubleType, [_numType]),
- ElementFactory.methodElement("*", _doubleType, [_numType]),
- ElementFactory.methodElement("%", _doubleType, [_numType]),
- ElementFactory.methodElement("/", _doubleType, [_numType]),
- ElementFactory.methodElement("~/", _doubleType, [_numType]),
- ElementFactory.methodElement("-", _doubleType),
- ElementFactory.methodElement("abs", _doubleType),
- ElementFactory.methodElement("round", _doubleType),
- ElementFactory.methodElement("floor", _doubleType),
- ElementFactory.methodElement("ceil", _doubleType),
- ElementFactory.methodElement("truncate", _doubleType),
- ElementFactory.methodElement("toString", _stringType)];
- }
-
- /**
- * Given a class element representing a class with type parameters, propagate those type
- * parameters to all of the accessors, methods and constructors defined for the class.
- *
- * @param classElement the element representing the class with type parameters
- */
- void _propagateTypeArguments(ClassElementImpl classElement) {
- List<DartType> typeArguments =
- TypeParameterTypeImpl.getTypes(classElement.typeParameters);
- for (PropertyAccessorElement accessor in classElement.accessors) {
- FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl;
- functionType.typeArguments = typeArguments;
- }
- for (MethodElement method in classElement.methods) {
- FunctionTypeImpl functionType = method.type as FunctionTypeImpl;
- functionType.typeArguments = typeArguments;
- }
- for (ConstructorElement constructor in classElement.constructors) {
- FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl;
- functionType.typeArguments = typeArguments;
- }
- }
-}
@reflectiveTest
class TypeOverrideManagerTest extends EngineTestCase {
« no previous file with comments | « pkg/analyzer/test/generated/element_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698