dart-sdk/tests/language/scope_variable_test.dart
sgjesse@google.com 1f2051f88a Merge two static_final_field tests and rewrite a negative test to a multi-test
Removed negative static_final_field_negative_test.dart and created a
multi-test in static_final_field2_test.dart.

Changed throw7_negative_test.dart into a multi-test throw7_test.dart

More Expect.equals cleanup in scope_variable_test.dart.

Add more issue numbers as well.

R=kustermann@google.com
BUG=

Review URL: https://codereview.chromium.org//23638006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27123 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-04 13:26:32 +00:00

47 lines
893 B
Dart

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
void testSimpleScope() {
{
var a = "Test";
int b = 1;
}
{
var c;
int d;
Expect.isNull(c);
Expect.isNull(d);
}
}
void testShadowingScope() {
var a = "Test";
{
var a;
Expect.isNull(a);
a = "a";
Expect.equals(a, "a");
}
Expect.equals(a, "Test");
}
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
return d + a;
}
}
main() {
testSimpleScope();
testShadowingScope();
testShadowingAfterUse();
}