| 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 for testing argument definition test. | 4 // Dart test program for testing argument definition test. |
| 5 | 5 |
| 6 int test(int a, {int b: 2, int c: 3}) { | 6 int test(int a, {int b: 2, int c: 3}) { |
| 7 int result = 0; | 7 int result = 0; |
| 8 ?b; | 8 ?b; |
| 9 ?result; /// 01: compile-time error | 9 ?result; /// 01: compile-time error |
| 10 if (?a) { | 10 if (?a) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 result += 200; | 48 result += 200; |
| 49 } | 49 } |
| 50 // Equivalent to: (!?c) ? ?b : ?c. | 50 // Equivalent to: (!?c) ? ?b : ?c. |
| 51 if (!?a?!?b:!?c == ?a??b:?c) { | 51 if (!?a?!?b:!?c == ?a??b:?c) { |
| 52 result += 400; | 52 result += 400; |
| 53 } | 53 } |
| 54 return result; | 54 return result; |
| 55 }; | 55 }; |
| 56 } | 56 } |
| 57 | 57 |
| 58 tl_test([a]) => ?a; |
| 59 |
| 58 main() { | 60 main() { |
| 59 // Use a loop to test optimized version as well. | 61 // Use a loop to test optimized version as well. |
| 60 for (int i = 0; i < 1000; i++) { | 62 for (int i = 0; i < 1000; i++) { |
| 61 Expect.equals(100, test(1)); | 63 Expect.equals(100, test(1)); |
| 62 Expect.equals(720, test(1, b: 2)); | 64 Expect.equals(720, test(1, b: 2)); |
| 63 Expect.equals(523, test(1, b: 2, c: 3)); | 65 Expect.equals(523, test(1, b: 2, c: 3)); |
| 64 Expect.equals(703, test(1, c: 3)); | 66 Expect.equals(703, test(1, c: 3)); |
| 65 | 67 |
| 66 Expect.equals(100, closure_test(1)()); | 68 Expect.equals(100, closure_test(1)()); |
| 67 Expect.equals(720, closure_test(1, b: 2)()); | 69 Expect.equals(720, closure_test(1, b: 2)()); |
| 68 Expect.equals(523, closure_test(1, b: 2, c: 3)()); | 70 Expect.equals(523, closure_test(1, b: 2, c: 3)()); |
| 69 Expect.equals(703, closure_test(1, c: 3)()); | 71 Expect.equals(703, closure_test(1, c: 3)()); |
| 72 |
| 73 Expect.equals(true, tl_test(0)); |
| 74 Expect.equals(false, tl_test()); |
| 70 } | 75 } |
| 71 } | 76 } |
| OLD | NEW |