http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94636
Revision: 94636 Author: catrope Date: 2011-08-16 13:33:22 +0000 (Tue, 16 Aug 2011) Log Message: ----------- 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: trunk/phase3/resources/jquery/jquery.qunit.completenessTest.js =================================================================== --- trunk/phase3/resources/jquery/jquery.qunit.completenessTest.js 2011-08-16 13:28:29 UTC (rev 94635) +++ trunk/phase3/resources/jquery/jquery.qunit.completenessTest.js 2011-08-16 13:33:22 UTC (rev 94636) @@ -5,7 +5,7 @@ * libraries. Written to be used in enviroments with jQuery and QUnit. * Requires jQuery 1.5.2 or higher. * - * Globals: jQuery, $, QUnit, console.log + * Globals: jQuery, QUnit, console.log * * Built for and tested with: * - Safari 5 @@ -13,12 +13,8 @@ * * @author Timo Tijhof, 2011 */ -(function(){ +( function( $ ) { -/* Private members */ -var TYPE_SIMPLEFUNC = 101; -var TYPE_OBJCONSTRFUNC = 100; - /** * CompletenessTest * @constructor @@ -159,7 +155,7 @@ $.each( currVar.prototype, function( key, value ) { if ( key === 'constructor' ) return; - // Clone and brake reference to parentPathArray + // Clone and break reference to parentPathArray var tmpPathArray = $.extend( [], parentPathArray ); tmpPathArray.push( 'prototype' ); tmpPathArray.push( key ); @@ -174,12 +170,10 @@ if ( !currVar.prototype || $.isEmptyObject( currVar.prototype ) ) { // Inject check - that.injectCheck( masterVariable, parentPathArray, function(){ - + that.injectCheck( masterVariable, parentPathArray, function() { that.methodCallTracker[ parentPathArray.join( '.' ) ] = true; + } ); - }, TYPE_SIMPLEFUNC ); - // We don't support checking object constructors yet... } else { @@ -187,7 +181,7 @@ $.each( currVar.prototype, function( key, value ) { if ( key === 'constructor' ) return; - // Clone and brake reference to parentPathArray + // Clone and break reference to parentPathArray var tmpPathArray = $.extend( [], parentPathArray ); tmpPathArray.push( 'prototype' ); tmpPathArray.push( key ); @@ -197,12 +191,12 @@ } - // Recursively. After all, this *is* the completness test + // Recursively. After all, this *is* the completeness test } else if ( type === 'object' ) { $.each( currVar, function( key, value ) { - // Clone and brake reference to parentPathArray + // Clone and break reference to parentPathArray var tmpPathArray = $.extend( [], parentPathArray ); tmpPathArray.push( key ); @@ -211,8 +205,6 @@ } ); } - - return 'End of checkTests'; }, /** @@ -220,13 +212,13 @@ * * Checks if the given method name (ie. 'my.foo.bar') * was called during the test suite (as far as the tracker knows). - * If so it adds it to missingTests. + * If not it adds it to missingTests. * * @param fnName {String} * @return {Boolean} */ hasTest: function( fnName ) { - if ( !(fnName in this.methodCallTracker) ) { + if ( !( fnName in this.methodCallTracker ) ) { this.missingTests[fnName] = true; return false; } @@ -248,14 +240,14 @@ curr = masterVariable, lastMember; - $.each( objectPathArray, function(i, memberName){ + $.each( objectPathArray, function( i, memberName ) { prev = curr; curr = prev[memberName]; lastMember = memberName; }); // Objects are by reference, members (unless objects) are not. - prev[lastMember] = function(){ + prev[lastMember] = function() { injectFn(); return curr.apply( this, arguments ); }; @@ -264,4 +256,4 @@ window.CompletenessTest = CompletenessTest; -})(); +} )( jQuery ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs