| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 'package:compiler/src/compiler.dart'; | 7 import 'package:compiler/src/compiler.dart'; |
| 8 import 'package:compiler/src/elements/elements.dart'; | 8 import 'package:compiler/src/elements/elements.dart'; |
| 9 import 'package:compiler/src/js_backend/js_backend.dart'; | 9 import 'package:compiler/src/js_backend/js_backend.dart'; |
| 10 import 'package:compiler/src/types/types.dart'; | 10 import 'package:compiler/src/types/types.dart'; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 compiler.resolutionWorldBuilder.closedWorldForTesting; | 56 compiler.resolutionWorldBuilder.closedWorldForTesting; |
| 57 Expect.isFalse(compiler.compilationFailed, 'Unsuccessful compilation'); | 57 Expect.isFalse(compiler.compilationFailed, 'Unsuccessful compilation'); |
| 58 JavaScriptBackend backend = compiler.backend; | 58 JavaScriptBackend backend = compiler.backend; |
| 59 Expect.isNotNull(closedWorld.commonElements.expectNoInlineClass, | 59 Expect.isNotNull(closedWorld.commonElements.expectNoInlineClass, |
| 60 'NoInlineClass is unresolved.'); | 60 'NoInlineClass is unresolved.'); |
| 61 Expect.isNotNull(closedWorld.commonElements.expectTrustTypeAnnotationsClass, | 61 Expect.isNotNull(closedWorld.commonElements.expectTrustTypeAnnotationsClass, |
| 62 'TrustTypeAnnotations is unresolved.'); | 62 'TrustTypeAnnotations is unresolved.'); |
| 63 Expect.isNotNull(closedWorld.commonElements.expectAssumeDynamicClass, | 63 Expect.isNotNull(closedWorld.commonElements.expectAssumeDynamicClass, |
| 64 'AssumeDynamicClass is unresolved.'); | 64 'AssumeDynamicClass is unresolved.'); |
| 65 | 65 |
| 66 void testTypeMatch(FunctionElement function, TypeMask expectedParameterType, | 66 void testTypeMatch(MethodElement function, TypeMask expectedParameterType, |
| 67 TypeMask expectedReturnType, TypesInferrer inferrer) { | 67 TypeMask expectedReturnType, TypesInferrer inferrer) { |
| 68 for (ParameterElement parameter in function.parameters) { | 68 for (ParameterElement parameter in function.parameters) { |
| 69 TypeMask type = inferrer.getTypeOfElement(parameter); | 69 TypeMask type = inferrer.getTypeOfParameter(parameter); |
| 70 Expect.equals( | 70 Expect.equals( |
| 71 expectedParameterType, simplify(type, closedWorld), "$parameter"); | 71 expectedParameterType, simplify(type, closedWorld), "$parameter"); |
| 72 } | 72 } |
| 73 if (expectedReturnType != null) { | 73 if (expectedReturnType != null) { |
| 74 TypeMask type = inferrer.getReturnTypeOfElement(function); | 74 TypeMask type = inferrer.getReturnTypeOfMember(function); |
| 75 Expect.equals( | 75 Expect.equals( |
| 76 expectedReturnType, simplify(type, closedWorld), "$function"); | 76 expectedReturnType, simplify(type, closedWorld), "$function"); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 void test(String name, | 80 void test(String name, |
| 81 {bool expectNoInline: false, | 81 {bool expectNoInline: false, |
| 82 bool expectTrustTypeAnnotations: false, | 82 bool expectTrustTypeAnnotations: false, |
| 83 TypeMask expectedParameterType: null, | 83 TypeMask expectedParameterType: null, |
| 84 TypeMask expectedReturnType: null, | 84 TypeMask expectedReturnType: null, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 expectNoInline: true, | 121 expectNoInline: true, |
| 122 expectTrustTypeAnnotations: true, | 122 expectTrustTypeAnnotations: true, |
| 123 expectedParameterType: jsStringType, | 123 expectedParameterType: jsStringType, |
| 124 expectedReturnType: jsIntType); | 124 expectedReturnType: jsIntType); |
| 125 test('methodAssumeDynamicTrustTypeAnnotations', | 125 test('methodAssumeDynamicTrustTypeAnnotations', |
| 126 expectAssumeDynamic: true, | 126 expectAssumeDynamic: true, |
| 127 expectTrustTypeAnnotations: true, | 127 expectTrustTypeAnnotations: true, |
| 128 expectedParameterType: coreStringType); | 128 expectedParameterType: coreStringType); |
| 129 }); | 129 }); |
| 130 } | 130 } |
| OLD | NEW |