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