Skip to content

Commit ee51bfb

Browse files
committed
more tests
1 parent 7976a30 commit ee51bfb

File tree

7 files changed

+56
-54
lines changed

7 files changed

+56
-54
lines changed

test/constant_values_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'src/utils.dart';
1010

1111
void main() {
1212
defineReflectiveSuite(() {
13-
defineReflectiveTests(ConstantValuesWithConstructorTearoffsTest);
13+
defineReflectiveTests(ConstantValuesTest);
1414
if (namedArgumentsAnywhereAllowed) {
1515
defineReflectiveTests(ConstantValuesWithNamedArgumentsAnywhereTest);
1616
}
@@ -22,16 +22,17 @@ void main() {
2222
// test_reflective_loader migration.
2323

2424
@reflectiveTest
25-
class ConstantValuesWithConstructorTearoffsTest extends DartdocTestBase {
25+
class ConstantValuesTest extends DartdocTestBase {
2626
@override
27-
String get libraryName => 'constructor_tearoffs';
27+
String get libraryName => 'constant_values';
2828

2929
void test_nonGenericFunctionReference() async {
3030
var library = await bootPackageWithLibrary('''
3131
void func() {}
3232
const aFunc = func;
3333
''');
3434
var aFuncConstant = library.constants.named('aFunc');
35+
expect(aFuncConstant.fullyQualifiedName, equals('constant_values.aFunc'));
3536
expect(aFuncConstant.constantValue, equals('func'));
3637
}
3738

test/constructors_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ abstract final class C {
2828
''');
2929
var c = library.classes.named('C').constructors.first;
3030
expect(c.name, equals('C'));
31+
// TODO(srawlins): This should be `constructors.C.new`.
32+
expect(c.fullyQualifiedName, 'constructors.C.C');
3133
expect(c.isPublic, isTrue);
3234
expect(c.documentationAsHtml, '<p>Constructor.</p>');
3335
}
@@ -41,6 +43,8 @@ abstract final class C {
4143
''');
4244
var c = library.classes.named('C').constructors.first;
4345
expect(c.name, equals('C'));
46+
// TODO(srawlins): This should be `constructors.C.new`.
47+
expect(c.fullyQualifiedName, 'constructors.C.C');
4448
expect(c.isPublic, isFalse);
4549
expect(c.documentationAsHtml, '<p>Constructor.</p>');
4650
}
@@ -54,6 +58,8 @@ abstract interface class C {
5458
''');
5559
var c = library.classes.named('C').constructors.first;
5660
expect(c.name, equals('C'));
61+
// TODO(srawlins): This should be `constructors.C.new`.
62+
expect(c.fullyQualifiedName, 'constructors.C.C');
5763
expect(c.isPublic, isFalse);
5864
expect(c.documentationAsHtml, '<p>Constructor.</p>');
5965
}
@@ -67,6 +73,7 @@ class C {
6773
''');
6874
var c = library.classes.named('C').constructors.first;
6975
expect(c.name, equals('C._'));
76+
expect(c.fullyQualifiedName, 'constructors.C._');
7077
expect(c.isPublic, isFalse);
7178
expect(c.documentationAsHtml, '<p>Constructor.</p>');
7279
}
@@ -103,6 +110,7 @@ class C {
103110
''');
104111
var c = library.classes.named('C').constructors.first;
105112
expect(c.name, equals('C.named'));
113+
expect(c.fullyQualifiedName, 'constructors.C.named');
106114
expect(c.isPublic, isTrue);
107115
expect(c.documentationAsHtml, '<p>Constructor.</p>');
108116
}
@@ -129,6 +137,8 @@ class C {
129137
''');
130138
var c = library.classes.named('C').constructors.first;
131139
expect(c.name, equals('C'));
140+
// TODO(srawlins): This should be `constructors.C.new`.
141+
expect(c.fullyQualifiedName, 'constructors.C.C');
132142
expect(c.isPublic, isTrue);
133143
expect(c.documentationAsHtml, '<p>Constructor.</p>');
134144
}
@@ -156,6 +166,7 @@ enum E {
156166
''');
157167
var e = library.enums.named('E').constructors.first;
158168
expect(e.name, equals('E.named'));
169+
expect(e.fullyQualifiedName, 'constructors.E.named');
159170
expect(e.isPublic, isFalse);
160171
expect(e.documentationAsHtml, '<p>Constructor.</p>');
161172
}
@@ -170,6 +181,8 @@ enum E {
170181
''');
171182
var e = library.enums.named('E').constructors.first;
172183
expect(e.name, equals('E'));
184+
// TODO(srawlins): This should be `constructors.E.new`.
185+
expect(e.fullyQualifiedName, 'constructors.E.E');
173186
expect(e.isPublic, isFalse);
174187
expect(e.documentationAsHtml, '<p>Constructor.</p>');
175188
}
@@ -184,6 +197,7 @@ extension type ET(int it) {
184197
var etNamed =
185198
library.extensionTypes.named('ET').constructors.named('ET.named');
186199
expect(etNamed.name, equals('ET.named'));
200+
expect(etNamed.fullyQualifiedName, 'constructors.ET.named');
187201
expect(etNamed.isPublic, isTrue);
188202
expect(etNamed.documentationAsHtml, '<p>Constructor.</p>');
189203
}
@@ -195,6 +209,7 @@ extension type ET.named(int it) {}
195209
var etNamed =
196210
library.extensionTypes.named('ET').constructors.named('ET.named');
197211
expect(etNamed.name, equals('ET.named'));
212+
expect(etNamed.fullyQualifiedName, 'constructors.ET.named');
198213
expect(etNamed.isPublic, isTrue);
199214
}
200215

@@ -204,6 +219,8 @@ extension type ET(int it) {}
204219
''');
205220
var et = library.extensionTypes.named('ET').constructors.named('ET');
206221
expect(et.name, equals('ET'));
222+
// TODO(srawlins): This should be `constructors.ET.new`.
223+
expect(et.fullyQualifiedName, 'constructors.ET.ET');
207224
expect(et.isPublic, isTrue);
208225
}
209226

@@ -216,6 +233,8 @@ extension type ET.named(int it) {
216233
''');
217234
var etNamed = library.extensionTypes.named('ET').constructors.named('ET');
218235
expect(etNamed.name, equals('ET'));
236+
// TODO(srawlins): This should be `constructors.ET.new`.
237+
expect(etNamed.fullyQualifiedName, 'constructors.ET.ET');
219238
expect(etNamed.isPublic, isTrue);
220239
expect(etNamed.documentationAsHtml, '<p>Constructor.</p>');
221240
}

