OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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"; | |
6 | |
7 // Testing Function.apply calls correctly. | 5 // Testing Function.apply calls correctly. |
8 // This test is not testing error handling, only that correct parameters | 6 // This test is not testing error handling, only that correct parameters |
9 // cause a correct call. | 7 // cause a correct call. |
10 | 8 |
11 int test0() => 42; | 9 int test0() => 42; |
12 int test0a({int a}) => 37 + a; | 10 int test0a({int a}) => 37 + a; |
13 int test1(int i) => i + 1; | 11 int test1(int i) => i + 1; |
14 int test1a(int i, {int a}) => i + a; | 12 int test1a(int i, {int a}) => i + a; |
15 int test2(int i, int j) => i + j; | 13 int test2(int i, int j) => i + j; |
16 int test2a(int i, int j, {int a}) => i + j + a; | 14 int test2a(int i, int j, {int a}) => i + j + a; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // Test that apply works even with a different name. | 70 // Test that apply works even with a different name. |
73 var app = confuse(); | 71 var app = confuse(); |
74 Expect.equals(42, app(test2, [22, 20])); | 72 Expect.equals(42, app(test2, [22, 20])); |
75 | 73 |
76 // Test that apply can itself be applied. | 74 // Test that apply can itself be applied. |
77 Expect.equals(42, Function.apply(Function.apply, [test2, [17, 25]])); | 75 Expect.equals(42, Function.apply(Function.apply, [test2, [17, 25]])); |
78 | 76 |
79 // Test that apply works on callable objects. | 77 // Test that apply works on callable objects. |
80 testList(42, new Callable(), [13, 29]); | 78 testList(42, new Callable(), [13, 29]); |
81 } | 79 } |
OLD | NEW |