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

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

Issue 9107070: Proper handling of built-in identifiers (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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.status ('k') | tests/language/src/PseudoKWTest.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 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 operator negate() { 180 operator negate() {
181 var x = 3; 181 var x = 3;
182 return () { return x + 1; }; 182 return () { return x + 1; };
183 } 183 }
184 184
185 negate(x) {
186 return () { return x + 2; };
187 }
188
189 operator[] (x) { 185 operator[] (x) {
190 return () { return x + 3; }; 186 return () { return x + 3; };
191 } 187 }
192 188
193 static void test() { 189 static void test() {
194 var h = new Hoisting.negate(1); 190 var h = new Hoisting.negate(1);
195 Expect.equals(1, (h.f_)()); 191 Expect.equals(1, (h.f_)());
196 var f = -h; 192 var f = -h;
197 Expect.equals(4, f()); 193 Expect.equals(4, f());
198 Expect.equals(6, h.negate(4)()); 194 Expect.equals(4, h.negate()());
199 Expect.equals(7, h[4]()); 195 Expect.equals(7, h[4]());
200 } 196 }
201 } 197 }
202 198
203 // 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
204 // 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
205 class NamingTest { 201 class NamingTest {
206 static int count; 202 static int count;
207 203
208 static testExceptionNaming() { 204 static testExceptionNaming() {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 Naming2Test() { } 507 Naming2Test() { }
512 int get foo() { return 1; } 508 int get foo() { return 1; }
513 set foo(x) { } 509 set foo(x) { }
514 510
515 static void main(args) { 511 static void main(args) {
516 var a = new Naming2Test(); 512 var a = new Naming2Test();
517 Expect.throws(() => a.foo(2), (e) => e is ObjectNotClosureException); 513 Expect.throws(() => a.foo(2), (e) => e is ObjectNotClosureException);
518 } 514 }
519 } 515 }
520 516
521 // Ensure we don't have false positivesj.
522 class Naming3Test {
523 Naming3Test() { }
524 operator negate() { }
525 negate() => 777;
526
527 static void main(args) {
528 var a = new Naming3Test();
529 Expect.equals(777, a.negate());
530 }
531 }
532
533 main() { 517 main() {
534 NamingTest.testMain(); 518 NamingTest.testMain();
535 Naming1Test.main(null); 519 Naming1Test.main(null);
536 Naming2Test.main(null); 520 Naming2Test.main(null);
537 Naming3Test.main(null);
538 } 521 }
OLDNEW
« no previous file with comments | « tests/language/language.status ('k') | tests/language/src/PseudoKWTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698