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