Index: tests/compiler/dart2js/type_mask2_test.dart |
diff --git a/tests/compiler/dart2js/type_mask2_test.dart b/tests/compiler/dart2js/type_mask2_test.dart |
index 03db5802e1599e2bf63fb558f39237b427076cf7..648cf7649731618cbcbcc90473922c3d436650f0 100644 |
--- a/tests/compiler/dart2js/type_mask2_test.dart |
+++ b/tests/compiler/dart2js/type_mask2_test.dart |
@@ -8,11 +8,9 @@ import 'dart:async'; |
import 'package:expect/expect.dart'; |
import 'package:async_helper/async_helper.dart'; |
import 'type_test_helper.dart'; |
-import 'package:compiler/src/elements/elements.dart' |
- show Element, ClassElement; |
+import 'package:compiler/src/elements/elements.dart' show Element, ClassElement; |
import 'package:compiler/src/types/types.dart'; |
-import 'package:compiler/src/world.dart' show |
- ClassWorld; |
+import 'package:compiler/src/world.dart' show ClassWorld; |
isCheckedMode() { |
try { |
@@ -31,13 +29,12 @@ void main() { |
}); |
} |
-checkMasks(ClassWorld classWorld, |
- List<ClassElement> allClasses, |
- List<FlatTypeMask> masks, |
- {FlatTypeMask result, |
- List<FlatTypeMask> disjointMasks, |
- FlatTypeMask flattened, |
- List<ClassElement> containedClasses}) { |
+checkMasks(ClassWorld classWorld, List<ClassElement> allClasses, |
+ List<FlatTypeMask> masks, |
+ {FlatTypeMask result, |
+ List<FlatTypeMask> disjointMasks, |
+ FlatTypeMask flattened, |
+ List<ClassElement> containedClasses}) { |
List<FlatTypeMask> disjoint = <FlatTypeMask>[]; |
UnionTypeMask.unionOfHelper(masks, disjoint, classWorld); |
Expect.listEquals(disjointMasks, disjoint, |
@@ -47,14 +44,16 @@ checkMasks(ClassWorld classWorld, |
// behaviour in unchecked mode is not defined and thus cannot be |
// reliably tested. |
if (isCheckedMode()) { |
- Expect.throws(() => UnionTypeMask.flatten(disjoint, classWorld), |
- (e) => e is AssertionError, |
- 'Expect assertion failure on flattening of $disjoint.'); |
+ Expect.throws( |
+ () => UnionTypeMask.flatten(disjoint, classWorld), |
+ (e) => e is AssertionError, |
+ 'Expect assertion failure on flattening of $disjoint.'); |
} |
} else { |
- TypeMask flattenResult = |
- UnionTypeMask.flatten(disjoint, classWorld); |
- Expect.equals(flattened, flattenResult, |
+ TypeMask flattenResult = UnionTypeMask.flatten(disjoint, classWorld); |
+ Expect.equals( |
+ flattened, |
+ flattenResult, |
'Unexpected flattening of $disjoint: ' |
'$flattenResult, expected $flattened.'); |
} |
@@ -62,12 +61,14 @@ checkMasks(ClassWorld classWorld, |
if (result == null) { |
Expect.isTrue(union is UnionTypeMask, |
'Expected union of $masks to be a union-type: $union.'); |
- Expect.listEquals(disjointMasks, union.disjointMasks, |
+ Expect.listEquals( |
+ disjointMasks, |
+ union.disjointMasks, |
'Unexpected union masks: ' |
'${union.disjointMasks}, expected $disjointMasks.'); |
} else { |
- Expect.equals(result, union, |
- 'Unexpected union of $masks: $union, expected $result.'); |
+ Expect.equals( |
+ result, union, 'Unexpected union of $masks: $union, expected $result.'); |
} |
if (containedClasses != null) { |
for (ClassElement cls in allClasses) { |
@@ -79,13 +80,13 @@ checkMasks(ClassWorld classWorld, |
'$union not expected to contain $cls.'); |
} |
} |
- |
} |
return union; |
} |
-Future testUnionTypeMaskFlatten() async { |
- TypeEnvironment env = await TypeEnvironment.create(r""" |
+Future testUnionTypeMaskFlatten() async { |
+ TypeEnvironment env = await TypeEnvironment.create( |
+ r""" |
class A {} |
class B {} |
class C extends A {} |
@@ -115,14 +116,11 @@ Future testUnionTypeMaskFlatten() async { |
List<ClassElement> allClasses = <ClassElement>[Object_, A, B, C, D, E]; |
check(List<FlatTypeMask> masks, |
- {FlatTypeMask result, |
- List<FlatTypeMask> disjointMasks, |
- FlatTypeMask flattened, |
- List<ClassElement> containedClasses}) { |
- return checkMasks( |
- classWorld, |
- allClasses, |
- masks, |
+ {FlatTypeMask result, |
+ List<FlatTypeMask> disjointMasks, |
+ FlatTypeMask flattened, |
+ List<ClassElement> containedClasses}) { |
+ return checkMasks(classWorld, allClasses, masks, |
result: result, |
disjointMasks: disjointMasks, |
flattened: flattened, |
@@ -140,80 +138,71 @@ Future testUnionTypeMaskFlatten() async { |
TypeMask exactD = new TypeMask.nonNullExact(D, classWorld); |
TypeMask exactE = new TypeMask.nonNullExact(E, classWorld); |
- check([], |
- result: empty, |
- disjointMasks: [], |
- containedClasses: []); |
+ check([], result: empty, disjointMasks: [], containedClasses: []); |
check([exactA], |
- result: exactA, |
- disjointMasks: [exactA], |
- containedClasses: [A]); |
+ result: exactA, disjointMasks: [exactA], containedClasses: [A]); |
check([exactA, exactA], |
- result: exactA, |
- disjointMasks: [exactA], |
- containedClasses: [A]); |
+ result: exactA, disjointMasks: [exactA], containedClasses: [A]); |
check([exactA, exactB], |
- disjointMasks: [exactA, exactB], |
- flattened: subclassObject, |
- containedClasses: [A, B]); |
+ disjointMasks: [exactA, exactB], |
+ flattened: subclassObject, |
+ containedClasses: [A, B]); |
check([subclassObject], |
- result: subclassObject, |
- disjointMasks: [subclassObject], |
- containedClasses: [Object_, A, B, C, D, E]); |
+ result: subclassObject, |
+ disjointMasks: [subclassObject], |
+ containedClasses: [Object_, A, B, C, D, E]); |
check([subclassObject, exactA], |
- disjointMasks: [subclassObject], |
- result: subclassObject, |
- containedClasses: [Object_, A, B, C, D, E]); |
+ disjointMasks: [subclassObject], |
+ result: subclassObject, |
+ containedClasses: [Object_, A, B, C, D, E]); |
check([exactA, exactC], |
- disjointMasks: [subclassA], |
- result: subclassA, |
- containedClasses: [A, C]); |
+ disjointMasks: [subclassA], result: subclassA, containedClasses: [A, C]); |
check([exactA, exactB, exactC], |
- disjointMasks: [subclassA, exactB], |
- flattened: subclassObject, |
- containedClasses: [A, B, C]); |
+ disjointMasks: [subclassA, exactB], |
+ flattened: subclassObject, |
+ containedClasses: [A, B, C]); |
check([exactA, exactD], |
- disjointMasks: [subtypeA], |
- result: subtypeA, |
- containedClasses: [A, C, D, E]); |
+ disjointMasks: [subtypeA], |
+ result: subtypeA, |
+ containedClasses: [A, C, D, E]); |
check([exactA, exactB, exactD], |
- disjointMasks: [subtypeA, exactB], |
- flattened: subclassObject, |
- containedClasses: [A, B, C, D, E]); |
+ disjointMasks: [subtypeA, exactB], |
+ flattened: subclassObject, |
+ containedClasses: [A, B, C, D, E]); |
check([exactA, exactE], |
- disjointMasks: [subtypeA], |
- result: subtypeA, |
- containedClasses: [A, C, D, E]); |
+ disjointMasks: [subtypeA], |
+ result: subtypeA, |
+ containedClasses: [A, C, D, E]); |
check([exactA, exactB, exactE], |
- disjointMasks: [subtypeA, exactB], |
- flattened: subclassObject, |
- containedClasses: [A, B, C, D, E]); |
+ disjointMasks: [subtypeA, exactB], |
+ flattened: subclassObject, |
+ containedClasses: [A, B, C, D, E]); |
check([exactB, exactE, exactA], |
- disjointMasks: [subclassB, exactA], |
- flattened: subclassObject, |
- containedClasses: [A, B, E]); |
+ disjointMasks: [subclassB, exactA], |
+ flattened: subclassObject, |
+ containedClasses: [A, B, E]); |
check([exactE, exactA, exactB], |
- disjointMasks: [subtypeA, exactB], |
- flattened: subclassObject, |
- containedClasses: [A, B, C, D, E]); |
+ disjointMasks: [subtypeA, exactB], |
+ flattened: subclassObject, |
+ containedClasses: [A, B, C, D, E]); |
check([exactE, exactB, exactA], |
- disjointMasks: [subclassB, exactA], |
- flattened: subclassObject, |
- containedClasses: [A, B, E]); |
+ disjointMasks: [subclassB, exactA], |
+ flattened: subclassObject, |
+ containedClasses: [A, B, E]); |
} |
Future testStringSubtypes() async { |
@@ -224,35 +213,34 @@ Future testStringSubtypes() async { |
} |
""", |
useMockCompiler: false); |
- var classWorld = env.compiler.world; |
- var backend = env.compiler.backend; |
+ var classWorld = env.compiler.world; |
+ var backend = env.compiler.backend; |
- ClassElement Object_ = env.getElement("Object"); |
- ClassElement String_ = env.getElement("String"); |
- ClassElement JSString = backend.helpers.jsStringClass; |
+ ClassElement Object_ = env.getElement("Object"); |
+ ClassElement String_ = env.getElement("String"); |
+ ClassElement JSString = backend.helpers.jsStringClass; |
- List<ClassElement> allClasses = <ClassElement>[Object_, String_]; |
+ List<ClassElement> allClasses = <ClassElement>[Object_, String_]; |
- Expect.isFalse(classWorld.isDirectlyInstantiated(Object_)); |
- Expect.isTrue(classWorld.isIndirectlyInstantiated(Object_)); |
- Expect.isTrue(classWorld.isInstantiated(Object_)); |
+ Expect.isFalse(classWorld.isDirectlyInstantiated(Object_)); |
+ Expect.isTrue(classWorld.isIndirectlyInstantiated(Object_)); |
+ Expect.isTrue(classWorld.isInstantiated(Object_)); |
- Expect.isFalse(classWorld.isDirectlyInstantiated(String_)); |
- Expect.isFalse(classWorld.isIndirectlyInstantiated(String_)); |
- Expect.isFalse(classWorld.isInstantiated(String_)); |
+ Expect.isFalse(classWorld.isDirectlyInstantiated(String_)); |
+ Expect.isFalse(classWorld.isIndirectlyInstantiated(String_)); |
+ Expect.isFalse(classWorld.isInstantiated(String_)); |
- Expect.isTrue(classWorld.isDirectlyInstantiated(JSString)); |
- Expect.isFalse(classWorld.isIndirectlyInstantiated(JSString)); |
- Expect.isTrue(classWorld.isInstantiated(JSString)); |
+ Expect.isTrue(classWorld.isDirectlyInstantiated(JSString)); |
+ Expect.isFalse(classWorld.isIndirectlyInstantiated(JSString)); |
+ Expect.isTrue(classWorld.isInstantiated(JSString)); |
- TypeMask subtypeString = new TypeMask.nonNullSubtype(String_, classWorld); |
- TypeMask exactJSString = new TypeMask.nonNullExact(JSString, classWorld); |
- TypeMask subtypeJSString = |
- new TypeMask.nonNullSubtype(JSString, classWorld); |
- TypeMask subclassJSString = |
- new TypeMask.nonNullSubclass(JSString, classWorld); |
+ TypeMask subtypeString = new TypeMask.nonNullSubtype(String_, classWorld); |
+ TypeMask exactJSString = new TypeMask.nonNullExact(JSString, classWorld); |
+ TypeMask subtypeJSString = new TypeMask.nonNullSubtype(JSString, classWorld); |
+ TypeMask subclassJSString = |
+ new TypeMask.nonNullSubclass(JSString, classWorld); |
- Expect.equals(exactJSString, subtypeString); |
- Expect.equals(exactJSString, subtypeJSString); |
- Expect.equals(exactJSString, subclassJSString); |
+ Expect.equals(exactJSString, subtypeString); |
+ Expect.equals(exactJSString, subtypeJSString); |
+ Expect.equals(exactJSString, subclassJSString); |
} |