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

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

Issue 10915022: Implement argument definition test in the vm. (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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test program for testing argument definition test.
5
6 int test(int a, [int b, int c]) {
7 int result = 0;
8 ?b;
9 ?result; /// 01: compile-time error
10 if (?a) {
11 result += 100;
12 }
13 if (?b) {
14 result += 20;
15 }
16 if (?c) {
17 var b; ?b; /// 02: compile-time error
18 result += 3;
19 }
20 return result;
21 }
22
23 closure_test(int a, [int b, int c]) {
24 var x = 0;
25 return () {
26 int result = 0;
27 ?b;
28 ?result; /// 03: compile-time error
29 ?x; /// 04: compile-time error
30 if (?a) {
31 result += 100;
32 }
33 if (?b) {
34 result += 20;
35 }
36 if (?c) {
37 var b; ?b; /// 05: compile-time error
38 result += 3;
39 }
40 return result;
41 };
42 }
43
hausner 2012/08/31 00:34:55 Can add this nice test function: WTF([a, b, c]) {
regis 2012/08/31 01:36:18 LOL Does it work? Does it matter how you call WTF(
hausner 2012/08/31 05:56:26 We had some good laughs in the office today. I hav
44 main() {
45 // Use a loop to test optimized version as well.
46 for (int i = 0; i < 1000; i++) {
47 Expect.equals(100, test(1));
48 Expect.equals(120, test(1, 2));
49 Expect.equals(123, test(1, 2, 3));
50 Expect.equals(103, test(1, c:3));
51
52 Expect.equals(100, closure_test(1)());
53 Expect.equals(120, closure_test(1, 2)());
54 Expect.equals(123, closure_test(1, 2, 3)());
55 Expect.equals(103, closure_test(1, c:3)());
56 }
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698