test/end2end/model_test.dart

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,10 +1923,6 @@ void main() async {
19231923
CatString = exLibrary.classes.named('CatString');
19241924
});
19251925

1926-
test('has a fully qualified name', () {
1927-
expect(Apple.fullyQualifiedName, 'ex.Apple');
1928-
});
1929-
19301926
test('does have a line number and column', () {
19311927
expect(Apple.characterLocation, isNotNull);
19321928
});
@@ -2984,10 +2980,6 @@ void main() async {
29842980
'<a href="${htmlBasePlaceholder}reexport_two/DocumentThisExtensionOnce.html">DocumentThisExtensionOnce</a>'));
29852981
});
29862982

2987-
test('has a fully qualified name', () {
2988-
expect(ext.fullyQualifiedName, 'ex.AppleExtension');
2989-
});
2990-
29912983
test('does have a line number and column', () {
29922984
expect(ext.characterLocation, isNotNull);
29932985
});
@@ -3069,10 +3061,6 @@ void main() async {
30693061
doAComplicatedThing = fakeLibrary.functions.named('doAComplicatedThing');
30703062
});
30713063

3072-
test('has a fully qualified name', () {
3073-
expect(thisIsAsync.fullyQualifiedName, 'fake.thisIsAsync');
3074-
});
3075-
30763064
test('does have a line number and column', () {
30773065
expect(thisIsAsync.characterLocation, isNotNull);
30783066
});
@@ -3370,10 +3358,6 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
33703358
'bool Function&lt;<wbr><span class="type-parameter">T4</span>&gt;<span class="signature">(<span class="parameter" id="param-"><span class="type-annotation">String</span>, </span><span class="parameter" id="param-"><span class="type-annotation">T1</span>, </span><span class="parameter" id="param-"><span class="type-annotation">T4</span></span>)</span>'));
33713359
});
33723360

