Chromium Code Reviews| 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 for redirection constructors. | 4 // Dart test program for redirection constructors. |
| 5 | 5 |
| 6 class A { | 6 class A { |
| 7 var x; | 7 var x; |
| 8 A(this.x) {} | 8 A(this.x) {} |
| 9 A.named(x, int y) : this(x + y); | 9 A.named(x, int y) : this(x + y); |
| 10 A.named2(int x, int y, z) : this.named(staticFun(x, y), z); | 10 A.named2(int x, int y, z) : this.named(staticFun(x, y), z); |
| 11 | 11 |
| 12 static | |
|
kasperl
2012/03/12 12:14:36
Maybe add a comment that explain why this works?
ahe
2012/03/12 15:48:28
Done.
| |
| 13 moreStaticFun() {} /// 01: compile-time error | |
| 12 int staticFun(int v1, int v2) { | 14 int staticFun(int v1, int v2) { |
| 13 return v1 * v2; | 15 return v1 * v2; |
| 14 } | 16 } |
| 15 } | 17 } |
| 16 | 18 |
| 17 class B extends A { | 19 class B extends A { |
| 18 B(y) : super(y + 1) {} | 20 B(y) : super(y + 1) {} |
| 19 B.named(y) : super.named(y, y + 1) {} | 21 B.named(y) : super.named(y, y + 1) {} |
| 20 } | 22 } |
| 21 | 23 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 52 D d = const D(498); | 54 D d = const D(498); |
| 53 Expect.equals(499, d.x); | 55 Expect.equals(499, d.x); |
| 54 d = const D.named(249); | 56 d = const D.named(249); |
| 55 Expect.equals(499, d.x); | 57 Expect.equals(499, d.x); |
| 56 } | 58 } |
| 57 } | 59 } |
| 58 | 60 |
| 59 main() { | 61 main() { |
| 60 ConstructorRedirectTest.testMain(); | 62 ConstructorRedirectTest.testMain(); |
| 61 } | 63 } |
| OLD | NEW |