Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: tests/language/methods_as_constants_test.dart

Issue 10872059: Static and top-level methods can be compile time constants. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW
« lib/compiler/implementation/ssa/nodes.dart ('K') | « tests/co19/co19-dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698