@@ -76,6 +76,55 @@ void main() {
7676 packageGraph.libraries.firstWhere ((lib) => lib.name == 'base_class' );
7777 });
7878
79+ group ('Set Literals' , () {
80+ Library set_literals;
81+ TopLevelVariable aComplexSet,
82+ inferredTypeSet,
83+ specifiedSet,
84+ untypedMap,
85+ typedSet;
86+
87+ setUpAll (() async {
88+ set_literals = packageGraph.libraries
89+ .firstWhere ((lib) => lib.name == 'set_literals' );
90+ aComplexSet =
91+ set_literals.constants.firstWhere ((v) => v.name == 'aComplexSet' );
92+ inferredTypeSet =
93+ set_literals.constants.firstWhere ((v) => v.name == 'inferredTypeSet' );
94+ specifiedSet =
95+ set_literals.constants.firstWhere ((v) => v.name == 'specifiedSet' );
96+ untypedMap =
97+ set_literals.constants.firstWhere ((v) => v.name == 'untypedMap' );
98+ typedSet = set_literals.constants.firstWhere ((v) => v.name == 'typedSet' );
99+ });
100+
101+ test ('Set literals test' , () {
102+ expect (aComplexSet.modelType.name, equals ('Set' ));
103+ expect (aComplexSet.modelType.typeArguments.map ((a) => a.name).toList (),
104+ equals (['AClassContainingLiterals' ]));
105+ expect (aComplexSet.constantValue,
106+ equals ('const {const AClassContainingLiterals(3, 5)}' ));
107+ expect (inferredTypeSet.modelType.name, equals ('Set' ));
108+ expect (
109+ inferredTypeSet.modelType.typeArguments.map ((a) => a.name).toList (),
110+ equals (['num' ]));
111+ expect (inferredTypeSet.constantValue, equals ('const {1, 2.5, 3}' ));
112+ expect (specifiedSet.modelType.name, equals ('Set' ));
113+ expect (specifiedSet.modelType.typeArguments.map ((a) => a.name).toList (),
114+ equals (['int' ]));
115+ expect (specifiedSet.constantValue, equals ('const {}' ));
116+ expect (untypedMap.modelType.name, equals ('Map' ));
117+ expect (untypedMap.modelType.typeArguments.map ((a) => a.name).toList (),
118+ equals (['dynamic' , 'dynamic' ]));
119+ expect (untypedMap.constantValue, equals ('const {}' ));
120+ expect (typedSet.modelType.name, equals ('Set' ));
121+ expect (typedSet.modelType.typeArguments.map ((a) => a.name).toList (),
122+ equals (['String' ]));
123+ expect (typedSet.constantValue,
124+ matches (RegExp (r'const <String>\s?{}' )));
125+ });
126+ });
127+
79128 group ('Tools' , () {
80129 Class toolUser;
81130 Class _NonCanonicalToolUser , CanonicalToolUser , PrivateLibraryToolUser ;
@@ -291,10 +340,6 @@ void main() {
291340 ]));
292341 expect (packageCategories.map ((c) => c.libraries.length).toList (),
293342 orderedEquals ([0 , 2 , 3 , 1 , 0 , 0 ]));
294- expect (
295- packageGraph
296- .localPackages.first.defaultCategory.publicLibraries.length,
297- equals (9 ));
298343 });
299344
300345 test ('Verify libraries with multiple categories show up in multiple places' ,
@@ -313,7 +358,8 @@ void main() {
313358 expect (
314359 packageGraph
315360 .localPackages.first.defaultCategory.publicLibraries.length,
316- equals (9 ));
361+ // Only 5 libraries have categories, the rest belong in default.
362+ equals (utils.kTestPackagePublicLibraries - 5 ));
317363 });
318364 });
319365
@@ -383,7 +429,8 @@ void main() {
383429 });
384430
385431 test ('libraries' , () {
386- expect (packageGraph.localPublicLibraries, hasLength (14 ));
432+ expect (packageGraph.localPublicLibraries,
433+ hasLength (utils.kTestPackagePublicLibraries));
387434 expect (interceptorsLib.isPublic, isFalse);
388435 });
389436
@@ -398,7 +445,8 @@ void main() {
398445
399446 Package package = packageGraph.localPackages.first;
400447 expect (package.name, 'test_package' );
401- expect (package.publicLibraries, hasLength (14 ));
448+ expect (package.publicLibraries,
449+ hasLength (utils.kTestPackagePublicLibraries));
402450 });
403451
404452 test ('is documented in library' , () {
@@ -710,11 +758,12 @@ void main() {
710758 EnumField enumValue2;
711759
712760 setUpAll (() {
713- enumWithAnimation = exLibrary.enums.firstWhere ((c) => c.name == 'EnumWithAnimation' );
714- enumValue1 = enumWithAnimation.constants
715- .firstWhere ((m) => m.name == 'value1' );
716- enumValue2 = enumWithAnimation.constants
717- .firstWhere ((m) => m.name == 'value2' );
761+ enumWithAnimation =
762+ exLibrary.enums.firstWhere ((c) => c.name == 'EnumWithAnimation' );
763+ enumValue1 =
764+ enumWithAnimation.constants.firstWhere ((m) => m.name == 'value1' );
765+ enumValue2 =
766+ enumWithAnimation.constants.firstWhere ((m) => m.name == 'value2' );
718767 dog = exLibrary.classes.firstWhere ((c) => c.name == 'Dog' );
719768 withAnimation =
720769 dog.allInstanceMethods.firstWhere ((m) => m.name == 'withAnimation' );
@@ -775,12 +824,18 @@ void main() {
775824 contains ('<video id="outOfOrder"' ));
776825 });
777826 test ("Enum field animation identifiers are unique." , () {
778- expect (enumValue1.documentationAsHtml, contains ('<video id="animation_1"' ));
779- expect (enumValue1.documentationAsHtml, contains ('<video id="animation_2"' ));
780- expect (enumValue2.documentationAsHtml, isNot (contains ('<video id="animation_1"' )));
781- expect (enumValue2.documentationAsHtml, isNot (contains ('<video id="animation_2"' )));
782- expect (enumValue2.documentationAsHtml, contains ('<video id="animation_3"' ));
783- expect (enumValue2.documentationAsHtml, contains ('<video id="animation_4"' ));
827+ expect (
828+ enumValue1.documentationAsHtml, contains ('<video id="animation_1"' ));
829+ expect (
830+ enumValue1.documentationAsHtml, contains ('<video id="animation_2"' ));
831+ expect (enumValue2.documentationAsHtml,
832+ isNot (contains ('<video id="animation_1"' )));
833+ expect (enumValue2.documentationAsHtml,
834+ isNot (contains ('<video id="animation_2"' )));
835+ expect (
836+ enumValue2.documentationAsHtml, contains ('<video id="animation_3"' ));
837+ expect (
838+ enumValue2.documentationAsHtml, contains ('<video id="animation_4"' ));
784839 });
785840 });
786841
0 commit comments