Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: dart/tests/corelib/apply_test.dart

Issue 14107006: Update Function.apply to use Symbol. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/tests/corelib/apply2_test.dart ('k') | dart/tests/corelib/symbol_map_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"; 5 import "package:expect/expect.dart";
6 import "symbol_map_helper.dart";
6 7
7 // Testing Function.apply calls correctly. 8 // Testing Function.apply calls correctly.
8 // This test is not testing error handling, only that correct parameters 9 // This test is not testing error handling, only that correct parameters
9 // cause a correct call. 10 // cause a correct call.
10 11
11 int test0() => 42; 12 int test0() => 42;
12 int test0a({int a}) => 37 + a; 13 int test0a({int a}) => 37 + a;
13 int test1(int i) => i + 1; 14 int test1(int i) => i + 1;
14 int test1a(int i, {int a}) => i + a; 15 int test1a(int i, {int a}) => i + a;
15 int test2(int i, int j) => i + j; 16 int test2(int i, int j) => i + j;
(...skipping 15 matching lines...) Expand all
31 try { 32 try {
32 throw [Function.apply]; 33 throw [Function.apply];
33 } catch (e) { 34 } catch (e) {
34 return e[0]; 35 return e[0];
35 } 36 }
36 return null; 37 return null;
37 } 38 }
38 39
39 main() { 40 main() {
40 testMap(res, func, map) { 41 testMap(res, func, map) {
42 map = symbolMapToStringMap(map);
41 Expect.equals(res, Function.apply(func, null, map)); 43 Expect.equals(res, Function.apply(func, null, map));
42 Expect.equals(res, Function.apply(func, [], map)); 44 Expect.equals(res, Function.apply(func, [], map));
43 } 45 }
44 testList(res, func, list) { 46 testList(res, func, list) {
45 Expect.equals(res, Function.apply(func, list)); 47 Expect.equals(res, Function.apply(func, list));
46 Expect.equals(res, Function.apply(func, list, null)); 48 Expect.equals(res, Function.apply(func, list, null));
47 Expect.equals(res, Function.apply(func, list, {})); 49 Expect.equals(res, Function.apply(func, list, new Map<Symbol, dynamic>()));
48 } 50 }
49 test(res, func, list, map) { 51 test(res, func, list, map) {
52 map = symbolMapToStringMap(map);
50 Expect.equals(res, Function.apply(func, list, map)); 53 Expect.equals(res, Function.apply(func, list, map));
51 } 54 }
52 testList(42, test0, null); 55 testList(42, test0, null);
53 testList(42, test0, []); 56 testList(42, test0, []);
54 testMap(42, test0a, {"a": 5}); 57 testMap(42, test0a, {"a": 5});
55 testList(42, test1, [41]); 58 testList(42, test1, [41]);
56 test(42, test1a, [20], {"a": 22}); 59 test(42, test1a, [20], {"a": 22});
57 testList(42, test2, [20, 22]); 60 testList(42, test2, [20, 22]);
58 test(42, test2a, [10, 15], {"a" : 17}); 61 test(42, test2a, [10, 15], {"a" : 17});
59 62
(...skipping 12 matching lines...) Expand all
72 // Test that apply works even with a different name. 75 // Test that apply works even with a different name.
73 var app = confuse(); 76 var app = confuse();
74 Expect.equals(42, app(test2, [22, 20])); 77 Expect.equals(42, app(test2, [22, 20]));
75 78
76 // Test that apply can itself be applied. 79 // Test that apply can itself be applied.
77 Expect.equals(42, Function.apply(Function.apply, [test2, [17, 25]])); 80 Expect.equals(42, Function.apply(Function.apply, [test2, [17, 25]]));
78 81
79 // Test that apply works on callable objects. 82 // Test that apply works on callable objects.
80 testList(42, new Callable(), [13, 29]); 83 testList(42, new Callable(), [13, 29]);
81 } 84 }
OLDNEW
« no previous file with comments | « dart/tests/corelib/apply2_test.dart ('k') | dart/tests/corelib/symbol_map_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698