Chromium Code Reviews| 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 final x = foo(); | |
|
kasperl
2012/08/17 09:30:04
I guess we still need tests for the exceptional ca
floitsch
2012/09/04 17:32:21
Done.
| |
| 6 final y = y2(y3); | |
| 7 final y2 = incrementCreator(); | |
| 8 final y3 = fib(5); | |
| 9 | |
| 10 foo() => 499; | |
| 11 | |
| 12 incrementCreator() => (x) => x + 1; | |
| 13 fib(x) { | |
| 14 if (x < 2) return x; | |
| 15 return fib(x - 1) + fib(x - 2); | |
| 16 } | |
| 17 | |
| 18 class A { | |
| 19 static final a = toto(); | |
| 20 static final b = b2(b3); | |
| 21 static final b2 = decrementCreator(); | |
| 22 static final b3 = fact(5); | |
| 23 | |
| 24 static toto() => 666; | |
| 25 | |
| 26 static decrementCreator() => (x) => x - 1; | |
| 27 static fact(x) { | |
| 28 if (x <= 1) return x; | |
| 29 return x * fact(x - 1); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 main() { | |
| 34 Expect.equals(499, x); | |
| 35 Expect.equals(6, y); | |
| 36 Expect.equals(666, A.a); | |
| 37 Expect.equals(119, A.b); | |
| 38 } | |
| OLD | NEW |