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

Side by Side Diff: frog/tests/leg_only/closure_capture5_test.dart

Issue 10536169: Move frog/tests/{leg,leg_only,frog_native} to tests/compiler/. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
5 closure0() {
6 var fs = [];
7 for (var x = 1; x <= 3; x++) {
8 fs.add(fun() { return x; });
9 }
10 Expect.equals(3, fs.length);
11 Expect.equals(1, fs[0]());
12 Expect.equals(2, fs[1]());
13 Expect.equals(3, fs[2]());
14 }
15
16 closure1() {
17 var fs = [];
18 for (var x = 0; x < 6; x++) {
19 fs.add(fun() { return x; });
20 x++;
21 }
22 Expect.equals(3, fs.length);
23 Expect.equals(1, fs[0]());
24 Expect.equals(3, fs[1]());
25 Expect.equals(5, fs[2]());
26 }
27
28 closure2() {
29 var input = [1, 2, 3];
30 var fs = [];
31 for (var i = 0; i < input.length; i++) {
32 fs.add(fun() { return input[i]; });
33 }
34 Expect.equals(3, fs.length);
35 Expect.equals(1, fs[0]());
36 Expect.equals(2, fs[1]());
37 Expect.equals(3, fs[2]());
38 }
39
40 closure3() {
41 var fs = [];
42 for (var i = 0;
43 i < 3;
44 (f() {
45 fs.add(g() => i);
46 i++;
47 })()) {
48 i++;
49 }
50 Expect.equals(2, fs.length);
51 Expect.equals(3, fs[0]());
52 Expect.equals(4, fs[1]());
53 }
54
55 closure4() {
56 var g;
57 for (var i = 0;
58 (f() {
59 g = fun() => i;
60 return false;
61 })();
62 i++){
63 Expect.equals(false, true);
64 }
65 Expect.equals(0, g());
66 }
67
68 main() {
69 closure0();
70 closure1();
71 closure2();
72 closure3();
73 closure4();
74 }
OLDNEW
« no previous file with comments | « frog/tests/leg_only/closure_capture4_test.dart ('k') | frog/tests/leg_only/closure_capture_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698