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

Side by Side Diff: tests/language/src/LocalFunctionTest.dart

Issue 10188004: Provide better ToCString description for closures (issue 2680). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « tests/language/src/LocalFunction3Test.dart ('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 // 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 (LocalFunctionTest.set_field5_func)(x); 131 (LocalFunctionTest.set_field5_func)(x);
132 Expect.equals(x * x, LocalFunctionTest.field5); 132 Expect.equals(x * x, LocalFunctionTest.field5);
133 return true; 133 return true;
134 } 134 }
135 135
136 static testExceptions() { 136 static testExceptions() {
137 var f = (int n) => n + 1; 137 var f = (int n) => n + 1;
138 Expect.equals(2, f(1)); 138 Expect.equals(2, f(1));
139 Expect.equals(true, f is Function); 139 Expect.equals(true, f is Function);
140 Expect.equals(true, f is Object); 140 Expect.equals(true, f is Object);
141 Expect.equals("Closure", f.toString()); 141 Expect.equals(true, f.toString().startsWith("Closure"));
142 bool exception_caught = false; 142 bool exception_caught = false;
143 try { 143 try {
144 f(1, 2); 144 f(1, 2);
145 } catch (ClosureArgumentMismatchException e) { 145 } catch (ClosureArgumentMismatchException e) {
146 exception_caught = true; 146 exception_caught = true;
147 } 147 }
148 Expect.equals(true, exception_caught); 148 Expect.equals(true, exception_caught);
149 exception_caught = false; 149 exception_caught = false;
150 try { 150 try {
151 f(); 151 f();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 Expect.equals(99, doThis(10, int f(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)); 196 Expect.equals(99, doThis(10, (n) => n * n - 1));
197 Expect.equals(99, doThis(10, f(n) => n * n - 1)); 197 Expect.equals(99, doThis(10, f(n) => n * n - 1));
198 testExceptions(); 198 testExceptions();
199 } 199 }
200 } 200 }
201 201
202 main() { 202 main() {
203 LocalFunctionTest.testMain(); 203 LocalFunctionTest.testMain();
204 } 204 }
OLDNEW
« no previous file with comments | « tests/language/src/LocalFunction3Test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698