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