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

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

Issue 17977002: - Remove arguments definition test from the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
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 import "symbol_map_helper.dart";
7 7
8 // Testing Function.apply calls correctly. 8 // Testing Function.apply calls correctly.
9 // This test is not testing error handling, only that correct parameters 9 // This test is not testing error handling, only that correct parameters
10 // cause a correct call. 10 // cause a correct call.
11 11
12 int test0() => 42; 12 int test0() => 42;
13 int test0a({int a}) => 37 + a; 13 int test0a({int a}) => 37 + a;
14 int test1(int i) => i + 1; 14 int test1(int i) => i + 1;
15 int test1a(int i, {int a}) => i + a; 15 int test1a(int i, {int a}) => i + a;
16 int test2(int i, int j) => i + j; 16 int test2(int i, int j) => i + j;
17 int test2a(int i, int j, {int a}) => i + j + a; 17 int test2a(int i, int j, {int a}) => i + j + a;
18 18
19 bool testPassed1([int x]) => ?x;
20 bool testPassedX({int x}) => ?x;
21
22 class C { 19 class C {
23 int x = 10; 20 int x = 10;
24 int foo(y) => this.x + y; 21 int foo(y) => this.x + y;
25 } 22 }
26 23
27 class Callable { 24 class Callable {
28 int call(int x, int y) => x + y; 25 int call(int x, int y) => x + y;
29 } 26 }
30 27
31 confuse() { 28 confuse() {
(...skipping 21 matching lines...) Expand all
53 Expect.equals(res, Function.apply(func, list, map)); 50 Expect.equals(res, Function.apply(func, list, map));
54 } 51 }
55 testList(42, test0, null); 52 testList(42, test0, null);
56 testList(42, test0, []); 53 testList(42, test0, []);
57 testMap(42, test0a, {"a": 5}); 54 testMap(42, test0a, {"a": 5});
58 testList(42, test1, [41]); 55 testList(42, test1, [41]);
59 test(42, test1a, [20], {"a": 22}); 56 test(42, test1a, [20], {"a": 22});
60 testList(42, test2, [20, 22]); 57 testList(42, test2, [20, 22]);
61 test(42, test2a, [10, 15], {"a" : 17}); 58 test(42, test2a, [10, 15], {"a" : 17});
62 59
63 testList(false, testPassed1, null);
64 testList(false, testPassed1, []);
65 testList(true, testPassed1, [42]);
66
67 testMap(false, testPassedX, null);
68 testMap(false, testPassedX, {});
69 testMap(true, testPassedX, {"x": 42});
70
71 // Test that "this" is correct when calling closurized functions. 60 // Test that "this" is correct when calling closurized functions.
72 var cfoo = new C().foo; 61 var cfoo = new C().foo;
73 testList(42, cfoo, [32]); 62 testList(42, cfoo, [32]);
74 63
75 // Test that apply works even with a different name. 64 // Test that apply works even with a different name.
76 var app = confuse(); 65 var app = confuse();
77 Expect.equals(42, app(test2, [22, 20])); 66 Expect.equals(42, app(test2, [22, 20]));
78 67
79 // Test that apply can itself be applied. 68 // Test that apply can itself be applied.
80 Expect.equals(42, Function.apply(Function.apply, [test2, [17, 25]])); 69 Expect.equals(42, Function.apply(Function.apply, [test2, [17, 25]]));
81 70
82 // Test that apply works on callable objects. 71 // Test that apply works on callable objects.
83 testList(42, new Callable(), [13, 29]); 72 testList(42, new Callable(), [13, 29]);
84 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698