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

Side by Side Diff: tests/language/argument_definition_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 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) {
11 result += 100; 11 result += 100;
12 } 12 }
13 if (?b) { 13 if (?b) {
14 result += 20; 14 result += 20;
15 } 15 }
16 if (?c) { 16 if (?c) {
17 var b; ?b; /// 02: compile-time error 17 var b; ?b; /// 02: compile-time error
18 result += 3; 18 result += 3;
19 } 19 }
20 if ((!?a?!?b:!?c) == (?a??b:?c)) { 20 if ((!?a?!?b:!?c) == (?a??b:?c)) {
21 result += 200; 21 result += 200;
22 } 22 }
23 if (!?a?!?b:!?c == ?a??b:?c) { 23 if (!?a?!?b:!?c == ?a??b:?c) {
24 result += 400; 24 result += 400;
25 } 25 }
26 return result; 26 return result;
27 } 27 }
28 28
29 closure_test(int a, [int b = 2, int c = 3]) { 29 closure_test(int a, {int b: 2, int c: 3}) {
30 var x = 0; 30 var x = 0;
31 return () { 31 return () {
32 int result = 0; 32 int result = 0;
33 ?b; 33 ?b;
34 ?result; /// 03: compile-time error 34 ?result; /// 03: compile-time error
35 ?x; /// 04: compile-time error 35 ?x; /// 04: compile-time error
36 if (?a) { 36 if (?a) {
37 result += 100; 37 result += 100;
38 } 38 }
39 if (?b) { 39 if (?b) {
(...skipping 12 matching lines...) Expand all
52 result += 400; 52 result += 400;
53 } 53 }
54 return result; 54 return result;
55 }; 55 };
56 } 56 }
57 57
58 main() { 58 main() {
59 // Use a loop to test optimized version as well. 59 // Use a loop to test optimized version as well.
60 for (int i = 0; i < 1000; i++) { 60 for (int i = 0; i < 1000; i++) {
61 Expect.equals(100, test(1)); 61 Expect.equals(100, test(1));
62 Expect.equals(720, test(1, 2)); 62 Expect.equals(720, test(1, b: 2));
63 Expect.equals(523, test(1, 2, 3)); 63 Expect.equals(523, test(1, b: 2, c: 3));
64 Expect.equals(703, test(1, c:3)); 64 Expect.equals(703, test(1, c: 3));
65 65
66 Expect.equals(100, closure_test(1)()); 66 Expect.equals(100, closure_test(1)());
67 Expect.equals(720, closure_test(1, 2)()); 67 Expect.equals(720, closure_test(1, b: 2)());
68 Expect.equals(523, closure_test(1, 2, 3)()); 68 Expect.equals(523, closure_test(1, b: 2, c: 3)());
69 Expect.equals(703, closure_test(1, c:3)()); 69 Expect.equals(703, closure_test(1, c: 3)());
70 } 70 }
71 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698