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

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

Issue 11194033: Enable constructor name check by default (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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
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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 $add(Object other) => other; 481 $add(Object other) => other;
482 $negate() => wrapped; 482 $negate() => wrapped;
483 483
484 operator +(Object other) => 123; 484 operator +(Object other) => 123;
485 operator -() => 444; 485 operator -() => 444;
486 } 486 }
487 487
488 $add(Object first, Object second) => second; 488 $add(Object first, Object second) => second;
489 DartQuery $(Object obj) => new DartQuery(obj); 489 DartQuery $(Object obj) => new DartQuery(obj);
490 490
491 // Ensure we don't have false positive. named constructor and methods
492 // are in different namespaces, therefore it is ok to have a method
493 // called foo and a named constructor CLASS.foo
494 class Naming1Test {
495 Naming1Test.foo() { }
496 foo() { }
497
498 static void main(args) {
499 var a = new Naming1Test.foo();
500 a.foo();
501 }
502 }
503 491
504 // Ensure we don't have false positive. 492 // Ensure we don't have false positive.
505 class Naming2Test { 493 class Naming2Test {
506 Naming2Test() { } 494 Naming2Test() { }
507 int get foo { return 1; } 495 int get foo { return 1; }
508 set foo(x) { } 496 set foo(x) { }
509 497
510 static void main(args) { 498 static void main(args) {
511 var a = new Naming2Test(); 499 var a = new Naming2Test();
512 Expect.throws( 500 Expect.throws(
513 () => a.foo(2), 501 () => a.foo(2),
514 // We check for both exceptions because the exact exception to 502 // We check for both exceptions because the exact exception to
515 // throw is hard to compute on some browsers. 503 // throw is hard to compute on some browsers.
516 // Also, ObjectNotClosureException should probably implement 504 // Also, ObjectNotClosureException should probably implement
517 // NoSuchMethodError. 505 // NoSuchMethodError.
518 (e) => e is ObjectNotClosureException || e is NoSuchMethodError); 506 (e) => e is ObjectNotClosureException || e is NoSuchMethodError);
519 } 507 }
520 } 508 }
521 509
522 main() { 510 main() {
523 NamingTest.testMain(); 511 NamingTest.testMain();
524 Naming1Test.main(null);
525 Naming2Test.main(null); 512 Naming2Test.main(null);
526 } 513 }
OLDNEW
« tests/language/named_constructor_test.dart ('K') | « tests/language/named_constructor_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698