OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 | 6 |
7 String log; | 7 String log; |
8 init() { log = ''; } | 8 init() { |
9 logit(msg) { return log = '$log$msg'; } | 9 log = ''; |
| 10 } |
| 11 |
| 12 logit(msg) { |
| 13 return log = '$log$msg'; |
| 14 } |
10 | 15 |
11 class Base { | 16 class Base { |
12 var b; | 17 var b; |
13 Base.arg0() : b = logit('b') { | 18 Base.arg0() : b = logit('b') { |
14 logit('B'); | 19 logit('B'); |
15 } | 20 } |
16 Base.arg1(a) : b = logit('b') { | 21 Base.arg1(a) : b = logit('b') { |
17 logit('B'); | 22 logit('B'); |
18 } | 23 } |
19 Base.arg2(a, b) : b = logit('b') { | 24 Base.arg2(a, b) : b = logit('b') { |
20 logit('B'); | 25 logit('B'); |
21 } | 26 } |
22 } | 27 } |
23 | 28 |
24 class Sub extends Base { | 29 class Sub extends Base { |
25 var x; | 30 var x; |
26 var s; | 31 var s; |
27 Sub.arg0() : x = logit('x'), super.arg0(), s = logit('s') { | 32 Sub.arg0() |
| 33 : x = logit('x'), |
| 34 super.arg0(), |
| 35 s = logit('s') { |
28 logit('S'); | 36 logit('S'); |
29 } | 37 } |
30 Sub.arg1(a) : x = logit('x'), super.arg1(logit('1')), s = logit('s') { | 38 Sub.arg1(a) |
| 39 : x = logit('x'), |
| 40 super.arg1(logit('1')), |
| 41 s = logit('s') { |
31 logit('S'); | 42 logit('S'); |
32 } | 43 } |
33 Sub.arg2(a, b) : x = logit('x'), super.arg2(logit('1'), logit('2')), s = logit
('s') { | 44 Sub.arg2(a, b) |
| 45 : x = logit('x'), |
| 46 super.arg2(logit('1'), logit('2')), |
| 47 s = logit('s') { |
34 logit('S'); | 48 logit('S'); |
35 } | 49 } |
36 } | 50 } |
37 | 51 |
38 test(fun(), String result) { | 52 test(fun(), String result) { |
39 init(); | 53 init(); |
40 fun(); | 54 fun(); |
41 Expect.isTrue(log == result); | 55 Expect.isTrue(log == result); |
42 } | 56 } |
43 | 57 |
44 main() { | 58 main() { |
45 test(() => new Sub.arg0(), 'xsbBS'); | 59 test(() => new Sub.arg0(), 'xsbBS'); |
46 test(() => new Sub.arg1(1), 'x1sbBS'); | 60 test(() => new Sub.arg1(1), 'x1sbBS'); |
47 test(() => new Sub.arg2(1, 2), 'x12sbBS'); | 61 test(() => new Sub.arg2(1, 2), 'x12sbBS'); |
48 } | 62 } |
OLD | NEW |