| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 | 4 |
| 5 final x = foo(); | 5 final x = foo(); |
| 6 final y = y2(y3); | 6 final y = y2(y3); |
| 7 final y2 = incrementCreator(); | 7 final y2 = incrementCreator(); |
| 8 final y3 = fib(5); | 8 final y3 = fib(5); |
| 9 | 9 |
| 10 foo() => 499; | 10 foo() => 499; |
| 11 | 11 |
| 12 incrementCreator() => (x) => x + 1; | 12 incrementCreator() => (x) => x + 1; |
| 13 fib(x) { | 13 fib(x) { |
| 14 if (x < 2) return x; | 14 if (x < 2) return x; |
| 15 return fib(x - 1) + fib(x - 2); | 15 return fib(x - 1) + fib(x - 2); |
| 16 } | 16 } |
| 17 | 17 |
| 18 var count = 0; | 18 var count = 0; |
| 19 sideEffect() => count++; | 19 sideEffect() => count++; |
| 20 | 20 |
| 21 final t = sideEffect(); | 21 final t = sideEffect(); |
| 22 final t2 = sideEffect(); | 22 var t2 = sideEffect(); |
| 23 | 23 |
| 24 class A { | 24 class A { |
| 25 static final a = toto(); | 25 static final a = toto(); |
| 26 static final b = b2(b3); | 26 static final b = b2(b3); |
| 27 static final b2 = decrementCreator(); | 27 static final b2 = decrementCreator(); |
| 28 static final b3 = fact(5); | 28 static final b3 = fact(5); |
| 29 | 29 |
| 30 static toto() => 666; | 30 static toto() => 666; |
| 31 | 31 |
| 32 static decrementCreator() => (x) => x - 1; | 32 static decrementCreator() => (x) => x - 1; |
| 33 static fact(x) { | 33 static fact(x) { |
| 34 if (x <= 1) return x; | 34 if (x <= 1) return x; |
| 35 return x * fact(x - 1); | 35 return x * fact(x - 1); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 main() { | 39 main() { |
| 40 Expect.equals(499, x); | 40 Expect.equals(499, x); |
| 41 Expect.equals(6, y); | 41 Expect.equals(6, y); |
| 42 Expect.equals(666, A.a); | 42 Expect.equals(666, A.a); |
| 43 Expect.equals(119, A.b); | 43 Expect.equals(119, A.b); |
| 44 Expect.equals(0, t); | 44 Expect.equals(0, t); |
| 45 t2 = 499; | 45 t2 = 499; |
| 46 Expect.equals(499, t2); | 46 Expect.equals(499, t2); |
| 47 Expect.equals(1, count); | 47 Expect.equals(1, count); |
| 48 } | 48 } |
| OLD | NEW |