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 returnInt1() { | 10 returnInt1() { |
10 var a = 42; | 11 var a = 42; |
11 var f = () { | 12 var f = () { |
12 return a; | 13 return a; |
13 }; | 14 }; |
14 return a; | 15 return a; |
15 } | 16 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 returnDyn3(); | 91 returnDyn3(); |
91 returnInt4(); | 92 returnInt4(); |
92 returnNum1(); | 93 returnNum1(); |
93 } | 94 } |
94 """; | 95 """; |
95 | 96 |
96 | 97 |
97 void main() { | 98 void main() { |
98 Uri uri = new Uri(scheme: 'source'); | 99 Uri uri = new Uri(scheme: 'source'); |
99 var compiler = compilerFor(TEST, uri); | 100 var compiler = compilerFor(TEST, uri); |
100 compiler.runCompiler(uri); | 101 asyncTest(() => compiler.runCompiler(uri).then((_) { |
101 var typesInferrer = compiler.typesTask.typesInferrer; | 102 var typesInferrer = compiler.typesTask.typesInferrer; |
102 | 103 |
103 checkReturn(String name, type) { | 104 checkReturn(String name, type) { |
104 var element = findElement(compiler, name); | 105 var element = findElement(compiler, name); |
105 Expect.equals(type, | 106 Expect.equals(type, |
106 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); | 107 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); |
107 } | 108 } |
108 | 109 |
109 checkReturn('returnInt1', compiler.typesTask.intType); | 110 checkReturn('returnInt1', compiler.typesTask.intType); |
110 checkReturn('returnInt2', compiler.typesTask.intType.nullable()); | 111 checkReturn('returnInt2', compiler.typesTask.intType.nullable()); |
111 checkReturn('returnInt3', compiler.typesTask.intType); | 112 checkReturn('returnInt3', compiler.typesTask.intType); |
112 checkReturn('returnInt4', compiler.typesTask.intType); | 113 checkReturn('returnInt4', compiler.typesTask.intType); |
113 | 114 |
114 checkReturn('returnDyn1', compiler.typesTask.dynamicType); | 115 checkReturn('returnDyn1', compiler.typesTask.dynamicType); |
115 checkReturn('returnDyn2', compiler.typesTask.dynamicType); | 116 checkReturn('returnDyn2', compiler.typesTask.dynamicType); |
116 checkReturn('returnDyn3', compiler.typesTask.dynamicType); | 117 checkReturn('returnDyn3', compiler.typesTask.dynamicType); |
117 checkReturn('returnNum1', compiler.typesTask.numType); | 118 checkReturn('returnNum1', compiler.typesTask.numType); |
| 119 })); |
118 } | 120 } |
OLD | NEW |