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

Side by Side Diff: tests/language/named_parameters_with_conversions_test.dart

Issue 18170003: Fix bug in the inliner when dealing with named optional parameters. (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
« no previous file with comments | « runtime/vm/flow_graph_inliner.cc ('k') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Test named arguments work as expected regardless of whether the function or 5 // Test named arguments work as expected regardless of whether the function or
6 // method is called via function call syntax or method call syntax. 6 // method is called via function call syntax or method call syntax.
7 // VMOptions=--optimization-counter-threshold=10
7 8
8 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
9 10
10 11
11 Validate(tag, a, b) { 12 Validate(tag, a, b) {
12 // tag encodes which parameters are passed in with values a: 111, b: 222. 13 // tag encodes which parameters are passed in with values a: 111, b: 222.
13 if (tag == 'ab') { 14 if (tag == 'ab') {
14 Expect.equals(a, 111); 15 Expect.equals(a, 111);
15 Expect.equals(b, 222); 16 Expect.equals(b, 222);
16 } 17 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 a.foo('ab', 111, 222); 93 a.foo('ab', 111, 222);
93 a.foo2('a', a: 111); 94 a.foo2('a', a: 111);
94 a.foo2('b', b: 222); 95 a.foo2('b', b: 222);
95 a.foo2('ab', a: 111, b: 222); 96 a.foo2('ab', a: 111, b: 222);
96 a.foo2('ab', b: 222, a: 111); 97 a.foo2('ab', b: 222, a: 111);
97 98
98 Expect.equals(7, a.calls); 99 Expect.equals(7, a.calls);
99 100
100 checkException(() => a.foo()); // Too few arguments. 101 checkException(() => a.foo()); // Too few arguments.
101 checkException(() => a.foo('abc', 1, 2, 3)); // Too many arguments. 102 checkException(() => a.foo('abc', 1, 2, 3)); // Too many arguments.
102 checkException(() => a.foo2('c', c: 1)); // Bad name. 103 checkException(() => a.foo2('c', c: 1)); // Bad name.
104 checkException(() => a.foo2('c', a:111, c: 1)); // Bad name.
103 105
104 Expect.equals(7, a.calls); 106 Expect.equals(7, a.calls);
105 } 107 }
106 108
107 static testFunctionCallSyntax(a) { 109 static testFunctionCallSyntax(a) {
108 var f = a.foo; 110 var f = a.foo;
109 var f2 = a.foo2; 111 var f2 = a.foo2;
110 f(''); 112 f('');
111 f('a', 111); 113 f('a', 111);
112 f('ab', 111, 222); 114 f('ab', 111, 222);
113 f2('a', a: 111); 115 f2('a', a: 111);
114 f2('b', b: 222); 116 f2('b', b: 222);
115 f2('ab', a: 111, b: 222); 117 f2('ab', a: 111, b: 222);
116 f2('ab', b: 222, a: 111); 118 f2('ab', b: 222, a: 111);
117 119
118 Expect.equals(7, a.calls); 120 Expect.equals(7, a.calls);
119 121
120 checkException(() => f()); // Too few arguments. 122 checkException(() => f()); // Too few arguments.
121 checkException(() => f('abc', 1, 2, 3)); // Too many arguments. 123 checkException(() => f('abc', 1, 2, 3)); // Too many arguments.
122 checkException(() => f2('c', c: 1)); // Bad name. 124 checkException(() => f2('c', c: 1)); // Bad name.
125 checkException(() => f2('c', a: 111, c: 1)); // Bad name.
123 126
124 Expect.equals(7, a.calls); 127 Expect.equals(7, a.calls);
125 } 128 }
126 129
127 static testMain() { 130 static testMain() {
128 // 'Plain' calls where the method/field syntax matches the object. 131 // 'Plain' calls where the method/field syntax matches the object.
129 testMethodCallSyntax(new HasMethod()); 132 testMethodCallSyntax(new HasMethod());
130 testFunctionCallSyntax(new HasField()); 133 testFunctionCallSyntax(new HasField());
131 134
132 // 'Conversion' calls where method/field call syntax does not match the 135 // 'Conversion' calls where method/field call syntax does not match the
133 // object. 136 // object.
134 testMethodCallSyntax(new HasField()); 137 testMethodCallSyntax(new HasField());
135 testFunctionCallSyntax(new HasMethod()); 138 testFunctionCallSyntax(new HasMethod());
136 } 139 }
137 } 140 }
138 141
139 main() { 142 main() {
140 NamedParametersWithConversionsTest.testMain(); 143 for (var i = 0; i < 20; i++) {
144 NamedParametersWithConversionsTest.testMain();
145 }
141 } 146 }
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_inliner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698