| 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 library analyzer.test.enum_test; | 5 library analyzer.test.enum_test; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| 11 import 'package:analyzer/src/generated/error.dart'; | 11 import 'package:analyzer/src/generated/error.dart'; |
| 12 import 'package:analyzer/src/generated/java_core.dart'; | 12 import 'package:analyzer/src/generated/java_core.dart'; |
| 13 import 'package:analyzer/src/generated/resolver.dart'; | 13 import 'package:analyzer/src/generated/resolver.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
| 15 import 'package:analyzer/src/generated/utilities_dart.dart'; | 15 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 16 import 'package:unittest/unittest.dart'; | 16 import 'package:unittest/unittest.dart'; |
| 17 | 17 |
| 18 import 'generated/ast_test.dart'; | |
| 19 import 'reflective_tests.dart'; | 18 import 'reflective_tests.dart'; |
| 20 import 'utils.dart'; | 19 import 'utils.dart'; |
| 21 | 20 |
| 22 void main() { | 21 void main() { |
| 23 initializeTestEnvironment(); | 22 initializeTestEnvironment(); |
| 24 runReflectiveTests(EnumTest); | 23 runReflectiveTests(EnumTest); |
| 25 } | 24 } |
| 26 | 25 |
| 27 @reflectiveTest | 26 @reflectiveTest |
| 28 class EnumTest { | 27 class EnumTest { |
| 29 void test_AnalysisLevel() { | 28 void test_AnalysisLevel() { |
| 30 new EnumTester<AnalysisLevel>() | 29 new EnumTester<AnalysisLevel>() |
| 31 ..check_getters() | 30 ..check_getters() |
| 32 ..check_explicit_values(); | 31 ..check_explicit_values(); |
| 33 } | 32 } |
| 34 | 33 |
| 35 void test_AssignmentKind() { | |
| 36 new EnumTester<AssignmentKind>() | |
| 37 ..check_getters() | |
| 38 ..check_explicit_values(); | |
| 39 } | |
| 40 | |
| 41 void test_CacheState() { | 34 void test_CacheState() { |
| 42 new EnumTester<CacheState>() | 35 new EnumTester<CacheState>() |
| 43 ..check_getters() | 36 ..check_getters() |
| 44 ..check_explicit_values(); | 37 ..check_explicit_values(); |
| 45 } | 38 } |
| 46 | 39 |
| 47 void test_ElementKind() { | 40 void test_ElementKind() { |
| 48 new EnumTester<ElementKind>() | 41 new EnumTester<ElementKind>() |
| 49 ..check_getters() | 42 ..check_getters() |
| 50 ..check_explicit_values(); | 43 ..check_explicit_values(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 new EnumTester<SourceKind>() | 89 new EnumTester<SourceKind>() |
| 97 ..check_getters() | 90 ..check_getters() |
| 98 ..check_explicit_values(); | 91 ..check_explicit_values(); |
| 99 } | 92 } |
| 100 | 93 |
| 101 void test_UriKind() { | 94 void test_UriKind() { |
| 102 new EnumTester<UriKind>() | 95 new EnumTester<UriKind>() |
| 103 ..check_getters() | 96 ..check_getters() |
| 104 ..check_explicit_values(); | 97 ..check_explicit_values(); |
| 105 } | 98 } |
| 106 | |
| 107 void test_WrapperKind() { | |
| 108 new EnumTester<WrapperKind>() | |
| 109 ..check_getters() | |
| 110 ..check_explicit_values(); | |
| 111 } | |
| 112 } | 99 } |
| 113 | 100 |
| 114 /** | 101 /** |
| 115 * Helper class for testing invariants of enumerated types. | 102 * Helper class for testing invariants of enumerated types. |
| 116 */ | 103 */ |
| 117 class EnumTester<C extends Enum> { | 104 class EnumTester<C extends Enum> { |
| 118 /** | 105 /** |
| 119 * Set of getter names which should be ignored when looking for getters | 106 * Set of getter names which should be ignored when looking for getters |
| 120 * representing enum values. | 107 * representing enum values. |
| 121 */ | 108 */ |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 199 |
| 213 // Check that the set of ordinals runs from 0 to N-1, where N is the number | 200 // Check that the set of ordinals runs from 0 to N-1, where N is the number |
| 214 // of enumerated values. | 201 // of enumerated values. |
| 215 Set<int> expectedOrdinals = new Set<int>(); | 202 Set<int> expectedOrdinals = new Set<int>(); |
| 216 for (int i = 0; i < numValues; i++) { | 203 for (int i = 0; i < numValues; i++) { |
| 217 expectedOrdinals.add(i); | 204 expectedOrdinals.add(i); |
| 218 } | 205 } |
| 219 expect(ordinals.keys.toSet(), equals(expectedOrdinals)); | 206 expect(ordinals.keys.toSet(), equals(expectedOrdinals)); |
| 220 } | 207 } |
| 221 } | 208 } |
| OLD | NEW |