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

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

Issue 10830253: Support for new operator - (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/language_dart2js.status ('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 class A { 5 class A {
6 A() { NamingTest.count++; } 6 A() { NamingTest.count++; }
7 foo(a, b) { 7 foo(a, b) {
8 Expect.equals(1, a); 8 Expect.equals(1, a);
9 Expect.equals(2, b); 9 Expect.equals(2, b);
10 } 10 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 Expect.equals(42, bug.x); 170 Expect.equals(42, bug.x);
171 } 171 }
172 } 172 }
173 173
174 class Hoisting { 174 class Hoisting {
175 var f_; 175 var f_;
176 Hoisting.negate(var x) { 176 Hoisting.negate(var x) {
177 f_ = () { return x; }; 177 f_ = () { return x; };
178 } 178 }
179 179
180 // TODO(hausner): Rename to operator -.
180 operator negate() { 181 operator negate() {
181 var x = 3; 182 var x = 3;
182 return () { return x + 1; }; 183 return () { return x + 1; };
183 } 184 }
184 185
185 operator[] (x) { 186 operator[] (x) {
186 return () { return x + 3; }; 187 return () { return x + 3; };
187 } 188 }
188 189
189 static void test() { 190 static void test() {
190 var h = new Hoisting.negate(1); 191 var h = new Hoisting.negate(1);
191 Expect.equals(1, (h.f_)()); 192 Expect.equals(1, (h.f_)());
192 var f = -h; 193 var f = -h;
193 Expect.equals(4, f()); 194 Expect.equals(4, f());
194 Expect.equals(4, h.negate()());
195 Expect.equals(7, h[4]()); 195 Expect.equals(7, h[4]());
196 } 196 }
197 } 197 }
198 198
199 // It is not possible to make sure that the backend uses the hardcoded names 199 // It is not possible to make sure that the backend uses the hardcoded names
200 // we are testing against. This test might therefore become rapidly out of date 200 // we are testing against. This test might therefore become rapidly out of date
201 class NamingTest { 201 class NamingTest {
202 static int count; 202 static int count;
203 203
204 static testExceptionNaming() { 204 static testExceptionNaming() {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 var a = new Naming2Test(); 512 var a = new Naming2Test();
513 Expect.throws(() => a.foo(2), (e) => e is ObjectNotClosureException); 513 Expect.throws(() => a.foo(2), (e) => e is ObjectNotClosureException);
514 } 514 }
515 } 515 }
516 516
517 main() { 517 main() {
518 NamingTest.testMain(); 518 NamingTest.testMain();
519 Naming1Test.main(null); 519 Naming1Test.main(null);
520 Naming2Test.main(null); 520 Naming2Test.main(null);
521 } 521 }
OLDNEW
« no previous file with comments | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698