3373-
test('has a fully qualified name', () {
3374-
expect(m1.fullyQualifiedName, 'ex.B.m1');
3375-
});
3376-
33773361
test('has abstract kind', () {
33783362
expect(abstractMethod.fullkind, 'abstract method');
33793363
});
@@ -3725,10 +3709,6 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
37253709
equals('Getter doc for explicitGetterImplicitSetter'));
37263710
});
37273711

3728-
test('has a fully qualified name', () {
3729-
expect(lengthX.fullyQualifiedName, 'fake.WithGetterAndSetter.lengthX');
3730-
});
3731-
37323712
test('has extended documentation', () {
37333713
expect(lengthX.oneLineDoc, equals('Returns a length.'));
37343714
expect(lengthX.documentation, contains('the fourth dimension'));
@@ -4014,10 +3994,6 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
40143994
equals('Setter docs should be shown.'));
40153995
});
40163996

4017-
test('has a fully qualified name', () {
4018-
expect(justGetter.fullyQualifiedName, 'fake.justGetter');
4019-
});
4020-
40213997
test('type arguments are correct', () {
40223998
var modelType = mapWithDynamicKeys.modelType as ParameterizedElementType;
40233999
expect(modelType.typeArguments, hasLength(2));
@@ -4097,10 +4073,6 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
40974073
expect(customClassPrivate.constantValue, 'const _APrivateConstClass()');
40984074
});
40994075

4100-
test('has a fully qualified name', () {
4101-
expect(greenConstant.fullyQualifiedName, 'ex.COLOR_GREEN');
4102-
});
4103-
41044076
test('has the correct kind', () {
41054077
expect(greenConstant.kind, equals(Kind.topLevelConstant));
41064078
});
@@ -4192,11 +4164,6 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
41924164
'ConstructorTester&lt;<wbr><span class="type-parameter">A</span>, <span class="type-parameter">B</span>&gt;.fromSomething');
41934165
});
41944166

4195-
test('has a fully qualified name', () {
4196-
expect(
4197-
appleConstructorFromString.fullyQualifiedName, 'ex.Apple.fromString');
4198-
});
4199-
42004167
test('has a line number and column', () {
42014168
expect(appleDefaultConstructor.characterLocation, isNotNull);
42024169
expect(syntheticConstructor.characterLocation, isNotNull);
@@ -4388,11 +4355,6 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
43884355
);
43894356
});
43904357

