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

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

Issue 12381089: Fix for loop variable capturing (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | « runtime/vm/parser.cc ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 4
5 foo() => 123; 5 foo() => 123;
6 6
7 void testShadowingScope1() { 7 void testShadowingScope1() {
8 var foo = foo(); 8 var foo = foo();
9 Expect.equals(123, foo); 9 Expect.equals(123, foo);
10 } 10 }
(...skipping 11 matching lines...) Expand all
22 { 22 {
23 var foo = 888; 23 var foo = 888;
24 f = () => foo; 24 f = () => foo;
25 } 25 }
26 var foo = -888; 26 var foo = -888;
27 Expect.equals(888, f()); 27 Expect.equals(888, f());
28 } 28 }
29 29
30 void testShadowingCapture2() { 30 void testShadowingCapture2() {
31 var f = null; 31 var f = null;
32 // this one uses a reentrent block 32 // this one uses a reentrant block
33 for (int i = 0; i < 2; i++) { 33 for (int i = 0; i < 2; i++) {
34 var foo = i + 888; 34 var foo = i + 888;
35 if (f == null) f = () => foo; 35 if (f == null) f = () => foo;
36 } while(false); 36 }
37 var foo = -888; 37 var foo = -888;
38 38
39 // this could break if it doesn't bind the right "foo" 39 // this could break if it doesn't bind the right "foo"
40 Expect.equals(888, f()); 40 Expect.equals(888, f());
41 } 41 }
42 42
43 class BlockScopeTest1 { 43 class BlockScopeTest1 {
44 void testShadowingInstanceVar() { 44 void testShadowingInstanceVar() {
45 if (true) { 45 if (true) {
46 var foo = foo() + 444; 46 var foo = foo() + 444;
(...skipping 14 matching lines...) Expand all
61 } 61 }
62 62
63 main() { 63 main() {
64 testShadowingScope1(); 64 testShadowingScope1();
65 testShadowingScope2(); 65 testShadowingScope2();
66 testShadowingCapture1(); 66 testShadowingCapture1();
67 testShadowingCapture2(); 67 testShadowingCapture2();
68 new BlockScopeTest1().testShadowingInstanceVar(); 68 new BlockScopeTest1().testShadowingInstanceVar();
69 BlockScopeTest1.testShadowingStatic(); 69 BlockScopeTest1.testShadowingStatic();
70 } 70 }
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698