| 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 // Dart test program testing closures. | 4 // Dart test program testing closures. |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 class A { | 8 class A { |
| 9 operator -() => this; | 9 operator -() => this; |
| 10 | 10 |
| 11 foo(x) { | 11 foo(x) { |
| 12 -a; | 12 -a; |
| 13 if(x) return true; | 13 if (x) return true; |
| 14 return false; | 14 return false; |
| 15 } | 15 } |
| 16 | 16 |
| 17 loop1(x) { | 17 loop1(x) { |
| 18 -a; | 18 -a; |
| 19 while(x) return true; | 19 while (x) return true; |
| 20 return false; | 20 return false; |
| 21 } | 21 } |
| 22 | 22 |
| 23 loop2(x) { | 23 loop2(x) { |
| 24 -a; | 24 -a; |
| 25 for(;x;) return true; | 25 for (; x;) return true; |
| 26 return false; | 26 return false; |
| 27 } | 27 } |
| 28 | 28 |
| 29 loop3(x) { | 29 loop3(x) { |
| 30 -a; | 30 -a; |
| 31 var i = 0; | 31 var i = 0; |
| 32 do { | 32 do { |
| 33 if (i++ == 1) return false; | 33 if (i++ == 1) return false; |
| 34 } while(!x); | 34 } while (!x); |
| 35 return true; | 35 return true; |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 var a; | 39 var a; |
| 40 | 40 |
| 41 main() { | 41 main() { |
| 42 a = new A(); | 42 a = new A(); |
| 43 Expect.isTrue(a.foo(true)); | 43 Expect.isTrue(a.foo(true)); |
| 44 Expect.isTrue(a.loop1(true)); | 44 Expect.isTrue(a.loop1(true)); |
| 45 Expect.isTrue(a.loop2(true)); | 45 Expect.isTrue(a.loop2(true)); |
| 46 Expect.isTrue(a.loop3(true)); | 46 Expect.isTrue(a.loop3(true)); |
| 47 } | 47 } |
| OLD | NEW |