4391-
test('has a fully qualified name', () {
4392-
expect(processMessage.fullyQualifiedName, 'ex.processMessage');
4393-
expect(generic.fullyQualifiedName, 'fake.NewGenericTypedef');
4394-
});
4395-
43964358
test('has enclosing element', () {
43974359
expect(processMessage.enclosingElement.name, equals(exLibrary.name));
43984360
expect(generic.enclosingElement.name, equals(fakeLibrary.name));

test/extension_types_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ extension type ET<T extends num>(int it) implements num {
4040
class C {}
4141
''');
4242

43+
var et = library.extensionTypes.named('ET');
44+
expect(et.fullyQualifiedName, 'extension_types.ET');
4345
expect(
44-
library.extensionTypes.named('ET').documentationAsHtml,
46+
et.documentationAsHtml,
4547
'<p>Doc referring to '
4648
'<a href="${placeholder}extension_types/C-class.html">C</a>.</p>',
4749
);
@@ -57,12 +59,10 @@ extension type ET(int it) {
5759
class C {}
5860
''');
5961

62+
var et = library.extensionTypes.named('ET');
63+
expect(et.fullyQualifiedName, 'extension_types.ET');
6064
expect(
61-
library.extensionTypes
62-
.named('ET')
63-
.instanceMethods
64-
.named('m')
65-
.documentationAsHtml,
65+
et.instanceMethods.named('m').documentationAsHtml,
6666
'<p>Doc referring to '
6767
'<a href="${placeholder}extension_types/C-class.html">C</a>.</p>',
6868
);

test/extensions_test.dart

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ extension Ex on int {}
3131
var f() {}
3232
''');
3333

34+
var f = library.functions.named('f');
35+
expect(f.fullyQualifiedName, 'extension_methods.f');
3436
expect(
35-
library.functions.named('f').documentationAsHtml,
37+
f.documentationAsHtml,
3638
contains('<a href="$linkPrefix/Ex.html">Ex</a>'),
3739
);
3840
}
@@ -45,10 +47,12 @@ extension E on int {
4547
}
4648
''');
4749

50+
var f = library.extensions.first.instanceFields.first;
51+
expect(f.fullyQualifiedName, 'extension_methods.E.f');
4852
// We are primarily testing that dartdoc does not crash when trying to
4953
// resolve an unknown reference, from the position of an extension member.
5054
expect(
51-
library.extensions.first.instanceFields.first.documentationAsHtml,
55+
f.documentationAsHtml,
5256
contains('<p>Text <code>NotFound</code> text.</p>'),
5357
);
5458
}
@@ -63,8 +67,10 @@ extension Ex on int {
6367
var f() {}
6468
''');
6569

70+
var f = library.functions.named('f');
71+
expect(f.fullyQualifiedName, 'extension_methods.f');
6672
expect(
67-
library.functions.named('f').documentationAsHtml,
73+
f.documentationAsHtml,
6874
contains('<a href="$linkPrefix/Ex/m.html">Ex.m</a>'),
6975
);
7076
}
@@ -79,8 +85,10 @@ extension Ex on int {
7985
var f() {}
8086
''');
8187

88+
var f = library.functions.named('f');
89+
expect(f.fullyQualifiedName, 'extension_methods.f');
8290
expect(
83-
library.functions.named('f').documentationAsHtml,
91+
f.documentationAsHtml,
8492
contains('<a href="$linkPrefix/Ex/b.html">Ex.b</a>'),
8593
);
8694
}
@@ -95,8 +103,10 @@ extension Ex on int {
95103
var f() {}
96104
''');
97105

106+
var f = library.functions.named('f');
107+
expect(f.fullyQualifiedName, 'extension_methods.f');
98108
expect(
99-
library.functions.named('f').documentationAsHtml,
109+
f.documentationAsHtml,
100110
contains('<a href="$linkPrefix/Ex/b.html">Ex.b</a>'),
101111
);
102112
}

test/type_parameter_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ class TypeParameterTest extends DartdocTestBase {
1919
@override
2020
String get libraryName => 'type_parameters';
2121

22+
void test_name() async {
23+
var library = await bootPackageWithLibrary('''
24+
void f<T>(int p) {}
25+
''');
26+
var typeParameter = library.functions.named('f').typeParameters.first;
27+
expect(typeParameter.name, equals('T'));
28+
expect(typeParameter.fullyQualifiedName, equals('type_parameters.f.T'));
29+
}
30+
2231
void test_referenced() async {
2332
var library = await bootPackageWithLibrary('''
2433
/// Text [T].

test/typedef_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef T = C;
3636
''');
3737
final tTypedef = library.typedefs.named('T');
3838
expect(tTypedef.nameWithGenerics, 'T');
39+
expect(tTypedef.fullyQualifiedName, equals('typedefs.T'));
3940
expect(tTypedef.genericParameters, '');
4041
expect(tTypedef.aliasedType, isA<InterfaceType>());
4142
}
@@ -96,8 +97,8 @@ Line _two_.''');
9697
var library = await bootPackageWithLibrary('''
9798
typedef Cb2<T> = T Function(T);
9899
''');
99-
final cb2Typedef = library.typedefs.named('Cb2');
100-
100+
var cb2Typedef = library.typedefs.named('Cb2');
101+
expect(cb2Typedef.fullyQualifiedName, equals('typedefs.Cb2'));
101102
expect(
102103
cb2Typedef.nameWithGenerics,
103104
'Cb2&lt;<wbr><span class="type-parameter">T</span>&gt;',

0 commit comments

Comments
 (0)