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 "package:async_helper/async_helper.dart"; |
7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
8 import 'parser_helper.dart' show buildSourceString; | |
9 | 8 |
10 const String TEST = """ | 9 const String TEST = """ |
11 returnInt1() { | 10 returnInt1() { |
12 var a = 42; | 11 var a = 42; |
13 var f = () { | 12 var f = () { |
14 return a; | 13 return a; |
15 }; | 14 }; |
16 return a; | 15 return a; |
17 } | 16 } |
18 | 17 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 checkReturn('returnInt4', compiler.typesTask.intType); | 132 checkReturn('returnInt4', compiler.typesTask.intType); |
134 checkReturn('returnIntOrNull', compiler.typesTask.intType.nullable()); | 133 checkReturn('returnIntOrNull', compiler.typesTask.intType.nullable()); |
135 | 134 |
136 checkReturn('returnDyn1', compiler.typesTask.dynamicType.nonNullable()); | 135 checkReturn('returnDyn1', compiler.typesTask.dynamicType.nonNullable()); |
137 checkReturn('returnDyn2', compiler.typesTask.dynamicType.nonNullable()); | 136 checkReturn('returnDyn2', compiler.typesTask.dynamicType.nonNullable()); |
138 checkReturn('returnDyn3', compiler.typesTask.dynamicType.nonNullable()); | 137 checkReturn('returnDyn3', compiler.typesTask.dynamicType.nonNullable()); |
139 checkReturn('returnNum1', compiler.typesTask.numType); | 138 checkReturn('returnNum1', compiler.typesTask.numType); |
140 | 139 |
141 checkReturnInClass(String className, String methodName, type) { | 140 checkReturnInClass(String className, String methodName, type) { |
142 var cls = findElement(compiler, className); | 141 var cls = findElement(compiler, className); |
143 var element = cls.lookupLocalMember(buildSourceString(methodName)); | 142 var element = cls.lookupLocalMember(methodName); |
144 Expect.equals(type, | 143 Expect.equals(type, |
145 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); | 144 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); |
146 } | 145 } |
147 var cls = findElement(compiler, 'A'); | 146 var cls = findElement(compiler, 'A'); |
148 checkReturnInClass('A', 'foo', new TypeMask.nonNullExact(cls)); | 147 checkReturnInClass('A', 'foo', new TypeMask.nonNullExact(cls)); |
149 })); | 148 })); |
150 } | 149 } |
OLD | NEW |