@@ -6,6 +6,7 @@ library dartdoc.model_test;
6
6
7
7
import 'dart:io' ;
8
8
9
+ import 'package:analyzer/dart/element/type.dart' ;
9
10
import 'package:analyzer/source/line_info.dart' ;
10
11
import 'package:async/async.dart' ;
11
12
import 'package:dartdoc/src/element_type.dart' ;
@@ -23,15 +24,13 @@ import 'package:dartdoc/src/special_elements.dart';
23
24
import 'package:dartdoc/src/warnings.dart' ;
24
25
import 'package:test/test.dart' ;
25
26
26
- import '../src/utils.dart' as utils;
27
- import '../src/utils.dart' ;
27
+ import '../src/utils.dart'
28
+ show bootBasicPackage, bothLookup, kTestPackagePublicLibraries, newLookup ;
28
29
29
30
final _testPackageGraphMemo = AsyncMemoizer <PackageGraph >();
30
31
Future <PackageGraph > get testPackageGraph async =>
31
- _testPackageGraphMemo.runOnce (() => utils.bootBasicPackage (
32
- 'testing/test_package' ,
33
- pubPackageMetaProvider,
34
- PhysicalPackageConfigProvider (),
32
+ _testPackageGraphMemo.runOnce (() => bootBasicPackage ('testing/test_package' ,
33
+ pubPackageMetaProvider, PhysicalPackageConfigProvider (),
35
34
excludeLibraries: ['css' , 'code_in_comments' ],
36
35
additionalArguments: ['--no-link-to-remote' ]));
37
36
@@ -94,6 +93,121 @@ void main() {
94
93
packageGraph.libraries.firstWhere ((lib) => lib.name == 'base_class' );
95
94
});
96
95
96
+ group ('triple-shift' , () {
97
+ Library tripleShift;
98
+ Class C , E , F ;
99
+ Extension ShiftIt ;
100
+ Operator classShift, extensionShift;
101
+ Field constantTripleShifted;
102
+
103
+ setUpAll (() async {
104
+ tripleShift = (await testPackageGraph)
105
+ .libraries
106
+ .firstWhere ((l) => l.name == 'triple_shift' );
107
+ C = tripleShift.classes.firstWhere ((c) => c.name == 'C' );
108
+ E = tripleShift.classes.firstWhere ((c) => c.name == 'E' );
109
+ F = tripleShift.classes.firstWhere ((c) => c.name == 'F' );
110
+ ShiftIt = tripleShift.extensions.firstWhere ((e) => e.name == 'ShiftIt' );
111
+ classShift =
112
+ C .instanceOperators.firstWhere ((o) => o.name.contains ('>>>' ));
113
+ extensionShift =
114
+ ShiftIt .instanceOperators.firstWhere ((o) => o.name.contains ('>>>' ));
115
+ constantTripleShifted =
116
+ C .constantFields.firstWhere ((f) => f.name == 'constantTripleShifted' );
117
+ });
118
+
119
+ test ('constants with triple shift render correctly' , () {
120
+ expect (constantTripleShifted.constantValue, equals ('3 >>> 5' ));
121
+ });
122
+
123
+ test ('operators exist and are named correctly' , () {
124
+ expect (classShift.name, equals ('operator >>>' ));
125
+ expect (extensionShift.name, equals ('operator >>>' ));
126
+ });
127
+
128
+ test ('inheritance and overriding of triple shift operators works correctly' ,
129
+ () {
130
+ var tripleShiftE =
131
+ E .instanceOperators.firstWhere ((o) => o.name.contains ('>>>' ));
132
+ var tripleShiftF =
133
+ F .instanceOperators.firstWhere ((o) => o.name.contains ('>>>' ));
134
+
135
+ expect (tripleShiftE.isInherited, isTrue);
136
+ expect (tripleShiftE.canonicalModelElement, equals (classShift));
137
+ expect (tripleShiftE.modelType.returnType.name, equals ('C' ));
138
+ expect (tripleShiftF.isInherited, isFalse);
139
+ expect (tripleShiftF.modelType.returnType.name, equals ('F' ));
140
+ });
141
+ });
142
+
143
+ group ('generic metadata' , () {
144
+ Library genericMetadata;
145
+ TopLevelVariable f;
146
+ Typedef F ;
147
+ Class C ;
148
+ Method mp, mn;
149
+
150
+ setUpAll (() async {
151
+ genericMetadata = (await testPackageGraph)
152
+ .libraries
153
+ .firstWhere ((l) => l.name == 'generic_metadata' );
154
+ F = genericMetadata.typedefs.firstWhere ((t) => t.name == 'F' );
155
+ f = genericMetadata.properties.firstWhere ((p) => p.name == 'f' );
156
+ C = genericMetadata.classes.firstWhere ((c) => c.name == 'C' );
157
+ mp = C .instanceMethods.firstWhere ((m) => m.name == 'mp' );
158
+ mn = C .instanceMethods.firstWhere ((m) => m.name == 'mn' );
159
+ });
160
+
161
+ test (
162
+ 'Verify annotations and their type arguments render on type parameters for typedefs' ,
163
+ () {
164
+ expect ((F .aliasedType as FunctionType ).typeFormals.first.metadata,
165
+ isNotEmpty);
166
+ expect ((F .aliasedType as FunctionType ).parameters.first.metadata,
167
+ isNotEmpty);
168
+ // TODO(jcollins-g): add rendering verification once we have data from
169
+ // analyzer.
170
+ }, skip: 'dart-lang/sdk#46064' );
171
+
172
+ test ('Verify type arguments on annotations renders, including parameters' ,
173
+ () {
174
+ var ab0 =
175
+ '@<a href="%%__HTMLBASE_dartdoc_internal__%%generic_metadata/A-class.html">A</a><span class="signature"><<wbr><span class="type-parameter"><a href="%%__HTMLBASE_dartdoc_internal__%%generic_metadata/B.html">B</a></span>></span>(0)' ;
176
+
177
+ expect (genericMetadata.annotations.first.linkedNameWithParameters,
178
+ equals (ab0));
179
+ expect (f.annotations.first.linkedNameWithParameters, equals (ab0));
180
+ expect (C .annotations.first.linkedNameWithParameters, equals (ab0));
181
+ expect (C .typeParameters.first.annotations.first.linkedNameWithParameters,
182
+ equals (ab0));
183
+ expect (
184
+ mp.parameters
185
+ .map ((p) => p.annotations.first.linkedNameWithParameters),
186
+ everyElement (equals (ab0)));
187
+ expect (
188
+ mn.parameters
189
+ .map ((p) => p.annotations.first.linkedNameWithParameters),
190
+ everyElement (equals (ab0)));
191
+
192
+ expect (genericMetadata.features.map ((f) => f.linkedNameWithParameters),
193
+ contains (ab0));
194
+ expect (f.features.map ((f) => f.linkedNameWithParameters), contains (ab0));
195
+ expect (C .features.map ((f) => f.linkedNameWithParameters), contains (ab0));
196
+ expect (
197
+ C .typeParameters.first.features
198
+ .map ((f) => f.linkedNameWithParameters),
199
+ contains (ab0));
200
+ expect (
201
+ mp.parameters
202
+ .map ((p) => p.features.map ((f) => f.linkedNameWithParameters)),
203
+ everyElement (contains (ab0)));
204
+ expect (
205
+ mn.parameters
206
+ .map ((p) => p.features.map ((f) => f.linkedNameWithParameters)),
207
+ everyElement (contains (ab0)));
208
+ });
209
+ });
210
+
97
211
group ('generalized typedefs' , () {
98
212
Library generalizedTypedefs;
99
213
Typedef T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 ;
@@ -671,7 +785,7 @@ void main() {
671
785
packageGraph
672
786
.localPackages.first.defaultCategory.publicLibraries.length,
673
787
// Only 5 libraries have categories, the rest belong in default.
674
- equals (utils. kTestPackagePublicLibraries - 5 ));
788
+ equals (kTestPackagePublicLibraries - 5 ));
675
789
});
676
790
677
791
// TODO consider moving these to a separate suite
0 commit comments