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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 test8(); | 89 test8(); |
90 test9(); | 90 test9(); |
91 test10(); | 91 test10(); |
92 } | 92 } |
93 """; | 93 """; |
94 | 94 |
95 | 95 |
96 void main() { | 96 void main() { |
97 Uri uri = new Uri(scheme: 'source'); | 97 Uri uri = new Uri(scheme: 'source'); |
98 var compiler = compilerFor(TEST, uri); | 98 var compiler = compilerFor(TEST, uri); |
99 asyncTest(() => compiler.runCompiler(uri).then((_) { | 99 asyncTest(() => compiler.run(uri).then((_) { |
100 var typesInferrer = compiler.typesTask.typesInferrer; | 100 var typesInferrer = compiler.typesTask.typesInferrer; |
101 | 101 |
102 checkReturn(String name, type) { | 102 checkReturn(String name, type) { |
103 var element = findElement(compiler, name); | 103 var element = findElement(compiler, name); |
104 Expect.equals(type, | 104 Expect.equals(type, |
105 simplify(typesInferrer.getReturnTypeOfElement(element), compiler)); | 105 simplify(typesInferrer.getReturnTypeOfElement(element), compiler)); |
106 } | 106 } |
107 | 107 |
108 var subclassOfInterceptor = | 108 var subclassOfInterceptor = |
109 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 109 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
110 | 110 |
111 checkReturn('returnDyn1', subclassOfInterceptor); | 111 checkReturn('returnDyn1', subclassOfInterceptor); |
112 checkReturn('returnDyn2', subclassOfInterceptor); | 112 checkReturn('returnDyn2', subclassOfInterceptor); |
113 checkReturn('returnDyn3', subclassOfInterceptor); | 113 checkReturn('returnDyn3', subclassOfInterceptor); |
114 checkReturn('returnDyn4', compiler.typesTask.dynamicType.nonNullable()); | 114 checkReturn('returnDyn4', compiler.typesTask.dynamicType.nonNullable()); |
115 checkReturn('returnDyn5', compiler.typesTask.dynamicType.nonNullable()); | 115 checkReturn('returnDyn5', compiler.typesTask.dynamicType.nonNullable()); |
116 checkReturn('returnDyn6', compiler.typesTask.dynamicType.nonNullable()); | 116 checkReturn('returnDyn6', compiler.typesTask.dynamicType.nonNullable()); |
117 checkReturn('returnDyn7', subclassOfInterceptor); | 117 checkReturn('returnDyn7', subclassOfInterceptor); |
118 checkReturn('returnDyn7b', subclassOfInterceptor); | 118 checkReturn('returnDyn7b', subclassOfInterceptor); |
119 checkReturn('returnDyn8', subclassOfInterceptor); | 119 checkReturn('returnDyn8', subclassOfInterceptor); |
120 checkReturn('returnDyn9', subclassOfInterceptor); | 120 checkReturn('returnDyn9', subclassOfInterceptor); |
121 checkReturn('returnString', compiler.typesTask.stringType); | 121 checkReturn('returnString', compiler.typesTask.stringType); |
122 })); | 122 })); |
123 } | 123 } |
OLD | NEW |