OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012, 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 StringBuffer buffer; | |
6 | |
7 topLevelMethod() { | |
8 buffer.add('t'); | |
9 } | |
10 | |
11 class A { | |
12 final Function closure; | |
13 const A(this.closure); | |
14 const A.defaultTopLevel([this.closure = topLevelMethod]); | |
15 const A.defaultStatic([this.closure = staticMethod]); | |
16 const A.defaultStatic2([this.closure = A.staticMethod]); | |
17 static staticMethod() { | |
18 buffer.add('s'); | |
19 } | |
20 run() => closure(); | |
21 } | |
22 | |
23 main() { | |
24 buffer = new StringBuffer(); | |
25 (const A(topLevelMethod)).run(); | |
26 (const A(A.staticMethod)).run(); | |
27 (const A.defaultTopLevel()).run(); | |
28 (const A.defaultStatic()).run(); | |
29 (const A.defaultStatic2()).run(); | |
30 (new A.defaultTopLevel()).run(); | |
31 (new A.defaultStatic()).run(); | |
32 (new A.defaultStatic2()).run(); | |
33 Expect.equals('tstsstss', '$buffer'); | |
kasperl
2012/08/27 13:17:26
This would probably be easier to maintain if you c
ngeoffray
2012/08/27 14:09:09
Done.
| |
34 } | |
OLD | NEW |