Chromium Code Reviews| Index: tests/language/switch_this_test.dart |
| diff --git a/tests/language/switch_this_test.dart b/tests/language/switch_this_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6bd5c7658815f0aa46e70f083c1082a10096729d |
| --- /dev/null |
| +++ b/tests/language/switch_this_test.dart |
| @@ -0,0 +1,27 @@ |
| +// Copyright (c) 2012, 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. |
| +// Test that a new scope is introduced for each switch case. |
|
ngeoffray
2012/05/23 14:09:45
Update comment.
karlklose
2012/05/24 12:37:49
Done.
|
| + |
| +class Foo { |
| + static final C1 = const Foo('C1'); |
| + static final C2 = const Foo('C2'); |
| + static final C3 = const Foo('C3'); |
| + |
| + var name; |
| + const Foo(this.name); |
| + |
| + foo() { |
| + switch (this) { |
| + case C1: return C1; |
| + case C2: return C2; |
| + default: return null; |
| + } |
| + } |
| +} |
| + |
| +main() { |
| + Expect.equals(Foo.C1, Foo.C1.foo()); |
| + Expect.equals(Foo.C2, Foo.C2.foo()); |
| + Expect.equals(null, Foo.C3.foo()); |
| +} |