Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // Dart test program for testing named parameters. | |
| 5 | |
| 6 | |
| 7 // Expect compile-time error as no default values are allowed | |
| 8 // in closure type definitions. | |
| 9 typedef void Callback([String msg | |
| 10 = "" /// 01: compile-time error | |
| 11 ]); | |
| 12 | |
| 13 class NamedParametersAggregatedTests { | |
| 14 | |
| 15 static int F31(int a, [int b = 20, int c = 30]) { | |
| 16 return 100*(100*a + b) + c; | |
| 17 } | |
| 18 | |
| 19 static int f_missing_comma(a | |
| 20 [b = 42] /// 02: compile-time error | |
| 21 ) => a; | |
| 22 | |
| 23 var _handler = null; | |
| 24 | |
| 25 // Expect compile-time error as no default values | |
| 26 // are allowed in closure type. | |
| 27 void InstallCallback(void cb([String msg | |
| 28 = null /// 03: compile-time error | |
| 29 ])) { | |
| 30 _handler = cb; | |
| 31 } | |
| 32 | |
| 33 static testMain() { | |
| 34 // Expect compile-time error due to missing comma in | |
| 35 // function definition. | |
| 36 f_missing_comma(10 | |
| 37 , 25 /// 02: continued | |
| 38 ); | |
| 39 | |
| 40 // Expect compile-time erorr due to duplicate named argument. | |
| 41 F31(10, b:25 | |
| 42 , b:35 /// 04: compile-time error | |
| 43 ); | |
| 44 | |
| 45 // Expect compile-time error due to missing positional argument. | |
| 46 F31(b:25, c:35); /// 05: compile-time error | |
| 47 | |
| 48 Callback cb1 = null; | |
|
ahe
2012/08/23 11:39:25
I discussed this with Kasper, and we don't want to
| |
| 49 | |
| 50 (new NamedParametersAggregatedTests()).InstallCallback(null); | |
| 51 } | |
| 52 | |
| 53 } | |
| 54 | |
| 55 | |
| 56 main() { | |
| 57 NamedParametersAggregatedTests.testMain(); | |
|
ahe
2012/08/23 11:39:25
This is a left-over from when we didn't have top-l
| |
| 58 } | |
| OLD | NEW |