| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Test that a getter is evaluated after the arguments, when a getter is | 5 // Test that a getter is evaluated after the arguments, when a getter is |
| 6 // for invoking a method. See chapter 'Method Invocation' in specification. | 6 // for invoking a method. See chapter 'Method Invocation' in specification. |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 var counter = 0; | 10 var counter = 0; |
| 11 | 11 |
| 12 class Test1 { | 12 class Test1 { |
| 13 get a { | 13 get a { |
| 14 Expect.equals(1, counter); | 14 Expect.equals(1, counter); |
| 15 counter++; | 15 counter++; |
| 16 return (c) { }; | 16 return (c) {}; |
| 17 } | 17 } |
| 18 | 18 |
| 19 b() { | 19 b() { |
| 20 Expect.equals(0, counter); | 20 Expect.equals(0, counter); |
| 21 counter++; | 21 counter++; |
| 22 return 1; | 22 return 1; |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 class Test2 { | 26 class Test2 { |
| 27 static get a { | 27 static get a { |
| 28 Expect.equals(0, counter); | 28 Expect.equals(0, counter); |
| 29 counter++; | 29 counter++; |
| 30 return (c) { }; | 30 return (c) {}; |
| 31 } | 31 } |
| 32 | 32 |
| 33 static b() { | 33 static b() { |
| 34 Expect.equals(1, counter); | 34 Expect.equals(1, counter); |
| 35 counter++; | 35 counter++; |
| 36 return 1; | 36 return 1; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 get a { | 40 get a { |
| 41 Expect.equals(0, counter); | 41 Expect.equals(0, counter); |
| 42 counter++; | 42 counter++; |
| 43 return (c) { }; | 43 return (c) {}; |
| 44 } | 44 } |
| 45 | 45 |
| 46 b() { | 46 b() { |
| 47 Expect.equals(1, counter); | 47 Expect.equals(1, counter); |
| 48 counter++; | 48 counter++; |
| 49 return 1; | 49 return 1; |
| 50 } | 50 } |
| 51 | 51 |
| 52 main() { | 52 main() { |
| 53 var failures = []; | 53 var failures = []; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 80 failures.add(stack); | 80 failures.add(stack); |
| 81 } | 81 } |
| 82 // If any of the tests failed print out the details and fail the test. | 82 // If any of the tests failed print out the details and fail the test. |
| 83 if (failures.length != 0) { | 83 if (failures.length != 0) { |
| 84 for (var msg in failures) { | 84 for (var msg in failures) { |
| 85 print(msg.toString()); | 85 print(msg.toString()); |
| 86 } | 86 } |
| 87 throw "${failures.length ~/ 2} tests failed."; | 87 throw "${failures.length ~/ 2} tests failed."; |
| 88 } | 88 } |
| 89 } | 89 } |
| OLD | NEW |