OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'package:expect/expect.dart'; | |
6 import "package:async_helper/async_helper.dart"; | |
7 import 'compiler_helper.dart'; | |
8 import 'type_mask_test_helper.dart'; | |
9 | |
10 | |
11 | |
12 const String TEST = """ | |
13 | |
14 // [method_i] is called only via [foo_i]'s default value with a small integer. | |
15 | |
16 method1(a) => a; | |
17 method2(a) => a; | |
18 method3(a) => a; | |
19 method4(a) => a; | |
20 method5(a) => a; | |
21 method6(a) => a; | |
22 | |
23 foo1([fn = method1]) => fn(54); | |
24 foo2({fn: method2}) => fn(54); | |
25 foo3([fn = method3]) => fn(54); | |
26 foo4({fn: method4}) => fn(54); | |
27 foo5([fn = method5]) => fn(54); | |
28 foo6({fn: method6}) => fn(54); | |
29 | |
30 main() { | |
31 foo1(); | |
32 foo2(); | |
33 (foo3)(); | |
34 (foo4)(); | |
35 Function.apply(foo5, []); | |
36 Function.apply(foo6, []); | |
37 } | |
38 """; | |
39 | |
40 | |
41 void main() { | |
42 Uri uri = new Uri(scheme: 'source'); | |
43 var compiler = compilerFor(TEST, uri); | |
44 asyncTest(() => compiler.runCompiler(uri).then((_) { | |
45 var typesInferrer = compiler.typesTask.typesInferrer; | |
46 | |
47 checkArgument(String functionName, type) { | |
48 var functionElement = findElement(compiler, functionName); | |
49 var signature = functionElement.functionSignature; | |
50 var element = signature.requiredParameterCount > 0 | |
51 ? signature.requiredParameters.first | |
52 : signature.optionalParameters.first; | |
53 Expect.equals(type, | |
54 simplify(typesInferrer.getTypeOfElement(element), compiler), | |
55 functionName); | |
56 } | |
57 | |
58 checkOptionalArgument(String functionName, type) { | |
59 var functionElement = findElement(compiler, functionName); | |
60 var signature = functionElement.functionSignature; | |
61 var element = signature.optionalParameters.first; | |
62 Expect.equals(type, | |
63 simplify(typesInferrer.getTypeOfElement(element), compiler), | |
64 functionName); | |
65 } | |
66 | |
67 checkArgument('foo1', compiler.typesTask.functionType); | |
68 checkArgument('foo2', compiler.typesTask.functionType); | |
69 checkArgument('foo3', compiler.typesTask.functionType); | |
70 checkArgument('foo4', compiler.typesTask.functionType); | |
71 checkArgument('foo5', compiler.typesTask.functionType); | |
72 checkArgument('foo6', compiler.typesTask.functionType); | |
73 | |
74 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
| |
75 checkArgument('method2', compiler.typesTask.uint31Type); | |
76 checkArgument('method3', compiler.typesTask.uint31Type); | |
77 checkArgument('method4', compiler.typesTask.uint31Type); | |
78 checkArgument('method5', compiler.typesTask.uint31Type); | |
79 checkArgument('method6', compiler.typesTask.uint31Type); | |
80 })); | |
81 } | |
OLD | NEW |