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

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

Issue 11377102: Remove named function literals from library and tests (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | « tests/language/local_function2_test.dart ('k') | tests/language/param2_test.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) 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 // Dart test program testing closures. 4 // Dart test program testing closures.
5 5
6 class LocalFunctionTest { 6 class LocalFunctionTest {
7 LocalFunctionTest() : field1 = 100, field2_ = 200 { } 7 LocalFunctionTest() : field1 = 100, field2_ = 200 { }
8 static int f(int n) { 8 static int f(int n) {
9 int a = 0; 9 int a = 0;
10 g(int m) { 10 g(int m) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return 0; 86 return 0;
87 } else { 87 } else {
88 return 1 + foo(n - 1); // Local foo, not static foo. 88 return 1 + foo(n - 1); // Local foo, not static foo.
89 } 89 }
90 }; 90 };
91 return foo(n); // Local foo, not static foo. 91 return foo(n); // Local foo, not static foo.
92 } 92 }
93 static void hep(Function f) { 93 static void hep(Function f) {
94 f(); 94 f();
95 } 95 }
96 static testSelfReference3(int n) {
97 int i = 0;
98 var yup; // Not in same scope as yup below.
99 hep(yup() {
100 if (++i < n) hep(yup);
101 });
102 return i;
103 }
104 static testNesting(int n) { 96 static testNesting(int n) {
105 var a = new List(n*n); 97 var a = new List(n*n);
106 f0() { 98 f0() {
107 for (int i = 0; i < n; i++) { 99 for (int i = 0; i < n; i++) {
108 int vi = i; 100 int vi = i;
109 f1() { 101 f1() {
110 for (int j = 0; j < n; j++) { 102 for (int j = 0; j < n; j++) {
111 int vj = j; 103 int vj = j;
112 a[i*n + j] = () => vi*n + vj; 104 a[i*n + j] = () => vi*n + vj;
113 } 105 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return f(n); 173 return f(n);
182 } 174 }
183 175
184 static testMain() { 176 static testMain() {
185 Expect.equals(2*(3*2 + 2 + 1), f(2)); 177 Expect.equals(2*(3*2 + 2 + 1), f(2));
186 Expect.equals(10*10 + 10*9/2, h(10)); 178 Expect.equals(10*10 + 10*9/2, h(10));
187 Expect.equals(90, h2(10)); 179 Expect.equals(90, h2(10));
188 Expect.equals(320, new LocalFunctionTest().method(10)); 180 Expect.equals(320, new LocalFunctionTest().method(10));
189 Expect.equals(145, new LocalFunctionTest().testExecute(10)); 181 Expect.equals(145, new LocalFunctionTest().testExecute(10));
190 Expect.equals(5, testSelfReference1(5)); 182 Expect.equals(5, testSelfReference1(5));
191 Expect.equals(5, testSelfReference3(5));
192 Expect.equals(24*25/2, testNesting(5)); 183 Expect.equals(24*25/2, testNesting(5));
193 Expect.equals(true, testClosureCallStatement(7)); 184 Expect.equals(true, testClosureCallStatement(7));
194 Expect.equals(99, doThis(10, int _(n) => n * n - 1));
195 Expect.equals(99, doThis(10, int f(n) => n * n - 1));
196 Expect.equals(99, doThis(10, (n) => n * n - 1)); 185 Expect.equals(99, doThis(10, (n) => n * n - 1));
197 Expect.equals(99, doThis(10, f(n) => n * n - 1));
198 testExceptions(); 186 testExceptions();
199 } 187 }
200 } 188 }
201 189
202 main() { 190 main() {
203 LocalFunctionTest.testMain(); 191 LocalFunctionTest.testMain();
204 } 192 }
OLDNEW
« no previous file with comments | « tests/language/local_function2_test.dart ('k') | tests/language/param2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698