| OLD | NEW |
| 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 void testSimpleScope() { | 7 void testSimpleScope() { |
| 8 { | 8 { |
| 9 var a = "Test"; | 9 var a = "Test"; |
| 10 int b = 1; | 10 int b = 1; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 a = "a"; | 25 a = "a"; |
| 26 Expect.equals(a, "a"); | 26 Expect.equals(a, "a"); |
| 27 } | 27 } |
| 28 Expect.equals(a, "Test"); | 28 Expect.equals(a, "Test"); |
| 29 } | 29 } |
| 30 | 30 |
| 31 int testShadowingAfterUse() { | 31 int testShadowingAfterUse() { |
| 32 var a = 1; | 32 var a = 1; |
| 33 { | 33 { |
| 34 var b = 2; | 34 var b = 2; |
| 35 var c = a; // Use of 'a' prior to its shadow declaration below. | 35 var c = a; // Use of 'a' prior to its shadow declaration below. |
| 36 var d = b + c; | 36 var d = b + c; |
| 37 // Shadow declaration of 'a'. | 37 // Shadow declaration of 'a'. |
| 38 var a = 5; //# 01: compile-time error | 38 var a = 5; //# 01: compile-time error |
| 39 return d + a; | 39 return d + a; |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 main() { | 43 main() { |
| 44 testSimpleScope(); | 44 testSimpleScope(); |
| 45 testShadowingScope(); | 45 testShadowingScope(); |
| 46 testShadowingAfterUse(); | 46 testShadowingAfterUse(); |
| 47 } | 47 } |
| OLD | NEW |