r90637 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90636‎ | r90637 | r90638 >
Date:00:37, 23 June 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
Followup r86088: test cases and a correction for bug 17141 (IPv4 address sorting)

Test lists 8 randomly generated IPv4 addresses and attempts to sort them both forward and back.
Turned up a bug where single-digit octets (eg a .1 or .9) were not expanded in the sort key, causing them to mis-sort.
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.tablesorter.js (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
@@ -212,4 +212,47 @@
213213 }
214214 );
215215
 216+var ipv4 = [
 217+ // Some randomly generated fake IPs
 218+ ['45.238.27.109'],
 219+ ['44.172.9.22'],
 220+ ['247.240.82.209'],
 221+ ['204.204.132.158'],
 222+ ['170.38.91.162'],
 223+ ['197.219.164.9'],
 224+ ['45.68.154.72'],
 225+ ['182.195.149.80']
 226+];
 227+var ipv4Sorted = [
 228+ // Sort order should go octet by octet
 229+ ['44.172.9.22'],
 230+ ['45.68.154.72'],
 231+ ['45.238.27.109'],
 232+ ['170.38.91.162'],
 233+ ['182.195.149.80'],
 234+ ['197.219.164.9'],
 235+ ['204.204.132.158'],
 236+ ['247.240.82.209']
 237+];
 238+tableTest(
 239+ 'Bug 17141: IPv4 address sorting',
 240+ ['IP'],
 241+ ipv4,
 242+ ipv4Sorted,
 243+ function( $table ) {
 244+ $table.tablesorter();
 245+ $table.find('.headerSort:eq(0)').click();
 246+ }
 247+);
 248+tableTest(
 249+ 'Bug 17141: IPv4 address sorting (reverse)',
 250+ ['IP'],
 251+ ipv4,
 252+ reversed(ipv4Sorted),
 253+ function( $table ) {
 254+ $table.tablesorter();
 255+ $table.find('.headerSort:eq(0)').click().click();
 256+ }
 257+);
 258+
216259 })();
Index: trunk/phase3/resources/jquery/jquery.tablesorter.js
@@ -726,7 +726,9 @@
727727 l = a.length;
728728 for ( var i = 0; i < l; i++ ) {
729729 var item = a[i];
730 - if ( item.length == 2 ) {
 730+ if ( item.length == 1 ) {
 731+ r += "00" + item;
 732+ } else if ( item.length == 2 ) {
731733 r += "0" + item;
732734 } else {
733735 r += item;

Follow-up revisions

RevisionCommit summaryAuthorDate
r91782MFT to REL_1_18: jquery tablesorter...hashar08:54, 9 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86088Completely rewritten table sorting script....diebuche21:47, 14 April 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   00:37, 23 June 2011

Bug fix needs merge to 1.18 branch.

Status & tagging log