Bug 671533 - Fix test_DownloadUtils.js with locales with a different decimal separator. r=edilee
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Jul 2011 10:15:28 +0200
changeset 72863 b5c5e025368d2159cc46acd8140d37ccba2ced9c
parent 72862 49b5a71802b4d17a5c4989cd884d7ea47b3b4ddf
child 72864 9349ae9094f6d3e725e70a8020a1f017b9ceb1c8
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersedilee
bugs671533
milestone8.0a1
Bug 671533 - Fix test_DownloadUtils.js with locales with a different decimal separator. r=edilee
toolkit/mozapps/downloads/tests/unit/test_DownloadUtils.js
--- a/toolkit/mozapps/downloads/tests/unit/test_DownloadUtils.js
+++ b/toolkit/mozapps/downloads/tests/unit/test_DownloadUtils.js
@@ -34,17 +34,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 let Cu = Components.utils;
 Cu.import("resource://gre/modules/DownloadUtils.jsm");
 
 const gDecimalSymbol = Number(5.4).toLocaleString().match(/\D/);
 function _(str) {
-  return str.replace(".", gDecimalSymbol);
+  return str.replace(".", gDecimalSymbol, "g");
 }
 
 function testConvertByteUnits(aBytes, aValue, aUnit)
 {
   let [value, unit] = DownloadUtils.convertByteUnits(aBytes);
   do_check_eq(value, aValue);
   do_check_eq(unit, aUnit);
 }
@@ -71,17 +71,17 @@ function testStatus(aCurr, aMore, aRate,
     DownloadUtils.getDownloadStatus(curr, max, speed);
 
   if (0) {
     dump("testStatus(" + aCurr + ", " + aMore + ", " + aRate + ", [\"" +
       status.replace(gDash, "--") + "\", " + last.toFixed(3) + "]);\n");
   }
 
   // Make sure the status text matches
-  do_check_eq(status, aTest[0].replace(/--/, gDash));
+  do_check_eq(status, _(aTest[0].replace(/--/, gDash)));
 
   // Make sure the lastSeconds matches
   if (last == Infinity)
     do_check_eq(last, aTest[1]);
   else
     do_check_true(Math.abs(last - aTest[1]) < .1);
 }
 
@@ -108,16 +108,17 @@ function run_test()
   testConvertByteUnits(640000, _("625"), "KB");
   testConvertByteUnits(1048576, _("1.0"), "MB");
   testConvertByteUnits(307232768, _("293"), "MB");
   testConvertByteUnits(1073741824, _("1.0"), "GB");
 
   testTransferTotal(1, 1, _("1 of 1 bytes"));
   testTransferTotal(234, 4924, _("234 bytes of 4.8 KB"));
   testTransferTotal(94923, 233923, _("92.7 of 228 KB"));
+  testTransferTotal(4924, 94923, _("4.8 of 92.7 KB"));
   testTransferTotal(2342, 294960345, _("2.3 KB of 281 MB"));
   testTransferTotal(234, undefined, _("234 bytes"));
   testTransferTotal(4889023, undefined, _("4.7 MB"));
 
   if (0) {
     // Help find some interesting test cases
     let r = function() Math.floor(Math.random() * 10);
     for (let i = 0; i < 100; i++) {