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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 | 6 |
7 enum Enum1 { _ } | 7 enum Enum1 { _ } |
8 enum Enum2 { A } | 8 enum Enum2 { A } |
9 enum Enum3 { B, C } | 9 enum Enum3 { B, C } |
10 enum Enum4 { D, E, } | 10 enum Enum4 { D, E, } |
11 enum Enum5 { F, G, H } | 11 enum Enum5 { F, G, H } |
12 enum _Enum6 { I, _J } | 12 enum _Enum6 { I, _J } |
13 | 13 |
14 main() { | 14 main() { |
15 Expect.equals('Enum1._', Enum1._.toString()); | 15 Expect.equals('Enum1._', Enum1._.toString()); |
16 Expect.equals(0, Enum1._.index); | 16 Expect.equals(0, Enum1._.index); |
17 Expect.listEquals([Enum1._], Enum1.values); | 17 Expect.listEquals([Enum1._], Enum1.values); |
18 Enum1.values.forEach(test1); | 18 Enum1.values.forEach(test1); |
19 | 19 |
20 Expect.equals('Enum2.A', Enum2.A.toString()); | 20 Expect.equals('Enum2.A', Enum2.A.toString()); |
21 Expect.equals(0, Enum2.A.index); | 21 Expect.equals(0, Enum2.A.index); |
22 Expect.listEquals([Enum2.A], Enum2.values); | 22 Expect.listEquals([Enum2.A], Enum2.values); |
23 Expect.identical(const [Enum2.A], Enum2.values); | 23 Expect.isTrue(identical(const [Enum2.A], Enum2.values) || |
24 identical(const <Enum2>[Enum2.A], Enum2.values)); | |
kustermann
2017/01/11 12:25:06
I think dartk does the right thing by making the c
Vyacheslav Egorov (Google)
2017/01/11 17:28:28
I think it should be only one or another.
Per sp
Lasse Reichstein Nielsen
2017/01/11 17:55:00
Agree, the spec is clear. Do file bugs (or say so,
Vyacheslav Egorov (Google)
2017/01/11 17:56:29
It would be nice if you do that :) Thanks a (metri
| |
24 Enum2.values.forEach(test2); | 25 Enum2.values.forEach(test2); |
25 | 26 |
26 Expect.equals('Enum3.B', Enum3.B.toString()); | 27 Expect.equals('Enum3.B', Enum3.B.toString()); |
27 Expect.equals('Enum3.C', Enum3.C.toString()); | 28 Expect.equals('Enum3.C', Enum3.C.toString()); |
28 Expect.equals(0, Enum3.B.index); | 29 Expect.equals(0, Enum3.B.index); |
29 Expect.equals(1, Enum3.C.index); | 30 Expect.equals(1, Enum3.C.index); |
30 Expect.listEquals([Enum3.B, Enum3.C], Enum3.values); | 31 Expect.listEquals([Enum3.B, Enum3.C], Enum3.values); |
31 Enum3.values.forEach(test3); | 32 Enum3.values.forEach(test3); |
32 | 33 |
33 Expect.equals('Enum4.D', Enum4.D.toString()); | 34 Expect.equals('Enum4.D', Enum4.D.toString()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 break; | 105 break; |
105 case Enum5.F: | 106 case Enum5.F: |
106 index = 0; | 107 index = 0; |
107 break; | 108 break; |
108 case Enum5.G: | 109 case Enum5.G: |
109 index = 1; | 110 index = 1; |
110 break; | 111 break; |
111 } | 112 } |
112 Expect.equals(e.index, index); | 113 Expect.equals(e.index, index); |
113 } | 114 } |
OLD | NEW |