r94636 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94635‎ | r94636 | r94637 >
Date:13:33, 16 August 2011
Author:catrope
Status:ok
Tags:
Comment:
Followup r89853, tweaks for jquery.qunit.completenessTest:
* Don't assume $ as a global, but alias it to jQuery instead. The code is already wrapped in a closure so this is easy
* Remove unused constants TYPE_SIMPLEFUNC and TYPE_OBJCONSTRFUNC
* Fix spelling in comments, mostly brake->break
* Fix whitespace
* Kill useless return at the end of a void function
* Correct comment in hasTests() which claims the function does the opposite of what it really does
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.qunit.completenessTest.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.qunit.completenessTest.js
@@ -5,7 +5,7 @@
66 * libraries. Written to be used in enviroments with jQuery and QUnit.
77 * Requires jQuery 1.5.2 or higher.
88 *
9 - * Globals: jQuery, $, QUnit, console.log
 9+ * Globals: jQuery, QUnit, console.log
1010 *
1111 * Built for and tested with:
1212 * - Safari 5
@@ -13,12 +13,8 @@
1414 *
1515 * @author Timo Tijhof, 2011
1616 */
17 -(function(){
 17+( function( $ ) {
1818
19 -/* Private members */
20 -var TYPE_SIMPLEFUNC = 101;
21 -var TYPE_OBJCONSTRFUNC = 100;
22 -
2319 /**
2420 * CompletenessTest
2521 * @constructor
@@ -159,7 +155,7 @@
160156 $.each( currVar.prototype, function( key, value ) {
161157 if ( key === 'constructor' ) return;
162158
163 - // Clone and brake reference to parentPathArray
 159+ // Clone and break reference to parentPathArray
164160 var tmpPathArray = $.extend( [], parentPathArray );
165161 tmpPathArray.push( 'prototype' ); tmpPathArray.push( key );
166162
@@ -174,12 +170,10 @@
175171 if ( !currVar.prototype || $.isEmptyObject( currVar.prototype ) ) {
176172
177173 // Inject check
178 - that.injectCheck( masterVariable, parentPathArray, function(){
179 -
 174+ that.injectCheck( masterVariable, parentPathArray, function() {
180175 that.methodCallTracker[ parentPathArray.join( '.' ) ] = true;
 176+ } );
181177
182 - }, TYPE_SIMPLEFUNC );
183 -
184178 // We don't support checking object constructors yet...
185179 } else {
186180
@@ -187,7 +181,7 @@
188182 $.each( currVar.prototype, function( key, value ) {
189183 if ( key === 'constructor' ) return;
190184
191 - // Clone and brake reference to parentPathArray
 185+ // Clone and break reference to parentPathArray
192186 var tmpPathArray = $.extend( [], parentPathArray );
193187 tmpPathArray.push( 'prototype' ); tmpPathArray.push( key );
194188
@@ -197,12 +191,12 @@
198192
199193 }
200194
201 - // Recursively. After all, this *is* the completness test
 195+ // Recursively. After all, this *is* the completeness test
202196 } else if ( type === 'object' ) {
203197
204198 $.each( currVar, function( key, value ) {
205199
206 - // Clone and brake reference to parentPathArray
 200+ // Clone and break reference to parentPathArray
207201 var tmpPathArray = $.extend( [], parentPathArray );
208202 tmpPathArray.push( key );
209203
@@ -211,8 +205,6 @@
212206 } );
213207
214208 }
215 -
216 - return 'End of checkTests';
217209 },
218210
219211 /**
@@ -220,13 +212,13 @@
221213 *
222214 * Checks if the given method name (ie. 'my.foo.bar')
223215 * was called during the test suite (as far as the tracker knows).
224 - * If so it adds it to missingTests.
 216+ * If not it adds it to missingTests.
225217 *
226218 * @param fnName {String}
227219 * @return {Boolean}
228220 */
229221 hasTest: function( fnName ) {
230 - if ( !(fnName in this.methodCallTracker) ) {
 222+ if ( !( fnName in this.methodCallTracker ) ) {
231223 this.missingTests[fnName] = true;
232224 return false;
233225 }
@@ -248,14 +240,14 @@
249241 curr = masterVariable,
250242 lastMember;
251243
252 - $.each( objectPathArray, function(i, memberName){
 244+ $.each( objectPathArray, function( i, memberName ) {
253245 prev = curr;
254246 curr = prev[memberName];
255247 lastMember = memberName;
256248 });
257249
258250 // Objects are by reference, members (unless objects) are not.
259 - prev[lastMember] = function(){
 251+ prev[lastMember] = function() {
260252 injectFn();
261253 return curr.apply( this, arguments );
262254 };
@@ -264,4 +256,4 @@
265257
266258 window.CompletenessTest = CompletenessTest;
267259
268 -})();
 260+} )( jQuery );

Sign-offs

UserFlagDate
Nikerabbitinspected20:49, 16 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89853Added jquery.qunit.completenessTest.js (A jQuery/QUnit test coverage utility)...krinkle22:15, 10 June 2011

Status & tagging log