| 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 // Test parsing and resolution of argument definition test. | 5 // Test parsing and resolution of argument definition test. |
| 6 | 6 |
| 7 int test(int a, [int b = 2, int c = 3]) { | 7 int test(int a, {int b: 2, int c: 3}) { |
| 8 int result = 0; | 8 int result = 0; |
| 9 print(?b); | 9 print(?b); |
| 10 print(?result); /// 01: compile-time error | 10 print(?result); /// 01: compile-time error |
| 11 print(?a); | 11 print(?a); |
| 12 print(?b); | 12 print(?b); |
| 13 print(?c); | 13 print(?c); |
| 14 { | 14 { |
| 15 var b; | 15 var b; |
| 16 ?b; /// 02: compile-time error | 16 ?b; /// 02: compile-time error |
| 17 } | 17 } |
| 18 print((!?a?!?b:!?c) == (?a??b:?c)); | 18 print((!?a?!?b:!?c) == (?a??b:?c)); |
| 19 print(!?a?!?b:!?c == ?a??b:?c); | 19 print(!?a?!?b:!?c == ?a??b:?c); |
| 20 } | 20 } |
| 21 | 21 |
| 22 closure_test(int a, [int b = 2, int c = 3]) { | 22 closure_test(int a, {int b: 2, int c: 3}) { |
| 23 var x = 0; | 23 var x = 0; |
| 24 return () { | 24 return () { |
| 25 int result = 0; | 25 int result = 0; |
| 26 print(?b); | 26 print(?b); |
| 27 print(?result); /// 03: compile-time error | 27 print(?result); /// 03: compile-time error |
| 28 print(?x); /// 04: compile-time error | 28 print(?x); /// 04: compile-time error |
| 29 print(?a); | 29 print(?a); |
| 30 print(?b); | 30 print(?b); |
| 31 print(?c); | 31 print(?c); |
| 32 { | 32 { |
| 33 var b; | 33 var b; |
| 34 ?b; /// 05: compile-time error | 34 ?b; /// 05: compile-time error |
| 35 } | 35 } |
| 36 print((!?a?!?b:!?c) == (?a??b:?c)); | 36 print((!?a?!?b:!?c) == (?a??b:?c)); |
| 37 print(!?a?!?b:!?c == ?a??b:?c); | 37 print(!?a?!?b:!?c == ?a??b:?c); |
| 38 }; | 38 }; |
| 39 } | 39 } |
| 40 | 40 |
| 41 main() { | 41 main() { |
| 42 test(1); | 42 test(1); |
| 43 test(1, 2); | 43 test(1, b: 2); |
| 44 test(1, 2, 3); | 44 test(1, b: 2, c: 3); |
| 45 test(1, c:3); | 45 test(1, c: 3); |
| 46 | 46 |
| 47 closure_test(1)(); | 47 closure_test(1)(); |
| 48 closure_test(1, 2)(); | 48 closure_test(1, b: 2)(); |
| 49 closure_test(1, 2, 3)(); | 49 closure_test(1, b: 2, c: 3)(); |
| 50 closure_test(1, c:3)(); | 50 closure_test(1, c: 3)(); |
| 51 } | 51 } |
| OLD | NEW |