OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_mask2_test; | 5 library type_mask2_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
10 import 'type_test_helper.dart'; | 10 import 'type_test_helper.dart'; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } else { | 79 } else { |
80 Expect.isFalse(union.contains(cls, closedWorld), | 80 Expect.isFalse(union.contains(cls, closedWorld), |
81 '$union not expected to contain $cls.'); | 81 '$union not expected to contain $cls.'); |
82 } | 82 } |
83 } | 83 } |
84 } | 84 } |
85 return union; | 85 return union; |
86 } | 86 } |
87 | 87 |
88 Future testUnionTypeMaskFlatten() async { | 88 Future testUnionTypeMaskFlatten() async { |
89 TypeEnvironment env = await TypeEnvironment.create( | 89 TypeEnvironment env = await TypeEnvironment.create(r""" |
90 r""" | |
91 class A {} | 90 class A {} |
92 class B {} | 91 class B {} |
93 class C extends A {} | 92 class C extends A {} |
94 class D implements A {} | 93 class D implements A {} |
95 class E extends B implements A {} | 94 class E extends B implements A {} |
96 """, | 95 """, mainSource: r""" |
97 mainSource: r""" | |
98 main() { | 96 main() { |
99 new A(); | 97 new A(); |
100 new B(); | 98 new B(); |
101 new C(); | 99 new C(); |
102 new D(); | 100 new D(); |
103 new E(); | 101 new E(); |
104 } | 102 } |
105 """, | 103 """, useMockCompiler: false); |
106 useMockCompiler: false); | |
107 | 104 |
108 ClosedWorld closedWorld = env.closedWorld; | 105 ClosedWorld closedWorld = env.closedWorld; |
109 | 106 |
110 ClassElement Object_ = env.getElement("Object"); | 107 ClassElement Object_ = env.getElement("Object"); |
111 ClassElement A = env.getElement("A"); | 108 ClassElement A = env.getElement("A"); |
112 ClassElement B = env.getElement("B"); | 109 ClassElement B = env.getElement("B"); |
113 ClassElement C = env.getElement("C"); | 110 ClassElement C = env.getElement("C"); |
114 ClassElement D = env.getElement("D"); | 111 ClassElement D = env.getElement("D"); |
115 ClassElement E = env.getElement("E"); | 112 ClassElement E = env.getElement("E"); |
116 | 113 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 TypeMask subtypeString = new TypeMask.nonNullSubtype(String_, closedWorld); | 232 TypeMask subtypeString = new TypeMask.nonNullSubtype(String_, closedWorld); |
236 TypeMask exactJSString = new TypeMask.nonNullExact(JSString, closedWorld); | 233 TypeMask exactJSString = new TypeMask.nonNullExact(JSString, closedWorld); |
237 TypeMask subtypeJSString = new TypeMask.nonNullSubtype(JSString, closedWorld); | 234 TypeMask subtypeJSString = new TypeMask.nonNullSubtype(JSString, closedWorld); |
238 TypeMask subclassJSString = | 235 TypeMask subclassJSString = |
239 new TypeMask.nonNullSubclass(JSString, closedWorld); | 236 new TypeMask.nonNullSubclass(JSString, closedWorld); |
240 | 237 |
241 Expect.equals(exactJSString, subtypeString); | 238 Expect.equals(exactJSString, subtypeString); |
242 Expect.equals(exactJSString, subtypeJSString); | 239 Expect.equals(exactJSString, subtypeJSString); |
243 Expect.equals(exactJSString, subclassJSString); | 240 Expect.equals(exactJSString, subclassJSString); |
244 } | 241 } |
OLD | NEW |