@@ -127,6 +127,90 @@ describe('lib/rules/validate-jsdoc/check-param-names', function () {
127127 /* jshint ignore:end */
128128 ] ) ;
129129
130+ // out-of-order. issue #33
131+ checker . cases ( [
132+ /* jshint ignore:start */
133+ {
134+ it : 'should report out of order' ,
135+ code : function ( ) {
136+ /**
137+ * @param xxx
138+ * @param yyy
139+ */
140+ function funcName ( yyy , xxx ) {
141+ }
142+ } ,
143+ errors : [
144+ { message : 'parameters xxx and yyy are out of order' , column : 10 , line : 2 , rule : "jsDoc" }
145+ ]
146+ } , {
147+ it : 'should report out of order many times' ,
148+ code : function ( ) {
149+ Cls . prototype = {
150+ /**
151+ * @param xxx
152+ * @param yyy
153+ * @param zzz
154+ */
155+ run : function ( zzz , xxx , yyy ) {
156+ }
157+ } ;
158+ } ,
159+ errors : [
160+ { message : 'parameters xxx and zzz are out of order' , column : 14 , line : 3 , rule : "jsDoc" } ,
161+ { message : 'parameters yyy and xxx are out of order' , column : 14 , line : 4 , rule : "jsDoc" }
162+ ]
163+ } , {
164+ it : 'should report out of order and expected' ,
165+ code : function ( ) {
166+ Cls . prototype = {
167+ /**
168+ * @param xxx
169+ * @param yyy
170+ */
171+ run : function ( zzz , xxx ) {
172+ }
173+ } ;
174+ } ,
175+ errors : [
176+ { message : 'parameter xxx is out of order' , column : 14 , line : 3 , rule : "jsDoc" } ,
177+ { message : 'expected xxx but got yyy' , column : 14 , line : 4 , rule : "jsDoc" }
178+ ]
179+ } , {
180+ it : 'should report out of order and expected v2' ,
181+ code : function ( ) {
182+ Cls . prototype = {
183+ /**
184+ * @param xxx
185+ * @param yyy
186+ */
187+ run : function ( yyy , zzz ) {
188+ }
189+ } ;
190+ } ,
191+ errors : [
192+ { message : 'expected yyy but got xxx' , column : 14 , line : 3 , rule : "jsDoc" } ,
193+ { message : 'parameter yyy is out of order' , column : 14 , line : 4 , rule : "jsDoc" }
194+ ]
195+ } , {
196+ it : 'should not report out of order but expected' ,
197+ code : function ( ) {
198+ Cls . prototype = {
199+ /**
200+ * @param xxx
201+ * @param yyy
202+ */
203+ run : function ( zzz , yyy ) {
204+ }
205+ } ;
206+ } ,
207+ errors : [
208+ { message : 'expected zzz but got xxx' , column : 14 , line : 3 , rule : "jsDoc" }
209+ ]
210+ }
211+ /* jshint ignore:end */
212+ ] ) ;
213+
130214 } ) ;
131215
132216} ) ;
0 commit comments