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

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

Issue 59073003: Version 0.8.10.4 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 foo() => 123;
8
9 void testShadowingScope1() {
10 var foo = foo();
11 Expect.equals(123, foo);
12 }
13
14 void testShadowingScope2() {
15 {
16 var foo = foo() + 444;
17 Expect.equals(567, foo);
18 }
19 Expect.equals(123, foo());
20 }
21
22 void testShadowingCapture1() {
23 var f;
24 {
25 var foo = 888;
26 f = () => foo;
27 }
28 var foo = -888;
29 Expect.equals(888, f());
30 }
31
32 void testShadowingCapture2() {
33 var f = null;
34 // this one uses a reentrant block
35 for (int i = 0; i < 2; i++) {
36 var foo = i + 888;
37 if (f == null) f = () => foo;
38 }
39 var foo = -888;
40
41 // this could break if it doesn't bind the right "foo"
42 Expect.equals(888, f());
43 }
44
45 class BlockScopeTest1 {
46 void testShadowingInstanceVar() {
47 if (true) {
48 var foo = foo() + 444;
49 Expect.equals(1221, foo);
50 }
51 Expect.equals(777, foo());
52 }
53 static void testShadowingStatic() {
54 if (true) {
55 var bar = bar() + 444;
56 Expect.equals(1221, bar);
57 }
58 Expect.equals(777, bar());
59 }
60
61 foo() => 777;
62 static bar() => 777;
63 }
64
65 main() {
66 testShadowingScope1();
67 testShadowingScope2();
68 testShadowingCapture1();
69 testShadowingCapture2();
70 new BlockScopeTest1().testShadowingInstanceVar();
71 BlockScopeTest1.testShadowingStatic();
72 }
OLDNEW
« no previous file with comments | « dart/tests/language/bailout3_test.dart ('k') | dart/tests/language/export_ambiguous_main_a.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698