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