| OLD | NEW |
| 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 Loading... |
| 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 -() { |
| 181 operator negate() { | |
| 182 var x = 3; | 181 var x = 3; |
| 183 return () { return x + 1; }; | 182 return () { return x + 1; }; |
| 184 } | 183 } |
| 185 | 184 |
| 186 operator[] (x) { | 185 operator[] (x) { |
| 187 return () { return x + 3; }; | 186 return () { return x + 3; }; |
| 188 } | 187 } |
| 189 | 188 |
| 190 static void test() { | 189 static void test() { |
| 191 var h = new Hoisting.negate(1); | 190 var h = new Hoisting.negate(1); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 475 |
| 477 // Test that the generated JS names don't conflict with "$" | 476 // Test that the generated JS names don't conflict with "$" |
| 478 class DartQuery { | 477 class DartQuery { |
| 479 Object wrapped; | 478 Object wrapped; |
| 480 DartQuery(this.wrapped); | 479 DartQuery(this.wrapped); |
| 481 | 480 |
| 482 $add(Object other) => other; | 481 $add(Object other) => other; |
| 483 $negate() => wrapped; | 482 $negate() => wrapped; |
| 484 | 483 |
| 485 operator +(Object other) => 123; | 484 operator +(Object other) => 123; |
| 486 operator negate() => 444; | 485 operator -() => 444; |
| 487 } | 486 } |
| 488 | 487 |
| 489 $add(Object first, Object second) => second; | 488 $add(Object first, Object second) => second; |
| 490 DartQuery $(Object obj) => new DartQuery(obj); | 489 DartQuery $(Object obj) => new DartQuery(obj); |
| 491 | 490 |
| 492 // Ensure we don't have false positive. named constructor and methods | 491 // Ensure we don't have false positive. named constructor and methods |
| 493 // are in different namespaces, therefore it is ok to have a method | 492 // are in different namespaces, therefore it is ok to have a method |
| 494 // called foo and a named constructor CLASS.foo | 493 // called foo and a named constructor CLASS.foo |
| 495 class Naming1Test { | 494 class Naming1Test { |
| 496 Naming1Test.foo() { } | 495 Naming1Test.foo() { } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 518 // NoSuchMethodError. | 517 // NoSuchMethodError. |
| 519 (e) => e is ObjectNotClosureException || e is NoSuchMethodError); | 518 (e) => e is ObjectNotClosureException || e is NoSuchMethodError); |
| 520 } | 519 } |
| 521 } | 520 } |
| 522 | 521 |
| 523 main() { | 522 main() { |
| 524 NamingTest.testMain(); | 523 NamingTest.testMain(); |
| 525 Naming1Test.main(null); | 524 Naming1Test.main(null); |
| 526 Naming2Test.main(null); | 525 Naming2Test.main(null); |
| 527 } | 526 } |
| OLD | NEW |