Chromium Code Reviews| Index: tests/compiler/dart2js/simple_inferrer_const_closure_default_test.dart |
| diff --git a/tests/compiler/dart2js/simple_inferrer_const_closure_default_test.dart b/tests/compiler/dart2js/simple_inferrer_const_closure_default_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7a3443711811f8549c64dc027d6df553d145279b |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/simple_inferrer_const_closure_default_test.dart |
| @@ -0,0 +1,81 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import 'package:expect/expect.dart'; |
| +import "package:async_helper/async_helper.dart"; |
| +import 'compiler_helper.dart'; |
| +import 'type_mask_test_helper.dart'; |
| + |
| + |
| + |
| +const String TEST = """ |
| + |
| +// [method_i] is called only via [foo_i]'s default value with a small integer. |
| + |
| +method1(a) => a; |
| +method2(a) => a; |
| +method3(a) => a; |
| +method4(a) => a; |
| +method5(a) => a; |
| +method6(a) => a; |
| + |
| +foo1([fn = method1]) => fn(54); |
| +foo2({fn: method2}) => fn(54); |
| +foo3([fn = method3]) => fn(54); |
| +foo4({fn: method4}) => fn(54); |
| +foo5([fn = method5]) => fn(54); |
| +foo6({fn: method6}) => fn(54); |
| + |
| +main() { |
| + foo1(); |
| + foo2(); |
| + (foo3)(); |
| + (foo4)(); |
| + Function.apply(foo5, []); |
| + Function.apply(foo6, []); |
| +} |
| +"""; |
| + |
| + |
| +void main() { |
| + Uri uri = new Uri(scheme: 'source'); |
| + var compiler = compilerFor(TEST, uri); |
| + asyncTest(() => compiler.runCompiler(uri).then((_) { |
| + var typesInferrer = compiler.typesTask.typesInferrer; |
| + |
| + checkArgument(String functionName, type) { |
| + var functionElement = findElement(compiler, functionName); |
| + var signature = functionElement.functionSignature; |
| + var element = signature.requiredParameterCount > 0 |
| + ? signature.requiredParameters.first |
| + : signature.optionalParameters.first; |
| + Expect.equals(type, |
| + simplify(typesInferrer.getTypeOfElement(element), compiler), |
| + functionName); |
| + } |
| + |
| + checkOptionalArgument(String functionName, type) { |
| + var functionElement = findElement(compiler, functionName); |
| + var signature = functionElement.functionSignature; |
| + var element = signature.optionalParameters.first; |
| + Expect.equals(type, |
| + simplify(typesInferrer.getTypeOfElement(element), compiler), |
| + functionName); |
| + } |
| + |
| + checkArgument('foo1', compiler.typesTask.functionType); |
| + checkArgument('foo2', compiler.typesTask.functionType); |
| + checkArgument('foo3', compiler.typesTask.functionType); |
| + checkArgument('foo4', compiler.typesTask.functionType); |
| + checkArgument('foo5', compiler.typesTask.functionType); |
| + checkArgument('foo6', compiler.typesTask.functionType); |
| + |
| + checkArgument('method1', compiler.typesTask.uint31Type); |
|
Siggi Cherem (dart-lang)
2015/09/04 17:46:23
which of these fail today? We could turn this into
|
| + checkArgument('method2', compiler.typesTask.uint31Type); |
| + checkArgument('method3', compiler.typesTask.uint31Type); |
| + checkArgument('method4', compiler.typesTask.uint31Type); |
| + checkArgument('method5', compiler.typesTask.uint31Type); |
| + checkArgument('method6', compiler.typesTask.uint31Type); |
| + })); |
| +} |