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

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

Issue 23944004: Merge two language/scope_ tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « tests/language/scope_negative_test.dart ('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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 class ScopeVariableTest { 7 void testSimpleScope() {
8 {
9 var a = "Test";
10 int b = 1;
11 }
12 {
13 var c;
14 int d;
15 Expect.equals(true, c == null);
kustermann 2013/09/04 09:28:42 I'd use one of these two instead: Expect.isTrue
Søren Gjesse 2013/09/04 10:16:16 Done (I just copied some old code). Ended up using
kustermann 2013/09/04 10:19:16 'Expect.isNull' is even better in this case. My c
16 Expect.equals(true, d == null);
17 }
18 }
8 19
9 static void testSimpleScope() { 20 void testShadowingScope() {
10 { 21 var a = "Test";
11 var a = "Test"; 22 {
12 int b = 1; 23 var a;
13 } 24 Expect.equals(true, a == null);
14 { 25 a = "a";
15 var c; 26 Expect.equals(true, a == "a");
16 int d;
17 Expect.equals(true, c == null);
18 Expect.equals(true, d == null);
19 }
20 } 27 }
28 Expect.equals(true, a == "Test");
29 }
21 30
22 static void testShadowingScope() { 31 int testShadowingAfterUse() {
23 var a = "Test"; 32 var a = 1;
24 { 33 {
25 var a; 34 var b = 2;
26 Expect.equals(true, a == null); 35 var c = a; // Use of 'a' prior to its shadow declaration below.
27 a = "a"; 36 var d = b + c;
28 Expect.equals(true, a == "a"); 37 // Shadow declaration of 'a'.
29 } 38 var a = 5; /// 01: compile-time error
kustermann 2013/09/04 09:28:42 I wasn't aware that this is supposed to result in
30 Expect.equals(true, a == "Test"); 39 return d + a;
31 }
32
33 static void testMain() {
34 testSimpleScope();
35 testShadowingScope();
36 } 40 }
37 } 41 }
38 42
39 main() { 43 main() {
40 ScopeVariableTest.testMain(); 44 testSimpleScope();
45 testShadowingScope();
46 testShadowingAfterUse();
41 } 47 }
OLDNEW
« no previous file with comments | « tests/language/scope_negative_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698