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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Tests that methods with names "get", "set" and "operator" don't | 7 // Tests that methods with names "get", "set" and "operator" don't |
8 // cause fatal problems. | 8 // cause fatal problems. |
9 | 9 |
10 // With return type. | 10 // With return type. |
11 class A { | 11 class A { |
12 int get() {return 1;} | 12 int get() { |
13 int set() {return 2;} | 13 return 1; |
14 int operator() {return 3;} | 14 } |
15 int factory() { return 4; } | 15 |
| 16 int set() { |
| 17 return 2; |
| 18 } |
| 19 |
| 20 int operator() { |
| 21 return 3; |
| 22 } |
| 23 |
| 24 int factory() { |
| 25 return 4; |
| 26 } |
16 } | 27 } |
17 | 28 |
18 // Without return types. | 29 // Without return types. |
19 class B { | 30 class B { |
20 get() {return 1;} | 31 get() { |
21 set() {return 2;} | 32 return 1; |
22 operator() {return 3;} | 33 } |
23 factory() { return 4; } | 34 |
| 35 set() { |
| 36 return 2; |
| 37 } |
| 38 |
| 39 operator() { |
| 40 return 3; |
| 41 } |
| 42 |
| 43 factory() { |
| 44 return 4; |
| 45 } |
24 } | 46 } |
25 | 47 |
26 main() { | 48 main() { |
27 { | 49 { |
28 A a = new A(); | 50 A a = new A(); |
29 Expect.equals(1, a.get()); | 51 Expect.equals(1, a.get()); |
30 Expect.equals(2, a.set()); | 52 Expect.equals(2, a.set()); |
31 Expect.equals(3, a.operator()); | 53 Expect.equals(3, a.operator()); |
32 Expect.equals(4, a.factory()); | 54 Expect.equals(4, a.factory()); |
33 } | 55 } |
34 { | 56 { |
35 B b = new B(); | 57 B b = new B(); |
36 Expect.equals(1, b.get()); | 58 Expect.equals(1, b.get()); |
37 Expect.equals(2, b.set()); | 59 Expect.equals(2, b.set()); |
38 Expect.equals(3, b.operator()); | 60 Expect.equals(3, b.operator()); |
39 Expect.equals(4, b.factory()); | 61 Expect.equals(4, b.factory()); |
40 } | 62 } |
41 } | 63 } |
OLD | NEW |