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

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

Issue 17977002: - Remove arguments definition test from the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « tests/language/argument_definition6_test.dart ('k') | tests/language/constructor8_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 that the argument definition test has been
5 // removed.
5 6
6 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
7 8
8 int test(int a, {int b: 2, int c: 3}) { 9 int test(a, {b, c}) {
9 int result = 0; 10 if (?b) return b; /// 01: compile-time error
10 ?b; 11 return a + b + c;
11 ?result; /// 01: compile-time error
12 if (?a) {
13 result += 100;
14 }
15 if (?b) {
16 result += 20;
17 }
18 if (?c) {
19 var b; ?b; /// 02: compile-time error
20 result += 3;
21 }
22 if ((!?a?!?b:!?c) == (?a??b:?c)) {
23 result += 200;
24 }
25 if (!?a?!?b:!?c == ?a??b:?c) {
26 result += 400;
27 }
28 return result;
29 } 12 }
30 13
31 closure_test(int a, {int b: 2, int c: 3}) { 14 main() {
32 var x = 0; 15 Expect.equals(6, test(1, b: 2, c:3));
33 return () {
34 int result = 0;
35 ?b;
36 ?result; /// 03: compile-time error
37 ?x; /// 04: compile-time error
38 if (?a) {
39 result += 100;
40 }
41 if (?b) {
42 result += 20;
43 }
44 if (?c) {
45 var b; ?b; /// 05: compile-time error
46 result += 3;
47 }
48 // Equivalent to: (!?c) == ?b.
49 if ((!?a?!?b:!?c) == (?a??b:?c)) {
50 result += 200;
51 }
52 // Equivalent to: (!?c) ? ?b : ?c.
53 if (!?a?!?b:!?c == ?a??b:?c) {
54 result += 400;
55 }
56 return result;
57 };
58 } 16 }
59
60 tl_test([a]) => ?a;
61
62 main() {
63 // Use a loop to test optimized version as well.
64 for (int i = 0; i < 1000; i++) {
65 Expect.equals(100, test(1));
66 Expect.equals(720, test(1, b: 2));
67 Expect.equals(523, test(1, b: 2, c: 3));
68 Expect.equals(703, test(1, c: 3));
69
70 Expect.equals(100, closure_test(1)());
71 Expect.equals(720, closure_test(1, b: 2)());
72 Expect.equals(523, closure_test(1, b: 2, c: 3)());
73 Expect.equals(703, closure_test(1, c: 3)());
74
75 Expect.equals(true, tl_test(0));
76 Expect.equals(false, tl_test());
77 }
78 }
OLDNEW
« no previous file with comments | « tests/language/argument_definition6_test.dart ('k') | tests/language/constructor8_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698