r81151 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81150‎ | r81151 | r81152 >
Date:19:25, 28 January 2011
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
Some adjustments to new functionality from r81133
* Floating result to the right (looked a little messy)
* In Safari the 0.8em looked really pixelated and unreadably. Font-size back to normal size.
* Converted variable names to camelCase
* Fixed bug from r81133 (first array item is 0, first counter is 1). Added a +1 to fix it for now (since the headings were overwritten and the first one was removed). Perhaps should be done better at a later time.
Modified paths:
  • /trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.test.js
@@ -83,13 +83,13 @@
8484 '<p>Below is a list of tests to confirm proper functionality of the mediaWiki JavaScript library</p>'
8585 + '<p>' + skinLinksText + '</p>'
8686 + '<hr />'
87 - + '<table id="mw-mwutiltest-table" class="wikitable sortable" style="white-space:break; font-family:monospace,\'Courier New\';font-size:0.8em; width:100%;">'
 87+ + '<table id="mw-mwutiltest-table" class="wikitable sortable" style="white-space:break; font-family:monospace,\'Courier New\'; width:100%;">'
8888 + '<tr><th>Exec</th><th>Should return</th><th>Does return</th><th>Equal ?</th></tr>'
8989 + '</table>'
9090 );
9191
9292 // Override wikitable padding for <td>
93 - $('head').append('<style>#mw-mwutiltest-table tr td {padding:0 !important;}</style>');
 93+ mw.util.addCSS( '#mw-mwutiltest-table tr td { padding:0 !important; }' );
9494
9595 mw.test.$table = $( 'table#mw-mwutiltest-table' );
9696
@@ -319,73 +319,75 @@
320320 var exec,
321321 result,
322322 resulttype,
323 - numberoftests = 0,
324 - numberofpasseds = 0,
325 - numberofpartials = 0,
326 - numberoferrors = 0,
327 - headnumberoftests = 0,
328 - headnumberofpasseds = 0,
329 - headnumberofpartials = 0,
330 - headnumberoferrors = 0,
331 - numberofheaders = 0,
 323+ numberOfTests = 0,
 324+ numberOfPasseds = 0,
 325+ numberOfPartials = 0,
 326+ numberOfErrors = 0,
 327+ headNumberOfTests = 0,
 328+ headNumberOfPasseds = 0,
 329+ headNumberOfPartials = 0,
 330+ headNumberOfErrors = 0,
 331+ numberOfHeaders = 0,
 332+ previousHeadTitle = '',
