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 | 6 |
7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
8 import 'parser_helper.dart'; | 8 import 'parser_helper.dart'; |
9 | 9 |
10 const String TEST1 = """ | 10 const String TEST1 = """ |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 test6(); | 86 test6(); |
87 test7(); | 87 test7(); |
88 test8(); | 88 test8(); |
89 test9(); | 89 test9(); |
90 test10(); | 90 test10(); |
91 test11(); | 91 test11(); |
92 } | 92 } |
93 """; | 93 """; |
94 | 94 |
95 main() { | 95 main() { |
96 Uri uri = new Uri.fromComponents(scheme: 'source'); | 96 Uri uri = new Uri(scheme: 'source'); |
97 | 97 |
98 var compiler = compilerFor(TEST1, uri); | 98 var compiler = compilerFor(TEST1, uri); |
99 compiler.runCompiler(uri); | 99 compiler.runCompiler(uri); |
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( | 104 Expect.equals( |
105 type, | 105 type, |
106 typesInferrer.internal.returnTypeOf[element].simplify(compiler), | 106 typesInferrer.internal.returnTypeOf[element].simplify(compiler), |
(...skipping 21 matching lines...) Expand all Loading... |
128 // inferrer thinks Object.noSuchMethod return null. Once we track | 128 // inferrer thinks Object.noSuchMethod return null. Once we track |
129 // aborting control flow in the analysis, we won't get the nullable | 129 // aborting control flow in the analysis, we won't get the nullable |
130 // anymore. | 130 // anymore. |
131 checkReturn('test6', typesInferrer.numType.nullable()); | 131 checkReturn('test6', typesInferrer.numType.nullable()); |
132 checkReturn('test7', typesInferrer.intType); | 132 checkReturn('test7', typesInferrer.intType); |
133 checkReturn('test8', typesInferrer.intType); | 133 checkReturn('test8', typesInferrer.intType); |
134 checkReturn('test9', typesInferrer.intType); | 134 checkReturn('test9', typesInferrer.intType); |
135 checkReturn('test10', typesInferrer.numType); | 135 checkReturn('test10', typesInferrer.numType); |
136 checkReturn('test11', typesInferrer.doubleType); | 136 checkReturn('test11', typesInferrer.doubleType); |
137 } | 137 } |
OLD | NEW |