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 class A { | 7 class A { |
8 foo() { return 499; } | 8 foo() { |
9 bar(x) { return x + 499; } | 9 return 499; |
10 baz() { return 54; } | 10 } |
11 titi() { return 123; } | 11 |
| 12 bar(x) { |
| 13 return x + 499; |
| 14 } |
| 15 |
| 16 baz() { |
| 17 return 54; |
| 18 } |
| 19 |
| 20 titi() { |
| 21 return 123; |
| 22 } |
12 } | 23 } |
13 | 24 |
14 class B { | 25 class B { |
15 foo() { return 42; } | 26 foo() { |
16 bar(x) { return x + 42; } | 27 return 42; |
17 toto() { return foo() + 42; } | 28 } |
| 29 |
| 30 bar(x) { |
| 31 return x + 42; |
| 32 } |
| 33 |
| 34 toto() { |
| 35 return foo() + 42; |
| 36 } |
18 } | 37 } |
19 | 38 |
20 class C extends A { | 39 class C extends A { |
21 foo() { return 99; } | 40 foo() { |
22 bar(x) { return x + 99; } | 41 return 99; |
| 42 } |
| 43 |
| 44 bar(x) { |
| 45 return x + 99; |
| 46 } |
23 } | 47 } |
24 | 48 |
25 void main() { | 49 void main() { |
26 var a = new A(); | 50 var a = new A(); |
27 Expect.equals(499, a.foo()); | 51 Expect.equals(499, a.foo()); |
28 Expect.equals(500, a.bar(1)); | 52 Expect.equals(500, a.bar(1)); |
29 var b = new B(); | 53 var b = new B(); |
30 Expect.equals(42, b.foo()); | 54 Expect.equals(42, b.foo()); |
31 Expect.equals(43, b.bar(1)); | 55 Expect.equals(43, b.bar(1)); |
32 var c = new C(); | 56 var c = new C(); |
33 Expect.equals(99, c.foo()); | 57 Expect.equals(99, c.foo()); |
34 Expect.equals(100, c.bar(1)); | 58 Expect.equals(100, c.bar(1)); |
35 | 59 |
36 Expect.equals(54, a.baz()); | 60 Expect.equals(54, a.baz()); |
37 Expect.equals(54, c.baz()); | 61 Expect.equals(54, c.baz()); |
38 | 62 |
39 // We don't call a.titi. This means that the compiler needs to trigger the | 63 // We don't call a.titi. This means that the compiler needs to trigger the |
40 // compilation of A.titi by going through the super-chain. | 64 // compilation of A.titi by going through the super-chain. |
41 Expect.equals(123, c.titi()); | 65 Expect.equals(123, c.titi()); |
42 | 66 |
43 Expect.equals(84, b.toto()); | 67 Expect.equals(84, b.toto()); |
44 } | 68 } |
OLD | NEW |