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

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

Issue 2979073002: "Set up directories.." commit below broke the buildbot tests, two others are collateral damage. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « tests/corelib/apply_test.dart ('k') | tests/corelib_2/corelib_2.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6 import "symbol_map_helper.dart";
7
8 // Testing Function.apply calls correctly.
9 // This test is not testing error handling, only that correct parameters
10 // cause a correct call.
11
12 int test0() => 42;
13 int test0a({int a}) => 37 + a;
14 int test1(int i) => i + 1;
15 int test1a(int i, {int a}) => i + a;
16 int test2(int i, int j) => i + j;
17 int test2a(int i, int j, {int a}) => i + j + a;
18
19 class C {
20 int x = 10;
21 int foo(y) => this.x + y;
22 }
23
24 class Callable {
25 int call(int x, int y) => x + y;
26 }
27
28 @NoInline()
29 @AssumeDynamic()
30 confuse(x) => x;
31
32 main() {
33 testMap(res, func, map) {
34 map = symbolMapToStringMap(map);
35 Expect.equals(res, Function.apply(func, null, map));
36 Expect.equals(res, Function.apply(func, [], map));
37 }
38
39 testList(res, func, list) {
40 Expect.equals(res, Function.apply(func, list));
41 Expect.equals(res, Function.apply(func, list, null));
42 Expect.equals(res, Function.apply(func, list, new Map<Symbol, dynamic>()));
43 }
44
45 test(res, func, list, map) {
46 map = symbolMapToStringMap(map);
47 Expect.equals(res, Function.apply(func, list, map));
48 }
49
50 testList(42, test0, null);
51 testList(42, test0, []);
52 testMap(42, test0a, {"a": 5});
53 testList(42, test1, [41]);
54 test(42, test1a, [20], {"a": 22});
55 testList(42, test2, [20, 22]);
56 test(42, test2a, [10, 15], {"a": 17});
57
58 // Test that "this" is correct when calling closurized functions.
59 var cfoo = new C().foo;
60 testList(42, cfoo, [32]);
61
62 // Test that apply works even with a different name.
63 var app = confuse(Function.apply);
64 Expect.equals(42, app(test2, [22, 20]));
65
66 // Test that apply can itself be applied.
67 Expect.equals(
68 42,
69 Function.apply(Function.apply, [
70 test2,
71 [17, 25]
72 ]));
73
74 // Test that apply works on callable objects.
75 testList(42, new Callable(), [13, 29]);
76 }
OLDNEW
« no previous file with comments | « tests/corelib/apply_test.dart ('k') | tests/corelib_2/corelib_2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698