| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 'type_mask_test_helper.dart'; | 8 import 'type_mask_test_helper.dart'; |
| 9 | 9 |
| 10 const String TEST = """ | 10 const String TEST = """ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 """; | 39 """; |
| 40 | 40 |
| 41 void main() { | 41 void main() { |
| 42 Uri uri = new Uri(scheme: 'source'); | 42 Uri uri = new Uri(scheme: 'source'); |
| 43 var compiler = compilerFor(TEST, uri); | 43 var compiler = compilerFor(TEST, uri); |
| 44 asyncTest(() => compiler.run(uri).then((_) { | 44 asyncTest(() => compiler.run(uri).then((_) { |
| 45 var typesInferrer = compiler.globalInference.typesInferrerInternal; | 45 var typesInferrer = compiler.globalInference.typesInferrerInternal; |
| 46 var closedWorld = typesInferrer.closedWorld; | 46 var closedWorld = typesInferrer.closedWorld; |
| 47 | 47 |
| 48 checkArgument(String functionName, type) { | 48 checkArgument(String functionName, type) { |
| 49 var functionElement = findElement(compiler, functionName); | 49 dynamic functionElement = findElement(compiler, functionName); |
| 50 var signature = functionElement.functionSignature; | 50 var signature = functionElement.functionSignature; |
| 51 var element = signature.requiredParameterCount > 0 | 51 var element = signature.requiredParameterCount > 0 |
| 52 ? signature.requiredParameters.first | 52 ? signature.requiredParameters.first |
| 53 : signature.optionalParameters.first; | 53 : signature.optionalParameters.first; |
| 54 Expect.equals( | 54 Expect.equals( |
| 55 type, | 55 type, |
| 56 simplify(typesInferrer.getTypeOfElement(element), closedWorld), | 56 simplify(typesInferrer.getTypeOfElement(element), closedWorld), |
| 57 functionName); | 57 functionName); |
| 58 } | 58 } |
| 59 | 59 |
| 60 checkOptionalArgument(String functionName, type) { | |
| 61 var functionElement = findElement(compiler, functionName); | |
| 62 var signature = functionElement.functionSignature; | |
| 63 var element = signature.optionalParameters.first; | |
| 64 Expect.equals( | |
| 65 type, | |
| 66 simplify(typesInferrer.getTypeOfElement(element), closedWorld), | |
| 67 functionName); | |
| 68 } | |
| 69 | |
| 70 checkArgument('foo1', closedWorld.commonMasks.functionType); | 60 checkArgument('foo1', closedWorld.commonMasks.functionType); |
| 71 | 61 |
| 72 /// 01: ok | 62 /// 01: ok |
| 73 checkArgument('foo2', closedWorld.commonMasks.functionType); | 63 checkArgument('foo2', closedWorld.commonMasks.functionType); |
| 74 | 64 |
| 75 /// 02: ok | 65 /// 02: ok |
| 76 checkArgument('foo3', closedWorld.commonMasks.functionType); | 66 checkArgument('foo3', closedWorld.commonMasks.functionType); |
| 77 | 67 |
| 78 /// 03: ok | 68 /// 03: ok |
| 79 checkArgument('foo4', closedWorld.commonMasks.functionType); | 69 checkArgument('foo4', closedWorld.commonMasks.functionType); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 99 | 89 |
| 100 /// 10: ok | 90 /// 10: ok |
| 101 checkArgument('defaultFn5', closedWorld.commonMasks.uint31Type); | 91 checkArgument('defaultFn5', closedWorld.commonMasks.uint31Type); |
| 102 | 92 |
| 103 /// 11: ok | 93 /// 11: ok |
| 104 checkArgument('defaultFn6', closedWorld.commonMasks.uint31Type); | 94 checkArgument('defaultFn6', closedWorld.commonMasks.uint31Type); |
| 105 | 95 |
| 106 /// 12: ok | 96 /// 12: ok |
| 107 })); | 97 })); |
| 108 } | 98 } |
| OLD | NEW |