332333 $testrows = mw.test.$table.find( 'tr:has(td)' );
333334
334 - $.each( mw.test.addedTests, function( i ) {
 335+ $.each( mw.test.addedTests, function( i, item ) {
335336
336337 // New header
337 - if( mw.test.addedTests[i][0] == 'HEADER' ) {
338 - headertitle = mw.test.addedTests[i][1];
 338+ if( item[0] == 'HEADER' ) {
339339
340340 // update current header with its tests results
341 - mw.test.$table.find( 'tr#mw-mwutiltest-head'+numberofheaders+' > th' )
342 - .text( headertitle + ' ('
343 - + 'T: ' + headnumberoftests
344 - + ' ok: ' + headnumberofpasseds
345 - + ' partial: ' + headnumberofpartials
346 - + ' err: ' + headnumberoferrors
347 - + ')' );
 341+ mw.test.$table.find( 'tr#mw-mwutiltest-head' + ( numberOfHeaders ) +' > th' )
 342+ .html( previousHeadTitle + ' <span style="float:right">('
 343+ + 'T: ' + headNumberOfTests
 344+ + ' ok: ' + headNumberOfPasseds
 345+ + ' partial: ' + headNumberOfPartials
 346+ + ' err: ' + headNumberOfErrors
 347+ + ')</span>' );
348348
349 - numberofheaders++;
 349+ numberOfHeaders++;
350350 // Reset values for the new header;
351 - headnumberoftests = 0;
352 - headnumberofpasseds = 0;
353 - headnumberofpartials = 0;
354 - headnumberoferrors = 0;
 351+ headNumberOfTests = 0;
 352+ headNumberOfPasseds = 0;
 353+ headNumberOfPartials = 0;
 354+ headNumberOfErrors = 0;
355355
 356+ previousHeadTitle = mw.test.addedTests[i][1];
 357+
356358 return true;
357359 }
358360
359 - exec = mw.test.addedTests[i][0];
360 - shouldreturn = mw.test.addedTests[i][1];
361 - shouldcontain = mw.test.addedTests[i][2];
 361+ exec = item[0];
 362+ shouldreturn = item[1];
 363+ shouldcontain = item[2];
362364
363 - numberoftests++;
364 - headnumberoftests++;
365 - doesreturn = eval( exec );
366 - doesreturn = doesreturn + ' (' + typeof doesreturn + ')';
367 - $thisrow = $testrows.eq( i - numberofheaders ); // since headers are rows as well
368 - $thisrow.find( '> td' ).eq(2).html( mw.html.escape( doesreturn ).replace(/ /g, '&nbsp;&nbsp;' ) );
 365+ numberOfTests++;
 366+ headNumberOfTests++;
 367+ doesReturn = eval( exec );
 368+ doesReturn = doesReturn + ' (' + typeof doesReturn + ')';
 369+ $thisrow = $testrows.eq( i - numberOfHeaders ); // since headers are rows as well
 370+ $thisrow.find( '> td' ).eq(2).html( mw.html.escape( doesReturn ).replace(/ /g, '&nbsp;&nbsp;' ) );
369371
370 - if ( doesreturn.indexOf( shouldcontain ) !== -1 ) {
371 - if ( doesreturn == shouldreturn ) {
 372+ if ( doesReturn.indexOf( shouldcontain ) !== -1 ) {
 373+ if ( doesReturn == shouldreturn ) {
372374 $thisrow.find( '> td' ).eq(3).css( 'background', '#AFA' ).text( 'OK' );
373 - numberofpasseds++;
374 - headnumberofpasseds++;
 375+ numberOfPasseds++;
 376+ headNumberOfPasseds++;
375377 } else {
376378 $thisrow.find( '> td' ).eq(3).css( 'background', '#FFA' ).html( '<small>PARTIALLY</small>' );
377 - numberofpartials++;
378 - headnumberofpartials++;
 379+ numberOfPartials++;
 380+ headNumberOfPartials++;
379381 }
380382 } else {
381383 $thisrow.find( '> td' ).eq(3).css( 'background', '#FAA' ).text( 'ERROR' );
382 - numberoferrors++;
383 - headnumberoferrors++;
 384+ numberOfErrors++;
 385+ headNumberOfErrors++;
384386 }
385387
386388 } );
387 - mw.test.$table.before( '<p><strong>Ran ' + numberoftests + ' tests. ' +
388 - numberofpasseds + ' passed test(s). ' + numberoferrors + ' error(s). ' +
389 - numberofpartials + ' partially passed test(s). </p>' );
 389+ mw.test.$table.before( '<p><strong>Ran ' + numberOfTests + ' tests. ' +
 390+ numberOfPasseds + ' passed test(s). ' + numberOfErrors + ' error(s). ' +
 391+ numberOfPartials + ' partially passed test(s). </p>' );
390392
391393 // hide all tests. TODO hide only OK?
392394 mw.test.$table.find( '.mw-mwutiltest-test' ).hide();

Follow-up revisions

RevisionCommit summaryAuthorDate
r81154* Adding cursor:pointer when hovering the headers (which hide/show stuff)...krinkle19:38, 28 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81133Minor cleanup, docsdemon15:00, 28 January 2011

Comments

#Comment by Krinkle (talk | contribs)   19:28, 28 January 2011

Sorry, I meant to refer to r81146. Not r81151.

#Comment by Krinkle (talk | contribs)   19:30, 28 January 2011

Okay for some reason someting went wrong. i got the rev numbers totally mixed up.


This is a follow-up to r81126.

#Comment by Hashar (talk | contribs)   17:28, 4 February 2011

Thanks Krinkle! (ok)

Status & tagging log