Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: tests/language/named_parameters_test.dart

Issue 10918261: Update language tests to new optional parameter syntax and semantics. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 named parameters. 4 // Dart test program for testing named parameters.
5 // VMOptions=--reject_named_argument_as_positional
5 6
6 7
7 class NamedParametersTest { 8 class NamedParametersTest {
8 9
9 static int F00() { 10 static int F00() {
10 return 0; 11 return 0;
11 } 12 }
12 13
13 int f11() { 14 int f11() {
14 return 0; 15 return 0;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 static testMain() { 58 static testMain() {
58 NamedParametersTest np = new NamedParametersTest(); 59 NamedParametersTest np = new NamedParametersTest();
59 Expect.equals(0, F00()); 60 Expect.equals(0, F00());
60 Expect.equals(0, np.f11()); 61 Expect.equals(0, np.f11());
61 Expect.equals(10, F11(10)); 62 Expect.equals(10, F11(10));
62 Expect.equals(10, np.f22(10)); 63 Expect.equals(10, np.f22(10));
63 Expect.equals(20, F10()); 64 Expect.equals(20, F10());
64 Expect.equals(20, np.f21()); 65 Expect.equals(20, np.f21());
65 Expect.equals(20, F10(20)); 66 Expect.equals(20, F10(20));
66 Expect.equals(20, np.f21(20)); 67 Expect.equals(20, np.f21(20));
67 Expect.equals(20, F10(b:20)); 68 Expect.equals(20, F10(b:20)); /// 01: runtime error
68 Expect.equals(20, np.f21(b:20)); 69 Expect.equals(20, np.f21(b:20)); /// 02: runtime error
69 Expect.equals(1020, F21(10)); 70 Expect.equals(1020, F21(10));
70 Expect.equals(1020, np.f32(10)); 71 Expect.equals(1020, np.f32(10));
71 Expect.equals(1025, F21(10, 25)); 72 Expect.equals(1025, F21(10, 25));
72 Expect.equals(1025, np.f32(10, 25)); 73 Expect.equals(1025, np.f32(10, 25));
73 Expect.equals(1025, F21(10, b:25)); 74 Expect.equals(1025, F21(10, b:25)); /// 03: runtime error
74 Expect.equals(1025, np.f32(10, b:25)); 75 Expect.equals(1025, np.f32(10, b:25)); /// 04: runtime error
75 Expect.equals(102030, F31(10)); 76 Expect.equals(102030, F31(10));
76 Expect.equals(102030, np.f42(10)); 77 Expect.equals(102030, np.f42(10));
77 Expect.equals(102530, F31(10, 25)); 78 Expect.equals(102530, F31(10, 25));
78 Expect.equals(102530, np.f42(10, 25)); 79 Expect.equals(102530, np.f42(10, 25));
79 Expect.equals(102530, F31(10, b:25)); 80 Expect.equals(102035, F31(10, c:35)); /// 05: runtime error
80 Expect.equals(102530, np.f42(10, b:25)); 81 Expect.equals(102035, np.f42(10, c:35)); /// 06: runtime error
81 Expect.equals(102035, F31(10, c:35)); 82 Expect.equals(102535, F31(10, 25, 35));
82 Expect.equals(102035, np.f42(10, c:35)); 83 Expect.equals(102535, np.f42(10, 25, 35));
83 Expect.equals(102535, F31(10, b:25, c:35)); 84 Expect.equals(102535, F31(10, 25, c:35)); /// 07: runtime error
84 Expect.equals(102535, np.f42(10, b:25, c:35)); 85 Expect.equals(102535, np.f42(10, 25, c:35)); /// 08: runtime error
85 Expect.equals(102535, F31(10, 25, c:35));
86 Expect.equals(102535, np.f42(10, 25, c:35));
87 Expect.equals(102535, F31(10, c:35, b:25));
88 Expect.equals(102535, np.f42(10, c:35, b:25));
89 Expect.equals(10200040, F41(10)); 86 Expect.equals(10200040, F41(10));
90 Expect.equals(10200040, np.f52(10)); 87 Expect.equals(10200040, np.f52(10));
91 Expect.equals(10203540, F41(10, c:35)); 88 Expect.equals(10203540, F41(10, c:35)); /// 09: runtime error
92 Expect.equals(10203540, np.f52(10, c:35)); 89 Expect.equals(10203540, np.f52(10, c:35)); /// 10: runtime error
93 Expect.equals(10250045, F41(10, d:45, b:25));
94 Expect.equals(10250045, F41(10, 25, d:45));
95 Expect.equals(10250045, np.f52(10, d:45, b:25));
96 Expect.equals(10253545, F41(10, d:45, c:35, b:25));
97 Expect.equals(10253545, np.f52(10, d:45, c:35, b:25));
98 } 90 }
99 } 91 }
100 92
101 interface I default C { 93 interface I default C {
102 I(); 94 I();
103 int mul(int a, [int factor]); 95 int mul(int a, [int factor]);
104 } 96 }
105 97
106 class C implements I { 98 class C implements I {
107 int mul(int a, [int factor = 10]) { 99 int mul(int a, [int factor = 10]) {
108 return a * factor; 100 return a * factor;
109 } 101 }
110 } 102 }
111 103
112 hello(msg, to, [from]) => '${from} sent ${msg} to ${to}'; 104 hello(msg, to, {from}) => '${from} sent ${msg} to ${to}';
113 message() => hello("gladiolas", "possums", from: "Edna"); 105 message() => hello("gladiolas", "possums", from: "Edna");
114 106
115 main() { 107 main() {
116 NamedParametersTest.testMain(); 108 NamedParametersTest.testMain();
117 var i = new I(); 109 var i = new I();
118 Expect.equals(100, i.mul(10)); 110 Expect.equals(100, i.mul(10));
119 Expect.equals(1000, i.mul(10, 100)); 111 Expect.equals(1000, i.mul(10, 100));
120 var c = new C(); 112 var c = new C();
121 Expect.equals(100, c.mul(10)); 113 Expect.equals(100, c.mul(10));
122 Expect.equals(1000, c.mul(10, 100)); 114 Expect.equals(1000, c.mul(10, 100));
123 Expect.equals("Edna sent gladiolas to possums", message()); 115 Expect.equals("Edna sent gladiolas to possums", message());
124 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698