Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 // 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.
| |
| 5 | |
| 6 class Foo { | |
| 7 static final C1 = const Foo('C1'); | |
| 8 static final C2 = const Foo('C2'); | |
| 9 static final C3 = const Foo('C3'); | |
| 10 | |
| 11 var name; | |
| 12 const Foo(this.name); | |
| 13 | |
| 14 foo() { | |
| 15 switch (this) { | |
| 16 case C1: return C1; | |
| 17 case C2: return C2; | |
| 18 default: return null; | |
| 19 } | |
| 20 } | |
| 21 } | |
| 22 | |
| 23 main() { | |
| 24 Expect.equals(Foo.C1, Foo.C1.foo()); | |
| 25 Expect.equals(Foo.C2, Foo.C2.foo()); | |
| 26 Expect.equals(null, Foo.C3.foo()); | |
| 27 } | |
| OLD | NEW |