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 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
7 | 8 |
8 const String TEST = """ | 9 const String TEST = """ |
9 class X {} | 10 class X {} |
10 returnDyn1() { | 11 returnDyn1() { |
11 var a; | 12 var a; |
12 ((a = 52) == true) || ((a = 'foo') == true); | 13 ((a = 52) == true) || ((a = 'foo') == true); |
13 return a; | 14 return a; |
14 } | 15 } |
15 | 16 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 returnDyn4(); | 51 returnDyn4(); |
51 returnDyn5(); | 52 returnDyn5(); |
52 returnDyn6(); | 53 returnDyn6(); |
53 } | 54 } |
54 """; | 55 """; |
55 | 56 |
56 | 57 |
57 void main() { | 58 void main() { |
58 Uri uri = new Uri(scheme: 'source'); | 59 Uri uri = new Uri(scheme: 'source'); |
59 var compiler = compilerFor(TEST, uri); | 60 var compiler = compilerFor(TEST, uri); |
60 compiler.runCompiler(uri); | 61 asyncTest(() => compiler.runCompiler(uri).then((_) { |
61 var typesInferrer = compiler.typesTask.typesInferrer; | 62 var typesInferrer = compiler.typesTask.typesInferrer; |
62 | 63 |
63 checkReturn(String name, type) { | 64 checkReturn(String name, type) { |
64 var element = findElement(compiler, name); | 65 var element = findElement(compiler, name); |
65 Expect.equals(type, | 66 Expect.equals(type, |
66 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); | 67 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); |
67 } | 68 } |
68 | 69 |
69 var subclassOfInterceptor = | 70 var subclassOfInterceptor = |
70 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 71 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
71 | 72 |
72 checkReturn('returnDyn1', subclassOfInterceptor); | 73 checkReturn('returnDyn1', subclassOfInterceptor); |
73 checkReturn('returnDyn2', subclassOfInterceptor); | 74 checkReturn('returnDyn2', subclassOfInterceptor); |
74 checkReturn('returnDyn3', subclassOfInterceptor); | 75 checkReturn('returnDyn3', subclassOfInterceptor); |
75 checkReturn('returnDyn4', compiler.typesTask.dynamicType.nonNullable()); | 76 checkReturn('returnDyn4', compiler.typesTask.dynamicType.nonNullable()); |
76 checkReturn('returnDyn5', compiler.typesTask.dynamicType.nonNullable()); | 77 checkReturn('returnDyn5', compiler.typesTask.dynamicType.nonNullable()); |
77 checkReturn('returnDyn6', compiler.typesTask.dynamicType.nonNullable()); | 78 checkReturn('returnDyn6', compiler.typesTask.dynamicType.nonNullable()); |
| 79 })); |
78 } | 80 } |
OLD | NEW |