OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'expect.dart'; |
| 6 |
| 7 class A { |
| 8 A() { |
| 9 print("A"); |
| 10 } |
| 11 |
| 12 hello() { |
| 13 print("A.hello()"); |
| 14 return 1; |
| 15 } |
| 16 |
| 17 hello1(a) { |
| 18 print("A.hello1()"); |
| 19 print(a); |
| 20 return 1; |
| 21 } |
| 22 |
| 23 foo(a, [b]) { |
| 24 print("A.foo()"); |
| 25 print(a); |
| 26 print(b); |
| 27 return 1; |
| 28 } |
| 29 |
| 30 bar(a, {b}) { |
| 31 print("A.bar()"); |
| 32 print(a); |
| 33 print(b); |
| 34 return 1; |
| 35 } |
| 36 } |
| 37 |
| 38 class B extends A { |
| 39 hello() { |
| 40 print("B.hello()"); |
| 41 return 2; |
| 42 } |
| 43 |
| 44 bar(a, {b}) { |
| 45 print("B.bar()"); |
| 46 print(a); |
| 47 print(b); |
| 48 return 2; |
| 49 } |
| 50 } |
| 51 |
| 52 main() { |
| 53 var o = new B(); |
| 54 |
| 55 // Base class methods. |
| 56 Expect.isTrue(o.hello1(1) == 1); |
| 57 Expect.isTrue(o.foo(1) == 1); |
| 58 Expect.isTrue(o.foo(1, 2) == 1); |
| 59 |
| 60 // Overwritten methods. |
| 61 Expect.isTrue(o.hello() == 2); |
| 62 Expect.isTrue(o.bar(1) == 2); |
| 63 Expect.isTrue(o.bar(1, b: 2) == 2); |
| 64 } |
OLD | NEW |