| 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 // Dart test program to check that we can resolve unqualified identifiers | 4 // Dart test program to check that we can resolve unqualified identifiers |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 | |
| 9 class B { | 8 class B { |
| 10 B(x, y) : b = y { } | 9 B(x, y) : b = y {} |
| 11 var b; | 10 var b; |
| 12 | 11 |
| 13 get_b() { | 12 get_b() { |
| 14 // Resolving unqualified instance method. | 13 // Resolving unqualified instance method. |
| 15 return really_really_get_it(); | 14 return really_really_get_it(); |
| 16 } | 15 } |
| 17 | 16 |
| 18 really_really_get_it() { | 17 really_really_get_it() { |
| 19 return 5; | 18 return 5; |
| 20 } | 19 } |
| 21 } | 20 } |
| 22 | 21 |
| 23 | |
| 24 class UnqualNameTest { | 22 class UnqualNameTest { |
| 25 | |
| 26 static eleven() { | 23 static eleven() { |
| 27 return 11; | 24 return 11; |
| 28 } | 25 } |
| 29 | 26 |
| 30 static testMain() { | 27 static testMain() { |
| 31 var o = new B(3, 5); | 28 var o = new B(3, 5); |
| 32 Expect.equals(11, eleven()); // Unqualified static method call. | 29 Expect.equals(11, eleven()); // Unqualified static method call. |
| 33 Expect.equals(5, o.get_b()); | 30 Expect.equals(5, o.get_b()); |
| 34 | 31 |
| 35 // Check whether we handle variable initializers correctly. | 32 // Check whether we handle variable initializers correctly. |
| 36 var a = 1, x, b = a + 3; | 33 var a = 1, x, b = a + 3; |
| 37 Expect.equals(5, a + b); | 34 Expect.equals(5, a + b); |
| 38 } | 35 } |
| 39 } | 36 } |
| 40 | 37 |
| 41 main() { | 38 main() { |
| 42 UnqualNameTest.testMain(); | 39 UnqualNameTest.testMain(); |
| 43 } | 40 } |
| OLD | NEW |