Chromium Code Reviews| Index: tests/language/scope_variable_test.dart |
| diff --git a/tests/language/scope_variable_test.dart b/tests/language/scope_variable_test.dart |
| index d3bca7cc1ea376c779786b683388a00e58d0511c..e07da82a65ed325f34b3dc59d296cc4c36be8cf2 100644 |
| --- a/tests/language/scope_variable_test.dart |
| +++ b/tests/language/scope_variable_test.dart |
| @@ -4,38 +4,44 @@ |
| import "package:expect/expect.dart"; |
| -class ScopeVariableTest { |
| - |
| - static void testSimpleScope() { |
| - { |
| - var a = "Test"; |
| - int b = 1; |
| - } |
| - { |
| - var c; |
| - int d; |
| - Expect.equals(true, c == null); |
| - Expect.equals(true, d == null); |
| - } |
| - } |
| - |
| - static void testShadowingScope() { |
| +void testSimpleScope() { |
| + { |
| var a = "Test"; |
| - { |
| - var a; |
| - Expect.equals(true, a == null); |
| - a = "a"; |
| - Expect.equals(true, a == "a"); |
| + int b = 1; |
| + } |
| + { |
| + var c; |
| + int d; |
| + 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
|
| + Expect.equals(true, d == null); |
| } |
| - Expect.equals(true, a == "Test"); |
| +} |
| + |
| +void testShadowingScope() { |
| + var a = "Test"; |
| + { |
| + var a; |
| + Expect.equals(true, a == null); |
| + a = "a"; |
| + Expect.equals(true, a == "a"); |
| } |
| + Expect.equals(true, a == "Test"); |
| +} |
| - static void testMain() { |
| - testSimpleScope(); |
| - testShadowingScope(); |
| +int testShadowingAfterUse() { |
| + var a = 1; |
| + { |
| + var b = 2; |
| + var c = a; // Use of 'a' prior to its shadow declaration below. |
| + var d = b + c; |
| + // Shadow declaration of 'a'. |
| + 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
|
| + return d + a; |
| } |
| } |
| main() { |
| - ScopeVariableTest.testMain(); |
| + testSimpleScope(); |
| + testShadowingScope(); |
| + testShadowingAfterUse(); |
| } |