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 'compiler_helper.dart'; | 6 import 'compiler_helper.dart'; |
7 | 7 |
8 const String TEST = """ | 8 const String TEST = """ |
9 returnInt1() { | 9 returnInt1() { |
10 var a = 42; | 10 var a = 42; |
(...skipping 62 matching lines...) Loading... |
73 returnInt2(); | 73 returnInt2(); |
74 returnDyn2(); | 74 returnDyn2(); |
75 returnInt3(); | 75 returnInt3(); |
76 returnDyn3(); | 76 returnDyn3(); |
77 returnInt4(); | 77 returnInt4(); |
78 } | 78 } |
79 """; | 79 """; |
80 | 80 |
81 | 81 |
82 void main() { | 82 void main() { |
83 Uri uri = new Uri.fromComponents(scheme: 'source'); | 83 Uri uri = new Uri(scheme: 'source'); |
84 var compiler = compilerFor(TEST, uri); | 84 var compiler = compilerFor(TEST, uri); |
85 compiler.runCompiler(uri); | 85 compiler.runCompiler(uri); |
86 var typesInferrer = compiler.typesTask.typesInferrer; | 86 var typesInferrer = compiler.typesTask.typesInferrer; |
87 | 87 |
88 checkReturn(String name, type) { | 88 checkReturn(String name, type) { |
89 var element = findElement(compiler, name); | 89 var element = findElement(compiler, name); |
90 Expect.equals(type, typesInferrer.internal.returnTypeOf[element]); | 90 Expect.equals(type, typesInferrer.internal.returnTypeOf[element]); |
91 } | 91 } |
92 | 92 |
93 checkReturn('returnInt1', typesInferrer.intType); | 93 checkReturn('returnInt1', typesInferrer.intType); |
94 // TODO(ngeoffray): We don't use types of mutated captured | 94 // TODO(ngeoffray): We don't use types of mutated captured |
95 // variables anymore, because they could lead to optimistic results | 95 // variables anymore, because they could lead to optimistic results |
96 // needing to be re-analyzed. | 96 // needing to be re-analyzed. |
97 checkReturn('returnInt2', typesInferrer.dynamicType); | 97 checkReturn('returnInt2', typesInferrer.dynamicType); |
98 checkReturn('returnInt3', typesInferrer.intType); | 98 checkReturn('returnInt3', typesInferrer.intType); |
99 checkReturn('returnInt4', typesInferrer.intType); | 99 checkReturn('returnInt4', typesInferrer.intType); |
100 | 100 |
101 checkReturn('returnDyn1', typesInferrer.dynamicType); | 101 checkReturn('returnDyn1', typesInferrer.dynamicType); |
102 checkReturn('returnDyn2', typesInferrer.dynamicType); | 102 checkReturn('returnDyn2', typesInferrer.dynamicType); |
103 checkReturn('returnDyn3', typesInferrer.dynamicType); | 103 checkReturn('returnDyn3', typesInferrer.dynamicType); |
104 } | 104 } |
OLD | NEW |