Skip to content

Commit 6e62882

Browse files
authored
Remove outdated skips; tidy expectations (#2893)
1 parent 5cb56cd commit 6e62882

File tree

3 files changed

+88
-100
lines changed

3 files changed

+88
-100
lines changed

test/end2end/model_special_cases_test.dart

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,10 @@ void main() {
246246

247247
expect(aFunc.constantValue, equals('func'));
248248
expect(aFuncParams.constantValue, equals('funcTypeParams'));
249-
// Does not work @ analyzer 2.2
250-
//expect(aFuncWithArgs.constantValue, equals('funcTypeParams<String, int>'));
249+
var aFuncWithArgs = constructorTearoffs.constants
250+
.firstWhere((c) => c.name == 'aFuncWithArgs');
251+
expect(aFuncWithArgs.constantValue,
252+
equals('funcTypeParams<String, int>'));
251253

252254
expect(aTearOffDefaultConstructor.constantValue, equals('F.new'));
253255
expect(aTearOffNonDefaultConstructor.constantValue,
@@ -259,9 +261,11 @@ void main() {
259261

260262
expect(aTearOffDefaultConstructorTypedef.constantValue,
261263
equals('Fstring.new'));
262-
// Does not work @ analyzer 2.2
263-
//expect(aTearOffDefaultConstructorArgsTypedef.constantValue,
264-
// equals('Ft<String>.new'));
264+
var aTearOffDefaultConstructorArgsTypedef =
265+
constructorTearoffs.constants.firstWhere(
266+
(c) => c.name == 'aTearOffDefaultConstructorArgsTypedef');
267+
expect(aTearOffDefaultConstructorArgsTypedef.constantValue,
268+
equals('Ft<String>.new'));
265269
});
266270
}, skip: !_constructorTearoffsAllowed.allows(utils.platformVersion));
267271
});
@@ -355,11 +359,12 @@ void main() {
355359

356360
test('can inject HTML from tool', () {
357361
var envLine = RegExp(r'^Env: \{', multiLine: true);
358-
expect(envLine.allMatches(injectHtmlFromTool.documentation).length,
359-
equals(2));
362+
expect(envLine.allMatches(injectHtmlFromTool.documentation), hasLength(2),
363+
reason:
364+
'"${injectHtmlFromTool.documentation}" has wrong number of instances of "Env: {"');
360365
var argLine = RegExp(r'^Args: \[', multiLine: true);
361-
expect(argLine.allMatches(injectHtmlFromTool.documentation).length,
362-
equals(2));
366+
expect(
367+
argLine.allMatches(injectHtmlFromTool.documentation), hasLength(2));
363368
expect(
364369
injectHtmlFromTool.documentation,
365370
contains(
@@ -405,11 +410,8 @@ void main() {
405410

406411
test('Verify that ginormousPackageGraph takes in the SDK', () {
407412
expect(
408-
ginormousPackageGraph.packages
409-
.firstWhere((p) => p.isSdk)
410-
.libraries
411-
.length,
412-
greaterThan(1));
413+
ginormousPackageGraph.packages.firstWhere((p) => p.isSdk).libraries,
414+
hasLength(greaterThan(1)));
413415
expect(
414416
ginormousPackageGraph.packages
415417
.firstWhere((p) => p.isSdk)
@@ -435,7 +437,7 @@ void main() {
435437
.publicClasses
436438
.firstWhere((Class c) => c.name == 'IAmAClassWithCategories');
437439
expect(IAmAClassWithCategories.hasCategoryNames, isTrue);
438-
expect(IAmAClassWithCategories.categories.length, equals(1));
440+
expect(IAmAClassWithCategories.categories, hasLength(1));
439441
expect(
440442
IAmAClassWithCategories.categories.first.name, equals('Excellent'));
441443
expect(IAmAClassWithCategories.displayedCategories, isEmpty);
@@ -451,7 +453,7 @@ void main() {
451453
.publicClasses
452454
.firstWhere((Class c) => c.name == 'IAmAClassWithCategories');
453455
expect(IAmAClassWithCategoriesReexport.hasCategoryNames, isTrue);
454-
expect(IAmAClassWithCategoriesReexport.categories.length, equals(1));
456+
expect(IAmAClassWithCategoriesReexport.categories, hasLength(1));
455457
expect(IAmAClassWithCategoriesReexport.categories.first.name,
456458
equals('Superb'));
457459
expect(IAmAClassWithCategoriesReexport.displayedCategories, isNotEmpty);
@@ -471,7 +473,7 @@ void main() {
471473
.firstWhere((Class c) => c.name == 'SubForDocComments');
472474
expect(BaseForDocComments.hasCategoryNames, isTrue);
473475
// Display both, with the correct order and display name.
474-
expect(BaseForDocComments.displayedCategories.length, equals(2));
476+
expect(BaseForDocComments.displayedCategories, hasLength(2));
475477
expect(
476478
BaseForDocComments.displayedCategories.first.name, equals('Superb'));
477479
expect(

test/end2end/model_test.dart

Lines changed: 66 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -722,13 +722,11 @@ void main() {
722722
});
723723
test('can invoke a tool multiple times in one comment block', () {
724724
var envLine = RegExp(r'^Env: \{', multiLine: true);
725-
expect(
726-
envLine.allMatches(invokeToolMultipleSections.documentation).length,
727-
equals(2));
725+
expect(envLine.allMatches(invokeToolMultipleSections.documentation),
726+
hasLength(2));
728727
var argLine = RegExp(r'^Args: \[', multiLine: true);
729-
expect(
730-
argLine.allMatches(invokeToolMultipleSections.documentation).length,
731-
equals(2));
728+
expect(argLine.allMatches(invokeToolMultipleSections.documentation),
729+
hasLength(2));
732730
expect(invokeToolMultipleSections.documentation,
733731
contains('Invokes more than one tool in the same comment block.'));
734732
expect(invokeToolMultipleSections.documentation,
@@ -760,13 +758,12 @@ void main() {
760758

761759
group('Category', () {
762760
test('Verify categories for test_package', () {
763-
expect(packageGraph.localPackages.length, equals(1));
761+
expect(packageGraph.localPackages, hasLength(1));
764762
expect(packageGraph.localPackages.first.hasCategories, isTrue);
765763
var packageCategories = packageGraph.localPackages.first.categories;
766-
expect(packageCategories.length, equals(6));
767-
expect(
768-
packageGraph.localPackages.first.categoriesWithPublicLibraries.length,
769-
equals(3));
764+
expect(packageCategories, hasLength(6));
765+
expect(packageGraph.localPackages.first.categoriesWithPublicLibraries,
766+
hasLength(3));
770767
expect(
771768
packageCategories.map((c) => c.name).toList(),
772769
orderedEquals([
@@ -777,8 +774,16 @@ void main() {
777774
'More Excellence',
778775
'NotSoExcellent'
779776
]));
780-
expect(packageCategories.map((c) => c.libraries.length).toList(),
781-
orderedEquals([0, 2, 3, 1, 0, 0]));
777+
expect(
778+
packageCategories.map((c) => c.libraries).toList(),
779+
orderedEquals([
780+
hasLength(0),
781+
hasLength(2),
782+
hasLength(3),
783+
hasLength(1),
784+
hasLength(0),
785+
hasLength(0)
786+
]));
782787
});
783788

784789
test('Verify libraries with multiple categories show up in multiple places',
@@ -1296,22 +1301,21 @@ void main() {
12961301
});
12971302

12981303
test('Verify table appearance', () {
1299-
expect(docsAsHtml.contains('<table><thead><tr><th>Component</th>'),
1300-
isTrue);
1304+
expect(docsAsHtml, contains('<table><thead><tr><th>Component</th>'));
13011305
});
13021306

13031307
test('Verify links inside of table headers', () {
13041308
expect(
1305-
docsAsHtml.contains(
1306-
'<th><a href="${htmlBasePlaceholder}fake/Annotation-class.html">Annotation</a></th>'),
1307-
isTrue);
1309+
docsAsHtml,
1310+
contains(
1311+
'<th><a href="${htmlBasePlaceholder}fake/Annotation-class.html">Annotation</a></th>'));
13081312
});
13091313

13101314
test('Verify links inside of table body', () {
13111315
expect(
1312-
docsAsHtml.contains(
1313-
'<tbody><tr><td><a href="${htmlBasePlaceholder}fake/DocumentWithATable/foo-constant.html">foo</a></td>'),
1314-
isTrue);
1316+
docsAsHtml,
1317+
contains(
1318+
'<tbody><tr><td><a href="${htmlBasePlaceholder}fake/DocumentWithATable/foo-constant.html">foo</a></td>'));
13151319
});
13161320

13171321
test('Verify there is no emoji support', () {
@@ -1910,7 +1914,7 @@ void main() {
19101914
.map<String>((ElementType t) => t.name),
19111915
orderedEquals(['int']));
19121916

1913-
expect(TypeInferenceMixedIn.superChain.length, equals(2));
1917+
expect(TypeInferenceMixedIn.superChain, hasLength(2));
19141918
final firstType =
19151919
TypeInferenceMixedIn.superChain.first as ParameterizedElementType;
19161920
final lastType =
@@ -2143,8 +2147,8 @@ void main() {
21432147
test('all instance methods', () {
21442148
var methods = B.publicInstanceMethods.where((m) => !m.isInherited);
21452149
expect(methods, isNotEmpty);
2146-
expect(B.publicInstanceMethods.length,
2147-
equals(methods.length + B.publicInheritedMethods.length));
2150+
expect(B.publicInstanceMethods,
2151+
hasLength(methods.length + B.publicInheritedMethods.length));
21482152
});
21492153

21502154
test('inherited methods exist', () {
@@ -3014,7 +3018,7 @@ void main() {
30143018
});
30153019

30163020
test('static fields inside extensions do not crash', () {
3017-
expect(staticFieldExtension.staticFields.length, equals(1));
3021+
expect(staticFieldExtension.staticFields, hasLength(1));
30183022
expect(staticFieldExtension.staticFields.first.name, equals('aStatic'));
30193023
});
30203024

@@ -3125,7 +3129,7 @@ void main() {
31253129
'<a href="%%__HTMLBASE_dartdoc_internal__%%ex/AnExtendableThing-class.html">AnExtendableThing</a>'));
31263130
// TODO(jcollins-g): consider linking via applied extensions?
31273131
expect(doSomeStuff.documentationAsHtml, contains('<code>aMember</code>'));
3128-
}, skip: 'unskip when enhanced lookups are on by default');
3132+
});
31293133

31303134
test(
31313135
'references from outside an extension refer correctly to the extension',
@@ -3458,10 +3462,10 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
34583462
params,
34593463
'<span class="parameter" id="doAComplicatedThing-param-x"><span class="type-annotation">int</span> <span class="parameter-name">x</span>, </span>'
34603464
'<span class="parameter" id="doAComplicatedThing-param-doSomething">{<span class="type-annotation">void</span> <span class="parameter-name">doSomething</span>(<span class="parameter" id="doSomething-param-aThingParameter"><span class="type-annotation">int</span> <span class="parameter-name">aThingParameter</span>, </span>'
3461-
'<span class="parameter" id="doSomething-param-anotherThing"><span class="type-annotation">String</span> <span class="parameter-name">anotherThing</span></span>), </span>'
3465+
'<span class="parameter" id="doSomething-param-anotherThing"><span class="type-annotation">String</span> <span class="parameter-name">anotherThing</span></span>)?, </span>'
34623466
'<span class="parameter" id="doAComplicatedThing-param-doSomethingElse"><span class="type-annotation">void</span> <span class="parameter-name">doSomethingElse</span>(<span class="parameter" id="doSomethingElse-param-aThingParameter"><span class="type-annotation">int</span> <span class="parameter-name">aThingParameter</span>, </span>'
3463-
'<span class="parameter" id="doSomethingElse-param-somethingElse"><span class="type-annotation">double</span> <span class="parameter-name">somethingElse</span></span>)}</span>');
3464-
}, skip: 'reenable with analyzer > 1.7.1');
3467+
'<span class="parameter" id="doSomethingElse-param-somethingElse"><span class="type-annotation">double</span> <span class="parameter-name">somethingElse</span></span>)?}</span>');
3468+
});
34653469
});
34663470

34673471
group('Type expansion', () {
@@ -3941,12 +3945,10 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
39413945
});
39423946

39433947
test('annotations from getters and setters are accumulated in Fields', () {
3944-
expect(
3945-
explicitGetterSetter.featuresAsString.contains('a Getter Annotation'),
3946-
isTrue);
3947-
expect(
3948-
explicitGetterSetter.featuresAsString.contains('a Setter Annotation'),
3949-
isTrue);
3948+
expect(explicitGetterSetter.featuresAsString,
3949+
contains('a Getter Annotation'));
3950+
expect(explicitGetterSetter.featuresAsString,
3951+
contains('a Setter Annotation'));
39503952
});
39513953

39523954
test('Docs from inherited implicit accessors are preserved', () {
@@ -3974,10 +3976,8 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
39743976
expect(documentedPartialFieldInSubclassOnly.readOnly, isTrue);
39753977
expect(documentedPartialFieldInSubclassOnly.documentationComment,
39763978
contains('This getter is documented'));
3977-
expect(
3978-
documentedPartialFieldInSubclassOnly.annotations
3979-
.contains(Feature.inheritedSetter),
3980-
isFalse);
3979+
expect(documentedPartialFieldInSubclassOnly.annotations,
3980+
isNot(contains(Feature.inheritedSetter)));
39813981
});
39823982

39833983
test('@nodoc overridden in subclass for getter works', () {
@@ -4000,22 +4000,16 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
40004000
expect(implicitGetterExplicitSetter.getter!.isInherited, isTrue);
40014001
expect(implicitGetterExplicitSetter.setter!.isInherited, isFalse);
40024002
expect(implicitGetterExplicitSetter.isInherited, isFalse);
4003-
expect(implicitGetterExplicitSetter.features.contains(Feature.inherited),
4004-
isFalse);
4003+
expect(implicitGetterExplicitSetter.features,
4004+
isNot(contains(Feature.inherited)));
4005+
expect(implicitGetterExplicitSetter.features,
4006+
contains(Feature.inheritedGetter));
4007+
expect(implicitGetterExplicitSetter.features,
4008+
isNot(contains(Feature.overrideFeature)));
4009+
expect(implicitGetterExplicitSetter.features,
4010+
contains(Feature.overrideSetter));
40054011
expect(
4006-
implicitGetterExplicitSetter.features
4007-
.contains(Feature.inheritedGetter),
4008-
isTrue);
4009-
expect(
4010-
implicitGetterExplicitSetter.features
4011-
.contains(Feature.overrideFeature),
4012-
isFalse);
4013-
expect(
4014-
implicitGetterExplicitSetter.features
4015-
.contains(Feature.overrideSetter),
4016-
isTrue);
4017-
expect(implicitGetterExplicitSetter.features.contains(Feature.readWrite),
4018-
isTrue);
4012+
implicitGetterExplicitSetter.features, contains(Feature.readWrite));
40194013
expect(
40204014
implicitGetterExplicitSetter.oneLineDoc,
40214015
equals(
@@ -4030,22 +4024,16 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
40304024
expect(explicitGetterImplicitSetter.getter!.isInherited, isFalse);
40314025
expect(explicitGetterImplicitSetter.setter!.isInherited, isTrue);
40324026
expect(explicitGetterImplicitSetter.isInherited, isFalse);
4033-
expect(explicitGetterImplicitSetter.features.contains(Feature.inherited),
4034-
isFalse);
4035-
expect(
4036-
explicitGetterImplicitSetter.features
4037-
.contains(Feature.inheritedSetter),
4038-
isTrue);
4039-
expect(
4040-
explicitGetterImplicitSetter.features
4041-
.contains(Feature.overrideFeature),
4042-
isFalse);
4043-
expect(
4044-
explicitGetterImplicitSetter.features
4045-
.contains(Feature.overrideGetter),
4046-
isTrue);
4047-
expect(explicitGetterImplicitSetter.features.contains(Feature.readWrite),
4048-
isTrue);
4027+
expect(explicitGetterImplicitSetter.features,
4028+
isNot(contains(Feature.inherited)));
4029+
expect(explicitGetterImplicitSetter.features,
4030+
contains(Feature.inheritedSetter));
4031+
expect(explicitGetterImplicitSetter.features,
4032+
isNot(contains(Feature.overrideFeature)));
4033+
expect(explicitGetterImplicitSetter.features,
4034+
contains(Feature.overrideGetter));
4035+
expect(
4036+
explicitGetterImplicitSetter.features, contains(Feature.readWrite));
40494037
expect(explicitGetterImplicitSetter.oneLineDoc,
40504038
equals('Getter doc for explicitGetterImplicitSetter'));
40514039
// Even though we have some new setter docs, getter still takes priority.
@@ -4167,9 +4155,8 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
41674155
() {
41684156
var withGenericSub =
41694157
exLibrary.classes.firstWhere((c) => c.name == 'WithGenericSub');
4170-
expect(
4171-
withGenericSub.inheritedFields.where((p) => p.name == 'prop').length,
4172-
equals(1));
4158+
expect(withGenericSub.inheritedFields.where((p) => p.name == 'prop'),
4159+
hasLength(1));
41734160
});
41744161
});
41754162

@@ -4866,7 +4853,7 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
48664853
test('uses = instead of : to set default value', () {
48674854
final rendered =
48684855
ParameterRendererHtml().renderLinkedParams([intCheckOptional]);
4869-
expect(rendered.contains('</span> = <span'), isTrue);
4856+
expect(rendered, contains('</span> = <span'));
48704857
});
48714858

48724859
test('linkedName', () {
@@ -4880,7 +4867,8 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
48804867
test('param with generics', () {
48814868
var params = ParameterRendererHtml()
48824869
.renderLinkedParams(methodWithGenericParam.parameters);
4883-
expect(params.contains('List') && params.contains('Apple'), isTrue);
4870+
expect(params, contains('List'));
4871+
expect(params, contains('Apple'));
48844872
});
48854873

48864874
test('commas on same param line', () {
@@ -4987,9 +4975,9 @@ String? topLevelFunction(int param1, bool param2, Cool coolBeans,
49874975
test('Cat has implementors', () {
49884976
expect(implC, hasLength(3));
49894977
var implementors = <String>['B', 'Dog', 'ConstantCat'];
4990-
expect(implementors.contains(implC[0].name), isTrue);
4991-
expect(implementors.contains(implC[1].name), isTrue);
4992-
expect(implementors.contains(implC[2].name), isTrue);
4978+
expect(implementors, contains(implC[0].name));
4979+
expect(implementors, contains(implC[1].name));
4980+
expect(implementors, contains(implC[2].name));
49934981
});
49944982

49954983
test('B does not have implementors', () {

testing/test_package_experiments/lib/constructor_tearoffs.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class F<T> {
5151
F.alternative() {}
5252
}
5353

54-
typedef Ft = F;
54+
typedef Ft<T> = F<T>;
5555

5656
/// Referring to [Fstring.new] should be fine.
5757
typedef Fstring = F<String>;
@@ -68,8 +68,7 @@ void funcTypeParams<T extends String, U extends num>(
6868

6969
const aFunc = func;
7070
const aFuncParams = funcTypeParams;
71-
// TODO(jcollins-g): does not work @ analyzer 2.2
72-
//const aFuncWithArgs = funcTypeParams<String, int>;
71+
const aFuncWithArgs = funcTypeParams<String, int>;
7372

7473
const aTearOffDefaultConstructor = F.new;
7574
const aTearOffNonDefaultConstructor = F.alternative;
@@ -78,5 +77,4 @@ const aTearOffDefaultConstructorArgs = F<String>.new;
7877

7978
const aTearOffDefaultConstructorTypedef = Fstring.new;
8079

81-
// TODO(jcollins-g): does not work @ analyzer 2.2
82-
//const aTearOffDefaultConstructorArgsTypedef = Ft<String>.new;
80+
const aTearOffDefaultConstructorArgsTypedef = Ft<String>.new;

0 commit comments

Comments
 (0)