OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Basic syntax test for enumeration types | 5 // Basic syntax test for enumeration types |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 | |
10 enum Color { red, orange, yellow, green } | 9 enum Color { red, orange, yellow, green } |
11 | 10 |
12 // Additional comma at end of list is ok. | 11 // Additional comma at end of list is ok. |
13 enum Veggies { carrot, bean, broccolo, } | 12 enum Veggies { |
| 13 carrot, |
| 14 bean, |
| 15 broccolo, |
| 16 } |
14 | 17 |
15 // Need at least one enumeration identifier. | 18 // Need at least one enumeration identifier. |
16 enum Nada {} // //# 01: compile-time error | 19 enum Nada {} // //# 01: compile-time error |
17 | 20 |
18 // Duplicate entries are a compile-time error | 21 // Duplicate entries are a compile-time error |
19 enum ComeAgain { ahau, knust, zipfel, knust, gupf } // //# 02: compile-time erro
r | 22 enum ComeAgain { ahau, knust, zipfel, knust, gupf } // //# 02: compile-time erro
r |
20 | 23 |
21 // Enum entries must not collide with implicitly defined members. | 24 // Enum entries must not collide with implicitly defined members. |
22 enum ComeAgain { ahau, knust, zipfel, index } //# 03: compile-time error | 25 enum ComeAgain { ahau, knust, zipfel, index } //# 03: compile-time error |
23 | 26 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 var x = C.bla; // //# 10: continued | 64 var x = C.bla; // //# 10: continued |
62 var x = zzTop.Frank; // //# 11: continued | 65 var x = zzTop.Frank; // //# 11: continued |
63 | 66 |
64 var x = new Rainbow(); // //# 20: continued | 67 var x = new Rainbow(); // //# 20: continued |
65 var x = new Rainbow(); // //# 21: continued | 68 var x = new Rainbow(); // //# 21: continued |
66 var x = new Rainbow(); // //# 22: continued | 69 var x = new Rainbow(); // //# 22: continued |
67 | 70 |
68 // It is a compile-time error to explicitly instantiate an enum instance. | 71 // It is a compile-time error to explicitly instantiate an enum instance. |
69 var x = new Color(); // //# 30: compile-time error | 72 var x = new Color(); // //# 30: compile-time error |
70 } | 73 } |
71 | |
OLD | NEW |