@@ -53,9 +53,11 @@ void main() {
53
53
54
54
PackageGraph packageGraph;
55
55
PackageGraph packageGraphSmall;
56
+ PackageGraph packageGraphErrors;
56
57
PackageGraph ginormousPackageGraph;
57
58
Library exLibrary;
58
59
Library fakeLibrary;
60
+ Library errorLibrary;
59
61
Library twoExportsLib;
60
62
Library interceptorsLib;
61
63
PackageGraph sdkAsPackageGraph;
@@ -65,8 +67,11 @@ void main() {
65
67
await utils.init ();
66
68
packageGraph = utils.testPackageGraph;
67
69
packageGraphSmall = utils.testPackageGraphSmall;
70
+ packageGraphErrors = utils.testPackageGraphErrors;
68
71
ginormousPackageGraph = utils.testPackageGraphGinormous;
69
72
exLibrary = packageGraph.libraries.firstWhere ((lib) => lib.name == 'ex' );
73
+ errorLibrary = packageGraphErrors.libraries
74
+ .firstWhere ((lib) => lib.name == 'doc_errors' );
70
75
fakeLibrary =
71
76
packageGraph.libraries.firstWhere ((lib) => lib.name == 'fake' );
72
77
dartAsync =
@@ -97,10 +102,8 @@ void main() {
97
102
invokeTool.documentation,
98
103
contains (
99
104
new RegExp (r'--source=lib[/\\]example\.dart_[0-9]+_[0-9]+, ' )));
100
- expect (
101
- invokeTool.documentation,
102
- contains (new RegExp (
103
- r'--package-path=<PACKAGE_PATH>, ' )));
105
+ expect (invokeTool.documentation,
106
+ contains (new RegExp (r'--package-path=<PACKAGE_PATH>, ' )));
104
107
expect (
105
108
invokeTool.documentation, contains ('--package-name=test_package, ' ));
106
109
expect (invokeTool.documentation, contains ('--library-name=ex, ' ));
@@ -115,10 +118,8 @@ void main() {
115
118
contains (new RegExp ('SOURCE_COLUMN: [0-9]+, ' )));
116
119
expect (invokeTool.documentation,
117
120
contains (new RegExp (r'SOURCE_PATH: lib[/\\]example\.dart, ' )));
118
- expect (
119
- invokeTool.documentation,
120
- contains (new RegExp (
121
- r'PACKAGE_PATH: <PACKAGE_PATH>, ' )));
121
+ expect (invokeTool.documentation,
122
+ contains (new RegExp (r'PACKAGE_PATH: <PACKAGE_PATH>, ' )));
122
123
expect (
123
124
invokeTool.documentation, contains ('PACKAGE_NAME: test_package, ' ));
124
125
expect (invokeTool.documentation, contains ('LIBRARY_NAME: ex, ' ));
@@ -731,99 +732,50 @@ void main() {
731
732
});
732
733
});
733
734
734
- group ('Animation' , () {
735
- Class dog;
736
- Method withAnimation;
737
- Method withNamedAnimation;
738
- Method withQuoteNamedAnimation;
735
+ group ('Animation Errors' , () {
736
+ Class documentationErrors;
739
737
Method withInvalidNamedAnimation;
740
- Method withDeprecatedAnimation;
741
738
Method withAnimationNonUnique;
742
739
Method withAnimationNonUniqueDeprecated;
743
740
Method withAnimationWrongParams;
744
741
Method withAnimationBadWidth;
745
742
Method withAnimationBadHeight;
746
- Method withAnimationInOneLineDoc;
747
- Method withAnimationInline;
748
- Method withAnimationOutOfOrder;
749
743
Method withAnimationUnknownArg;
750
744
751
745
setUp (() {
752
- dog = exLibrary.classes.firstWhere ((c) => c.name == 'Dog' );
753
- withAnimation =
754
- dog.allInstanceMethods.firstWhere ((m) => m.name == 'withAnimation' );
755
- withNamedAnimation = dog.allInstanceMethods
756
- .firstWhere ((m) => m.name == 'withNamedAnimation' );
757
- withQuoteNamedAnimation = dog.allInstanceMethods
758
- .firstWhere ((m) => m.name == 'withQuotedNamedAnimation' );
759
- withInvalidNamedAnimation = dog.allInstanceMethods
746
+ documentationErrors = errorLibrary.classes
747
+ .firstWhere ((c) => c.name == 'DocumentationErrors' );
748
+ withInvalidNamedAnimation = documentationErrors.allInstanceMethods
760
749
.firstWhere ((m) => m.name == 'withInvalidNamedAnimation' );
761
- withDeprecatedAnimation = dog.allInstanceMethods
762
- .firstWhere ((m) => m.name == 'withDeprecatedAnimation' );
763
- withAnimationNonUnique = dog.allInstanceMethods
750
+ withAnimationNonUnique = documentationErrors.allInstanceMethods
764
751
.firstWhere ((m) => m.name == 'withAnimationNonUnique' );
765
- withAnimationNonUniqueDeprecated = dog .allInstanceMethods
752
+ withAnimationNonUniqueDeprecated = documentationErrors .allInstanceMethods
766
753
.firstWhere ((m) => m.name == 'withAnimationNonUniqueDeprecated' );
767
- withAnimationWrongParams = dog .allInstanceMethods
754
+ withAnimationWrongParams = documentationErrors .allInstanceMethods
768
755
.firstWhere ((m) => m.name == 'withAnimationWrongParams' );
769
- withAnimationBadWidth = dog .allInstanceMethods
756
+ withAnimationBadWidth = documentationErrors .allInstanceMethods
770
757
.firstWhere ((m) => m.name == 'withAnimationBadWidth' );
771
- withAnimationBadHeight = dog .allInstanceMethods
758
+ withAnimationBadHeight = documentationErrors .allInstanceMethods
772
759
.firstWhere ((m) => m.name == 'withAnimationBadHeight' );
773
- withAnimationInOneLineDoc = dog.allInstanceMethods
774
- .firstWhere ((m) => m.name == 'withAnimationInOneLineDoc' );
775
- withAnimationInline = dog.allInstanceMethods
776
- .firstWhere ((m) => m.name == 'withAnimationInline' );
777
- withAnimationOutOfOrder = dog.allInstanceMethods
778
- .firstWhere ((m) => m.name == 'withAnimationOutOfOrder' );
779
- withAnimationUnknownArg = dog.allInstanceMethods
760
+ withAnimationUnknownArg = documentationErrors.allInstanceMethods
780
761
.firstWhere ((m) => m.name == 'withAnimationUnknownArg' );
781
- packageGraph .allLocalModelElements.forEach ((m) => m.documentation);
762
+ packageGraphErrors .allLocalModelElements.forEach ((m) => m.documentation);
782
763
});
783
764
784
- test ("renders an unnamed animation within the method documentation" , () {
785
- expect (withAnimation.documentation, contains ('<video id="animation_1"' ));
786
- });
787
- test ("renders a named animation within the method documentation" , () {
788
- expect (withNamedAnimation.documentation,
789
- contains ('<video id="namedAnimation"' ));
790
- });
791
- test ("renders a quoted, named animation within the method documentation" ,
792
- () {
793
- expect (withQuoteNamedAnimation.documentation,
794
- contains ('<video id="quotedNamedAnimation"' ));
795
- expect (withQuoteNamedAnimation.documentation,
796
- contains ('<video id="quotedNamedAnimation2"' ));
797
- });
798
765
test ("warns with invalidly-named animation within the method documentation" ,
799
766
() {
800
767
expect (
801
- packageGraph .packageWarningCounter.hasWarning (
768
+ packageGraphErrors .packageWarningCounter.hasWarning (
802
769
withInvalidNamedAnimation,
803
770
PackageWarning .invalidParameter,
804
771
'An animation has an invalid identifier, "2isNot-A-ValidName". '
805
772
'The identifier can only contain letters, numbers and '
806
773
'underscores, and must not begin with a number.' ),
807
774
isTrue);
808
775
});
809
- test ("renders a deprecated-form animation within the method documentation" ,
810
- () {
811
- expect (withDeprecatedAnimation.documentation,
812
- contains ('<video id="deprecatedAnimation"' ));
813
- expect (
814
- packageGraph.packageWarningCounter.hasWarning (
815
- withDeprecatedAnimation,
816
- PackageWarning .deprecated,
817
- 'Deprecated form of @animation directive, '
818
- '"{@animation deprecatedAnimation 100 100 http://host/path/to/video.mp4}"\n '
819
- 'Animation directives are now of the form "{@animation '
820
- 'WIDTH HEIGHT URL [id=ID]}" (id is an optional '
821
- 'parameter)' ),
822
- isTrue);
823
- });
824
776
test ("warns on a non-unique animation name within a method" , () {
825
777
expect (
826
- packageGraph .packageWarningCounter.hasWarning (
778
+ packageGraphErrors .packageWarningCounter.hasWarning (
827
779
withAnimationNonUnique,
828
780
PackageWarning .invalidParameter,
829
781
'An animation has a non-unique identifier, "barHerderAnimation". '
@@ -833,7 +785,7 @@ void main() {
833
785
test ("warns on a non-unique animation name within a deprecated-form method" ,
834
786
() {
835
787
expect (
836
- packageGraph .packageWarningCounter.hasWarning (
788
+ packageGraphErrors .packageWarningCounter.hasWarning (
837
789
withAnimationNonUniqueDeprecated,
838
790
PackageWarning .invalidParameter,
839
791
'An animation has a non-unique identifier, "fooHerderAnimation". '
@@ -842,7 +794,7 @@ void main() {
842
794
});
843
795
test ("warns on animation with missing parameters" , () {
844
796
expect (
845
- packageGraph .packageWarningCounter.hasWarning (
797
+ packageGraphErrors .packageWarningCounter.hasWarning (
846
798
withAnimationWrongParams,
847
799
PackageWarning .invalidParameter,
848
800
'Invalid @animation directive, "{@animation http://host/path/to/video.mp4}"\n '
@@ -852,7 +804,7 @@ void main() {
852
804
});
853
805
test ("warns on animation with non-integer width" , () {
854
806
expect (
855
- packageGraph .packageWarningCounter.hasWarning (
807
+ packageGraphErrors .packageWarningCounter.hasWarning (
856
808
withAnimationBadWidth,
857
809
PackageWarning .invalidParameter,
858
810
'An animation has an invalid width (badWidthAnimation), "100px". '
@@ -861,13 +813,82 @@ void main() {
861
813
});
862
814
test ("warns on animation with non-integer height" , () {
863
815
expect (
864
- packageGraph .packageWarningCounter.hasWarning (
816
+ packageGraphErrors .packageWarningCounter.hasWarning (
865
817
withAnimationBadHeight,
866
818
PackageWarning .invalidParameter,
867
819
'An animation has an invalid height (badHeightAnimation), '
868
820
'"100px". The height must be an integer.' ),
869
821
isTrue);
870
822
});
823
+ test ("Unknown arguments generate an error." , () {
824
+ expect (
825
+ packageGraphErrors.packageWarningCounter.hasWarning (
826
+ withAnimationUnknownArg,
827
+ PackageWarning .invalidParameter,
828
+ 'The {@animation ...} directive was called with invalid '
829
+ 'parameters. FormatException: Could not find an option named "name".' ),
830
+ isTrue);
831
+ });
832
+ });
833
+
834
+ group ('Animation' , () {
835
+ Class dog;
836
+ Method withAnimation;
837
+ Method withNamedAnimation;
838
+ Method withQuoteNamedAnimation;
839
+ Method withDeprecatedAnimation;
840
+ Method withAnimationInOneLineDoc;
841
+ Method withAnimationInline;
842
+ Method withAnimationOutOfOrder;
843
+
844
+ setUp (() {
845
+ dog = exLibrary.classes.firstWhere ((c) => c.name == 'Dog' );
846
+ withAnimation =
847
+ dog.allInstanceMethods.firstWhere ((m) => m.name == 'withAnimation' );
848
+ withNamedAnimation = dog.allInstanceMethods
849
+ .firstWhere ((m) => m.name == 'withNamedAnimation' );
850
+ withQuoteNamedAnimation = dog.allInstanceMethods
851
+ .firstWhere ((m) => m.name == 'withQuotedNamedAnimation' );
852
+ withDeprecatedAnimation = dog.allInstanceMethods
853
+ .firstWhere ((m) => m.name == 'withDeprecatedAnimation' );
854
+ withAnimationInOneLineDoc = dog.allInstanceMethods
855
+ .firstWhere ((m) => m.name == 'withAnimationInOneLineDoc' );
856
+ withAnimationInline = dog.allInstanceMethods
857
+ .firstWhere ((m) => m.name == 'withAnimationInline' );
858
+ withAnimationOutOfOrder = dog.allInstanceMethods
859
+ .firstWhere ((m) => m.name == 'withAnimationOutOfOrder' );
860
+ packageGraph.allLocalModelElements.forEach ((m) => m.documentation);
861
+ });
862
+
863
+ test ("renders an unnamed animation within the method documentation" , () {
864
+ expect (withAnimation.documentation, contains ('<video id="animation_1"' ));
865
+ });
866
+ test ("renders a named animation within the method documentation" , () {
867
+ expect (withNamedAnimation.documentation,
868
+ contains ('<video id="namedAnimation"' ));
869
+ });
870
+ test ("renders a quoted, named animation within the method documentation" ,
871
+ () {
872
+ expect (withQuoteNamedAnimation.documentation,
873
+ contains ('<video id="quotedNamedAnimation"' ));
874
+ expect (withQuoteNamedAnimation.documentation,
875
+ contains ('<video id="quotedNamedAnimation2"' ));
876
+ });
877
+ test ("renders a deprecated-form animation within the method documentation" ,
878
+ () {
879
+ expect (withDeprecatedAnimation.documentation,
880
+ contains ('<video id="deprecatedAnimation"' ));
881
+ expect (
882
+ packageGraph.packageWarningCounter.hasWarning (
883
+ withDeprecatedAnimation,
884
+ PackageWarning .deprecated,
885
+ 'Deprecated form of @animation directive, '
886
+ '"{@animation deprecatedAnimation 100 100 http://host/path/to/video.mp4}"\n '
887
+ 'Animation directives are now of the form "{@animation '
888
+ 'WIDTH HEIGHT URL [id=ID]}" (id is an optional '
889
+ 'parameter)' ),
890
+ isTrue);
891
+ });
871
892
test ("Doesn't place animations in one line doc" , () {
872
893
expect (withAnimationInOneLineDoc.oneLineDoc, isNot (contains ('<video' )));
873
894
expect (withAnimationInOneLineDoc.documentation, contains ('<video' ));
@@ -881,15 +902,6 @@ void main() {
881
902
expect (withAnimationOutOfOrder.documentation,
882
903
contains ('<video id="outOfOrder"' ));
883
904
});
884
- test ("Unknown arguments generate an error." , () {
885
- expect (
886
- packageGraph.packageWarningCounter.hasWarning (
887
- withAnimationUnknownArg,
888
- PackageWarning .invalidParameter,
889
- 'The {@animation ...} directive was called with invalid '
890
- 'parameters. FormatException: Could not find an option named "name".' ),
891
- isTrue);
892
- });
893
905
});
894
906
895
907
group ('MultiplyInheritedExecutableElement handling' , () {
@@ -1570,7 +1582,7 @@ void main() {
1570
1582
});
1571
1583
1572
1584
test ('get methods' , () {
1573
- expect (Dog .publicInstanceMethods, hasLength (26 ));
1585
+ expect (Dog .publicInstanceMethods, hasLength (19 ));
1574
1586
});
1575
1587
1576
1588
test ('get operators' , () {
@@ -1636,23 +1648,16 @@ void main() {
1636
1648
'testMethod' ,
1637
1649
'toString' ,
1638
1650
'withAnimation' ,
1639
- 'withAnimationBadHeight' ,
1640
- 'withAnimationBadWidth' ,
1641
1651
'withAnimationInline' ,
1652
+ 'withAnimationOutOfOrder' ,
1642
1653
'withAnimationInOneLineDoc' ,
1643
- 'withAnimationNonUnique' ,
1644
- 'withAnimationNonUniqueDeprecated' ,
1645
- 'withAnimationWrongParams' ,
1646
1654
'withDeprecatedAnimation' ,
1647
- 'withInvalidNamedAnimation' ,
1648
1655
'withMacro' ,
1649
1656
'withMacro2' ,
1650
1657
'withNamedAnimation' ,
1651
1658
'withPrivateMacro' ,
1652
1659
'withQuotedNamedAnimation' ,
1653
- 'withUndefinedMacro' ,
1654
- 'withAnimationOutOfOrder' ,
1655
- 'withAnimationUnknownArg' ,
1660
+ 'withUndefinedMacro'
1656
1661
]));
1657
1662
});
1658
1663
0 commit comments