OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
8 import 'type_mask_test_helper.dart'; | 8 import 'type_mask_test_helper.dart'; |
9 | 9 |
10 const String TEST = """ | 10 const String TEST = """ |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 returnDyn4(); | 85 returnDyn4(); |
86 returnDyn5(); | 86 returnDyn5(); |
87 returnDyn6(); | 87 returnDyn6(); |
88 returnDyn7(); | 88 returnDyn7(); |
89 test8(); | 89 test8(); |
90 test9(); | 90 test9(); |
91 test10(); | 91 test10(); |
92 } | 92 } |
93 """; | 93 """; |
94 | 94 |
95 | |
96 void main() { | 95 void main() { |
97 Uri uri = new Uri(scheme: 'source'); | 96 Uri uri = new Uri(scheme: 'source'); |
98 var compiler = compilerFor(TEST, uri); | 97 var compiler = compilerFor(TEST, uri); |
99 asyncTest(() => compiler.run(uri).then((_) { | 98 asyncTest(() => compiler.run(uri).then((_) { |
100 var typesInferrer = compiler.globalInference.typesInferrer; | 99 var typesInferrer = compiler.globalInference.typesInferrer; |
101 | 100 |
102 checkReturn(String name, type) { | 101 checkReturn(String name, type) { |
103 var element = findElement(compiler, name); | 102 var element = findElement(compiler, name); |
104 Expect.equals(type, | 103 Expect.equals( |
105 simplify(typesInferrer.getReturnTypeOfElement(element), compiler)); | 104 type, |
106 } | 105 simplify( |
| 106 typesInferrer.getReturnTypeOfElement(element), compiler)); |
| 107 } |
107 | 108 |
108 var subclassOfInterceptor = | 109 var subclassOfInterceptor = |
109 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 110 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
110 | 111 |
111 checkReturn('returnDyn1', subclassOfInterceptor); | 112 checkReturn('returnDyn1', subclassOfInterceptor); |
112 checkReturn('returnDyn2', subclassOfInterceptor); | 113 checkReturn('returnDyn2', subclassOfInterceptor); |
113 checkReturn('returnDyn3', subclassOfInterceptor); | 114 checkReturn('returnDyn3', subclassOfInterceptor); |
114 checkReturn('returnDyn4', compiler.commonMasks.dynamicType.nonNullable()); | 115 checkReturn( |
115 checkReturn('returnDyn5', compiler.commonMasks.dynamicType.nonNullable()); | 116 'returnDyn4', compiler.commonMasks.dynamicType.nonNullable()); |
116 checkReturn('returnDyn6', compiler.commonMasks.dynamicType.nonNullable()); | 117 checkReturn( |
117 checkReturn('returnDyn7', subclassOfInterceptor); | 118 'returnDyn5', compiler.commonMasks.dynamicType.nonNullable()); |
118 checkReturn('returnDyn7b', subclassOfInterceptor); | 119 checkReturn( |
119 checkReturn('returnDyn8', subclassOfInterceptor); | 120 'returnDyn6', compiler.commonMasks.dynamicType.nonNullable()); |
120 checkReturn('returnDyn9', subclassOfInterceptor); | 121 checkReturn('returnDyn7', subclassOfInterceptor); |
121 checkReturn('returnString', compiler.commonMasks.stringType); | 122 checkReturn('returnDyn7b', subclassOfInterceptor); |
122 })); | 123 checkReturn('returnDyn8', subclassOfInterceptor); |
| 124 checkReturn('returnDyn9', subclassOfInterceptor); |
| 125 checkReturn('returnString', compiler.commonMasks.stringType); |
| 126 })); |
123 } | 127 } |
OLD | NEW |