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