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 test.integration.analysis.overrides; | 5 library test.integration.analysis.overrides; |
6 | 6 |
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 8 import 'package:test/test.dart'; |
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
9 import 'package:unittest/unittest.dart'; | |
10 | 10 |
11 import '../../utils.dart'; | 11 import '../../utils.dart'; |
12 import '../integration_tests.dart'; | 12 import '../integration_tests.dart'; |
13 | 13 |
14 main() { | 14 main() { |
15 initializeTestEnvironment(); | 15 initializeTestEnvironment(); |
16 defineReflectiveTests(Test); | 16 defineReflectiveSuite(() { |
| 17 defineReflectiveTests(Test); |
| 18 }); |
17 } | 19 } |
18 | 20 |
19 @reflectiveTest | 21 @reflectiveTest |
20 class Test extends AbstractAnalysisServerIntegrationTest { | 22 class Test extends AbstractAnalysisServerIntegrationTest { |
21 test_overrides() { | 23 test_overrides() { |
22 String pathname = sourcePath('test.dart'); | 24 String pathname = sourcePath('test.dart'); |
23 String text = r''' | 25 String text = r''' |
24 abstract class Interface1 { | 26 abstract class Interface1 { |
25 method0(); | 27 method0(); |
26 method1(); | 28 method1(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 int targetOffset = text.indexOf('Target'); | 69 int targetOffset = text.indexOf('Target'); |
68 Override findOverride(String methodName) { | 70 Override findOverride(String methodName) { |
69 int methodOffset = text.indexOf(methodName, targetOffset); | 71 int methodOffset = text.indexOf(methodName, targetOffset); |
70 for (Override override in overrides) { | 72 for (Override override in overrides) { |
71 if (override.offset == methodOffset) { | 73 if (override.offset == methodOffset) { |
72 return override; | 74 return override; |
73 } | 75 } |
74 } | 76 } |
75 return null; | 77 return null; |
76 } | 78 } |
| 79 |
77 void checkOverrides(String methodName, bool expectedOverridesBase, | 80 void checkOverrides(String methodName, bool expectedOverridesBase, |
78 List<String> expectedOverridesInterfaces) { | 81 List<String> expectedOverridesInterfaces) { |
79 Override override = findOverride(methodName); | 82 Override override = findOverride(methodName); |
80 if (!expectedOverridesBase && expectedOverridesInterfaces.isEmpty) { | 83 if (!expectedOverridesBase && expectedOverridesInterfaces.isEmpty) { |
81 // This method overrides nothing, so it should not appear in the | 84 // This method overrides nothing, so it should not appear in the |
82 // overrides list. | 85 // overrides list. |
83 expect(override, isNull); | 86 expect(override, isNull); |
84 return; | 87 return; |
85 } else { | 88 } else { |
86 expect(override, isNotNull); | 89 expect(override, isNotNull); |
(...skipping 15 matching lines...) Expand all Loading... |
102 String className = overriddenMember.className; | 105 String className = overriddenMember.className; |
103 bool wasAdded = actualOverridesInterfaces.add(className); | 106 bool wasAdded = actualOverridesInterfaces.add(className); |
104 expect(wasAdded, isTrue); | 107 expect(wasAdded, isTrue); |
105 } | 108 } |
106 expect(actualOverridesInterfaces, | 109 expect(actualOverridesInterfaces, |
107 equals(expectedOverridesInterfaces.toSet())); | 110 equals(expectedOverridesInterfaces.toSet())); |
108 } else { | 111 } else { |
109 expect(interfaceMembers, isNull); | 112 expect(interfaceMembers, isNull); |
110 } | 113 } |
111 } | 114 } |
| 115 |
112 checkOverrides('method0', true, ['Interface1', 'Interface2']); | 116 checkOverrides('method0', true, ['Interface1', 'Interface2']); |
113 checkOverrides('method1', false, ['Interface1', 'Interface2']); | 117 checkOverrides('method1', false, ['Interface1', 'Interface2']); |
114 checkOverrides('method2', true, ['Interface1']); | 118 checkOverrides('method2', true, ['Interface1']); |
115 checkOverrides('method3', false, ['Interface1']); | 119 checkOverrides('method3', false, ['Interface1']); |
116 checkOverrides('method4', true, ['Interface2']); | 120 checkOverrides('method4', true, ['Interface2']); |
117 checkOverrides('method5', false, ['Interface2']); | 121 checkOverrides('method5', false, ['Interface2']); |
118 checkOverrides('method6', true, []); | 122 checkOverrides('method6', true, []); |
119 checkOverrides('method7', false, []); | 123 checkOverrides('method7', false, []); |
120 }); | 124 }); |
121 } | 125 } |
122 } | 126 } |
OLD | NEW |