| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 main() { | 50 main() { |
| 51 asyncTest(() async { | 51 asyncTest(() async { |
| 52 CompilationResult result = | 52 CompilationResult result = |
| 53 await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES); | 53 await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES); |
| 54 Compiler compiler = result.compiler; | 54 Compiler compiler = result.compiler; |
| 55 ClosedWorld closedWorld = | 55 ClosedWorld closedWorld = |
| 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(compiler.commonElements.expectNoInlineClass, | 59 Expect.isNotNull(closedWorld.commonElements.expectNoInlineClass, |
| 60 'NoInlineClass is unresolved.'); | 60 'NoInlineClass is unresolved.'); |
| 61 Expect.isNotNull(compiler.commonElements.expectTrustTypeAnnotationsClass, | 61 Expect.isNotNull(closedWorld.commonElements.expectTrustTypeAnnotationsClass, |
| 62 'TrustTypeAnnotations is unresolved.'); | 62 'TrustTypeAnnotations is unresolved.'); |
| 63 Expect.isNotNull(compiler.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(FunctionElement 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.getTypeOfElement(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) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 expectNoInline: true, | 120 expectNoInline: true, |
| 121 expectTrustTypeAnnotations: true, | 121 expectTrustTypeAnnotations: true, |
| 122 expectedParameterType: jsStringType, | 122 expectedParameterType: jsStringType, |
| 123 expectedReturnType: jsIntType); | 123 expectedReturnType: jsIntType); |
| 124 test('methodAssumeDynamicTrustTypeAnnotations', | 124 test('methodAssumeDynamicTrustTypeAnnotations', |
| 125 expectAssumeDynamic: true, | 125 expectAssumeDynamic: true, |
| 126 expectTrustTypeAnnotations: true, | 126 expectTrustTypeAnnotations: true, |
| 127 expectedParameterType: coreStringType); | 127 expectedParameterType: coreStringType); |
| 128 }); | 128 }); |
| 129 } | 129 } |
| OLD | NEW |