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

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

Issue 1061043002: Remove union type support from analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/element_test.dart
diff --git a/pkg/analyzer/test/generated/element_test.dart b/pkg/analyzer/test/generated/element_test.dart
index 70509b37ccca629c54ee628cfadc83a8a2ee39d4..7dfddd7ff9a3203ddca818b167e4bbf3f73f6cb2 100644
--- a/pkg/analyzer/test/generated/element_test.dart
+++ b/pkg/analyzer/test/generated/element_test.dart
@@ -29,7 +29,6 @@ main() {
runReflectiveTests(FunctionTypeImplTest);
runReflectiveTests(InterfaceTypeImplTest);
runReflectiveTests(TypeParameterTypeImplTest);
- runReflectiveTests(UnionTypeImplTest);
runReflectiveTests(VoidTypeImplTest);
runReflectiveTests(ClassElementImplTest);
runReflectiveTests(CompilationUnitElementImplTest);
@@ -3750,203 +3749,6 @@ class TypeParameterTypeImplTest extends EngineTestCase {
}
@reflectiveTest
-class UnionTypeImplTest extends EngineTestCase {
- ClassElement _classA;
-
- InterfaceType _typeA;
-
- ClassElement _classB;
-
- InterfaceType _typeB;
-
- DartType _uA;
-
- DartType _uB;
-
- DartType _uAB;
-
- DartType _uBA;
-
- List<DartType> _us;
-
- @override
- void setUp() {
- super.setUp();
- _classA = ElementFactory.classElement2("A");
- _typeA = _classA.type;
- _classB = ElementFactory.classElement("B", _typeA);
- _typeB = _classB.type;
- _uA = UnionTypeImpl.union([_typeA]);
- _uB = UnionTypeImpl.union([_typeB]);
- _uAB = UnionTypeImpl.union([_typeA, _typeB]);
- _uBA = UnionTypeImpl.union([_typeB, _typeA]);
- _us = <DartType>[_uA, _uB, _uAB, _uBA];
- }
-
- void test_emptyUnionsNotAllowed() {
- try {
- UnionTypeImpl.union([]);
- } on IllegalArgumentException {
- return;
- }
- fail("Expected illegal argument exception.");
- }
-
- void test_equality_beingASubtypeOfAnElementIsNotSufficient() {
- // Non-equal if some elements are different
- expect(_uAB == _uA, isFalse);
- }
-
- void test_equality_insertionOrderDoesntMatter() {
- // Insertion order doesn't matter, only sets of elements
- expect(_uAB == _uBA, isTrue);
- expect(_uBA == _uAB, isTrue);
- }
-
- void test_equality_reflexivity() {
- for (DartType u in _us) {
- expect(u == u, isTrue);
- }
- }
-
- void test_equality_singletonsCollapse() {
- expect(_typeA == _uA, isTrue);
- expect(_uA == _typeA, isTrue);
- }
-
- void test_isMoreSpecificThan_allElementsOnLHSAreSubtypesOfSomeElementOnRHS() {
- // Unions are subtypes when all elements are subtypes
- expect(_uAB.isMoreSpecificThan(_uA), isTrue);
- expect(_uAB.isMoreSpecificThan(_typeA), isTrue);
- }
-
- void test_isMoreSpecificThan_element() {
- // Elements of union are sub types
- expect(_typeA.isMoreSpecificThan(_uAB), isTrue);
- expect(_typeB.isMoreSpecificThan(_uAB), isTrue);
- }
-
- void test_isMoreSpecificThan_notSubtypeOfAnyElement() {
- // Types that are not subtypes of elements are not subtypes
- expect(_typeA.isMoreSpecificThan(_uB), isFalse);
- }
-
- void test_isMoreSpecificThan_reflexivity() {
- for (DartType u in _us) {
- expect(u.isMoreSpecificThan(u), isTrue);
- }
- }
-
- void test_isMoreSpecificThan_someElementOnLHSIsNotASubtypeOfAnyElementOnRHS() {
- // Unions are subtypes when some element is a subtype
- expect(_uAB.isMoreSpecificThan(_uB), isTrue);
- expect(_uAB.isMoreSpecificThan(_typeB), isTrue);
- }
-
- void test_isMoreSpecificThan_subtypeOfSomeElement() {
- // Subtypes of elements are sub types
- expect(_typeB.isMoreSpecificThan(_uA), isTrue);
- }
-
- void test_isSubtypeOf_allElementsOnLHSAreSubtypesOfSomeElementOnRHS() {
- // Unions are subtypes when all elements are subtypes
- expect(_uAB.isSubtypeOf(_uA), isTrue);
- expect(_uAB.isSubtypeOf(_typeA), isTrue);
- }
-
- void test_isSubtypeOf_element() {
- // Elements of union are sub types
- expect(_typeA.isSubtypeOf(_uAB), isTrue);
- expect(_typeB.isSubtypeOf(_uAB), isTrue);
- }
-
- void test_isSubtypeOf_notSubtypeOfAnyElement() {
- // Types that are not subtypes of elements are not subtypes
- expect(_typeA.isSubtypeOf(_uB), isFalse);
- }
-
- void test_isSubtypeOf_reflexivity() {
- for (DartType u in _us) {
- expect(u.isSubtypeOf(u), isTrue);
- }
- }
-
- void test_isSubtypeOf_someElementOnLHSIsNotASubtypeOfAnyElementOnRHS() {
- // Unions are subtypes when some element is a subtype
- expect(_uAB.isSubtypeOf(_uB), isTrue);
- expect(_uAB.isSubtypeOf(_typeB), isTrue);
- }
-
- void test_isSubtypeOf_subtypeOfSomeElement() {
- // Subtypes of elements are sub types
- expect(_typeB.isSubtypeOf(_uA), isTrue);
- }
-
- void test_nestedUnionsCollapse() {
- UnionType u = UnionTypeImpl.union([_uAB, _typeA]) as UnionType;
- for (DartType t in u.elements) {
- if (t is UnionType) {
- fail("Expected only non-union types but found $t!");
- }
- }
- }
-
- void test_noLossage() {
- UnionType u = UnionTypeImpl
- .union([_typeA, _typeB, _typeB, _typeA, _typeB, _typeB]) as UnionType;
- Set<DartType> elements = u.elements;
- expect(elements.contains(_typeA), isTrue);
- expect(elements.contains(_typeB), isTrue);
- expect(elements.length == 2, isTrue);
- }
-
- void test_substitute() {
- // Based on [InterfaceTypeImplTest.test_substitute_equal].
- ClassElement classAE = ElementFactory.classElement2("A", ["E"]);
- InterfaceType typeAE = classAE.type;
- List<DartType> args = [_typeB];
- List<DartType> params = [classAE.typeParameters[0].type];
- DartType typeAESubbed = typeAE.substitute2(args, params);
- expect(typeAE == typeAESubbed, isFalse);
- expect(UnionTypeImpl.union([_typeA, typeAESubbed]),
- UnionTypeImpl.union([_typeA, typeAE]).substitute2(args, params));
- }
-
- void test_toString_pair() {
- String s = _uAB.toString();
- expect(s == "{A,B}" || s == "{B,A}", isTrue);
- expect(_uAB.displayName, s);
- }
-
- void test_toString_singleton() {
- // Singleton unions collapse to the the single type.
- expect(_uA.toString(), "A");
- }
-
- void test_unionTypeIsLessSpecificThan_function() {
- // Based on
- // [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArgs].
- ClassElement a = ElementFactory.classElement2("A");
- FunctionType t =
- ElementFactory.functionElement6("t", null, <ClassElement>[a]).type;
- DartType uAT = UnionTypeImpl.union([_uA, t]);
- expect(t.isMoreSpecificThan(uAT), isTrue);
- expect(t.isMoreSpecificThan(_uAB), isFalse);
- }
-
- void test_unionTypeIsSuperTypeOf_function() {
- // Based on
- // [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArgs].
- ClassElement a = ElementFactory.classElement2("A");
- FunctionType t =
- ElementFactory.functionElement6("t", null, <ClassElement>[a]).type;
- DartType uAT = UnionTypeImpl.union([_uA, t]);
- expect(t.isSubtypeOf(uAT), isTrue);
- expect(t.isSubtypeOf(_uAB), isFalse);
- }
-}
-
-@reflectiveTest
class VoidTypeImplTest extends EngineTestCase {
/**
* Reference {code VoidTypeImpl.getInstance()}.
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698