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

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

Issue 1024563003: Clean up apply2-test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added case to apply2_test Created 5 years, 9 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 | « no previous file | no next file » | 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";
7 6
8 apply(Function function, ArgumentDescriptor args) { 7 apply(Function function, List positional, Map<Symbol, dynamic> named) {
9 return Function.apply( 8 return Function.apply(function, positional, named);
10 function, args.positionalArguments,
11 symbolMapToStringMap(args.namedArguments));
12 } 9 }
13 10
14 class ArgumentDescriptor { 11 void throwsNSME(function, positional, named) {
15 final List positionalArguments; 12 Expect.throws(() => apply(function, positional, named),
16 final Map<String, dynamic> namedArguments; 13 (e) => e is NoSuchMethodError);
17
18 ArgumentDescriptor(this.positionalArguments, this.namedArguments);
19 }
20
21 void throwsNSME(function) {
22 Expect.throws(function, (e) => e is NoSuchMethodError);
23 } 14 }
24 15
25 main() { 16 main() {
26 var c1 = () => 'c1'; 17 var c1 = () => 'c1';
27 var c2 = (a) => 'c2 $a'; 18 var c2 = (a) => 'c2 $a';
28 var c3 = ([a = 1]) => 'c3 $a'; 19 var c3 = ([a = 1]) => 'c3 $a';
29 var c4 = ({a: 1}) => 'c4 $a'; 20 var c4 = ({a: 1}) => 'c4 $a';
30 var c5 = ({a: 1, b: 2}) => 'c5 $a $b'; 21 var c5 = ({a: 1, b: 2}) => 'c5 $a $b';
31 var c6 = ({b: 1, a: 2}) => 'c6 $a $b'; 22 var c6 = ({b: 1, a: 2}) => 'c6 $a $b';
32 var c7 = (x, {b: 1, a: 2}) => 'c7 $x $a $b'; 23 var c7 = (x, {b: 1, a: 2}) => 'c7 $x $a $b';
24 var c8 = (x, y, [a = 2, b = 3]) => 'c8 $x $y $a $b';
33 25
34 Expect.equals('c1', apply(c1, new ArgumentDescriptor(null, null))); 26 Expect.equals('c1', apply(c1, null, null));
35 Expect.equals('c1', apply(c1, new ArgumentDescriptor([], null))); 27 Expect.equals('c1', apply(c1, [], null));
36 Expect.equals('c1', apply(c1, new ArgumentDescriptor([], {}))); 28 Expect.equals('c1', apply(c1, [], {}));
37 Expect.equals('c1', apply(c1, new ArgumentDescriptor(null, {}))); 29 Expect.equals('c1', apply(c1, null, {}));
38 throwsNSME(() => apply(c1, new ArgumentDescriptor([1], null))); 30 throwsNSME(c1, [1], null);
39 throwsNSME(() => apply(c1, new ArgumentDescriptor([1], {'a': 2}))); 31 throwsNSME(c1, [1], {#a: 2});
40 throwsNSME(() => apply(c1, new ArgumentDescriptor(null, {'a': 2}))); 32 throwsNSME(c1, null, {#a: 2});
41 33
42 Expect.equals('c2 1', apply(c2, new ArgumentDescriptor([1], null))); 34 Expect.equals('c2 1', apply(c2, [1], null));
43 Expect.equals('c2 1', apply(c2, new ArgumentDescriptor([1], {}))); 35 Expect.equals('c2 1', apply(c2, [1], {}));
44 throwsNSME(() => apply(c2, new ArgumentDescriptor(null, null))); 36 throwsNSME(c2, null, null);
45 throwsNSME(() => apply(c2, new ArgumentDescriptor([], null))); 37 throwsNSME(c2, [], null);
46 throwsNSME(() => apply(c2, new ArgumentDescriptor(null, {}))); 38 throwsNSME(c2, null, {});
47 throwsNSME(() => apply(c2, new ArgumentDescriptor(null, {'a': 1}))); 39 throwsNSME(c2, null, {#a: 1});
40 throwsNSME(c2, [2], {#a: 1});
48 41
49 Expect.equals('c3 1', apply(c3, new ArgumentDescriptor([], null))); 42 Expect.equals('c3 1', apply(c3, null, null));
50 Expect.equals('c3 2', apply(c3, new ArgumentDescriptor([2], {}))); 43 Expect.equals('c3 1', apply(c3, [], null));
51 throwsNSME(() => apply(c3, new ArgumentDescriptor([1, 2], null))); 44 Expect.equals('c3 2', apply(c3, [2], {}));
52 throwsNSME(() => apply(c3, new ArgumentDescriptor(null, {'a': 1}))); 45 throwsNSME(c3, [1, 2], null);
46 throwsNSME(c3, null, {#a: 1});
53 47
54 Expect.equals('c4 1', apply(c4, new ArgumentDescriptor([], null))); 48 Expect.equals('c4 1', apply(c4, [], null));
55 Expect.equals('c4 2', apply(c4, new ArgumentDescriptor([], {'a': 2}))); 49 Expect.equals('c4 2', apply(c4, [], {#a: 2}));
56 Expect.equals('c4 1', apply(c4, new ArgumentDescriptor(null, null))); 50 Expect.equals('c4 1', apply(c4, null, null));
57 Expect.equals('c4 1', apply(c4, new ArgumentDescriptor([], {}))); 51 Expect.equals('c4 1', apply(c4, [], {}));
58 throwsNSME(() => apply(c4, new ArgumentDescriptor([1], {'a': 1}))); 52 throwsNSME(c4, [1], {#a: 1});
59 throwsNSME(() => apply(c4, new ArgumentDescriptor([1], {}))); 53 throwsNSME(c4, [1], {});
60 throwsNSME(() => apply(c4, new ArgumentDescriptor([], {'a': 1, 'b': 2}))); 54 throwsNSME(c4, [], {#a: 1, #b: 2});
61 55
62 Expect.equals('c5 1 2', apply(c5, new ArgumentDescriptor([], null))); 56 Expect.equals('c5 1 2', apply(c5, [], null));
63 Expect.equals('c5 3 2', apply(c5, new ArgumentDescriptor([], {'a': 3}))); 57 Expect.equals('c5 3 2', apply(c5, [], {#a: 3}));
64 Expect.equals('c5 1 2', apply(c5, new ArgumentDescriptor(null, null))); 58 Expect.equals('c5 1 2', apply(c5, null, null));
65 Expect.equals('c5 1 2', apply(c5, new ArgumentDescriptor([], {}))); 59 Expect.equals('c5 1 2', apply(c5, [], {}));
66 Expect.equals('c5 3 4', 60 Expect.equals('c5 3 4', apply(c5, [], {#a: 3, #b: 4}));
67 apply(c5, new ArgumentDescriptor([], {'a': 3, 'b': 4}))); 61 Expect.equals('c5 4 3', apply(c5, [], {#b: 3, #a: 4}));
68 Expect.equals('c5 4 3', 62 Expect.equals('c5 1 3', apply(c5, [], {#b: 3}));
69 apply(c5, new ArgumentDescriptor([], {'b': 3, 'a': 4}))); 63 throwsNSME(c5, [1], {#a: 1});
70 Expect.equals('c5 1 3', 64 throwsNSME(c5, [1], {});
71 apply(c5, new ArgumentDescriptor([], {'b': 3}))); 65 throwsNSME(c5, [], {#a: 1, #b: 2, #c: 3});
72 throwsNSME(() => apply(c5, new ArgumentDescriptor([1], {'a': 1})));
73 throwsNSME(() => apply(c5, new ArgumentDescriptor([1], {})));
74 throwsNSME(() =>
75 apply(c5, new ArgumentDescriptor([], {'a': 1, 'b': 2, 'c': 3})));
76 66
77 Expect.equals('c6 2 1', apply(c6, new ArgumentDescriptor([], null))); 67 Expect.equals('c6 2 1', apply(c6, [], null));
78 Expect.equals('c6 3 1', apply(c6, new ArgumentDescriptor([], {'a': 3}))); 68 Expect.equals('c6 3 1', apply(c6, [], {#a: 3}));
79 Expect.equals('c6 2 1', apply(c6, new ArgumentDescriptor(null, null))); 69 Expect.equals('c6 2 1', apply(c6, null, null));
80 Expect.equals('c6 2 1', apply(c6, new ArgumentDescriptor([], {}))); 70 Expect.equals('c6 2 1', apply(c6, [], {}));
81 Expect.equals('c6 3 4', 71 Expect.equals('c6 3 4', apply(c6, [], {#a: 3, #b: 4}));
82 apply(c6, new ArgumentDescriptor([], {'a': 3, 'b': 4}))); 72 Expect.equals('c6 4 3', apply(c6, [], {#b: 3, #a: 4}));
83 Expect.equals('c6 4 3', 73 Expect.equals('c6 2 3', apply(c6, [], {#b: 3}));
84 apply(c6, new ArgumentDescriptor([], {'b': 3, 'a': 4}))); 74 throwsNSME(c6, [1], {#a: 1});
85 Expect.equals('c6 2 3', 75 throwsNSME(c6, [1], {});
86 apply(c6, new ArgumentDescriptor([], {'b': 3}))); 76 throwsNSME(c6, [], {#a: 1, #b: 2, #c: 3});
87 throwsNSME(() => apply(c6, new ArgumentDescriptor([1], {'a': 1})));
88 throwsNSME(() => apply(c6, new ArgumentDescriptor([1], {})));
89 throwsNSME(() =>
90 apply(c6, new ArgumentDescriptor([], {'a': 1, 'b': 2, 'c': 3})));
91 77
92 Expect.equals('c7 7 2 1', apply(c7, new ArgumentDescriptor([7], null))); 78 Expect.equals('c7 7 2 1', apply(c7, [7], null));
93 Expect.equals('c7 7 3 1', apply(c7, new ArgumentDescriptor([7], {'a': 3}))); 79 Expect.equals('c7 7 3 1', apply(c7, [7], {#a: 3}));
94 Expect.equals('c7 7 2 1', apply(c7, new ArgumentDescriptor([7], {}))); 80 Expect.equals('c7 7 2 1', apply(c7, [7], {}));
95 Expect.equals('c7 7 3 4', 81 Expect.equals('c7 7 3 4', apply(c7, [7], {#a: 3, #b: 4}));
96 apply(c7, new ArgumentDescriptor([7], {'a': 3, 'b': 4}))); 82 Expect.equals('c7 7 4 3', apply(c7, [7], {#b: 3, #a: 4}));
97 Expect.equals('c7 7 4 3', 83 Expect.equals('c7 7 2 3', apply(c7, [7], {#b: 3}));
98 apply(c7, new ArgumentDescriptor([7], {'b': 3, 'a': 4}))); 84 throwsNSME(c7, [], {#a: 1});
99 Expect.equals('c7 7 2 3', 85 throwsNSME(c7, [], {});
100 apply(c7, new ArgumentDescriptor([7], {'b': 3}))); 86 throwsNSME(c7, [7], {#a: 1, #b: 2, #c: 3});
101 throwsNSME(() => apply(c7, new ArgumentDescriptor([], {'a': 1}))); 87
102 throwsNSME(() => apply(c7, new ArgumentDescriptor([], {}))); 88 Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], null));
103 throwsNSME(() => 89 Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], {}));
104 apply(c7, new ArgumentDescriptor([7], {'a': 1, 'b': 2, 'c': 3}))); 90 Expect.equals('c8 7 8 3 3', apply(c8, [7, 8, 3], null));
91 Expect.equals('c8 7 8 3 4', apply(c8, [7, 8, 3, 4], null));
92 throwsNSME(c8, [], null);
93 throwsNSME(c8, [], {});
94 throwsNSME(c8, [1], null);
95 throwsNSME(c8, [7, 8, 9, 10, 11], null);
105 } 96 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698