Bug 1133289 - Remove nonstandard expression closures from intl/locale. r=smontagu
authorChris Peterson <cpeterson@mozilla.com>
Sat, 24 Jan 2015 23:53:08 -0800
changeset 229262 89e49bd65079d220cb177b6b7db2dfb77a4f1bd3
parent 229261 0741e9b56498a8f35fbddcddca616efad986ce9c
child 229263 93fa6e70174a74a5cfb597df486f36234b7667ac
push id28282
push usercbook@mozilla.com
push dateMon, 16 Feb 2015 15:06:35 +0000
treeherdermozilla-central@09f4968d5f42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs1133289
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1133289 - Remove nonstandard expression closures from intl/locale. r=smontagu
intl/locale/PluralForm.jsm
intl/locale/tests/unit/test_bug22310.js
--- a/intl/locale/PluralForm.jsm
+++ b/intl/locale/PluralForm.jsm
@@ -32,49 +32,49 @@ const Ci = Components.interfaces;
 
 const kIntlProperties = "chrome://global/locale/intl.properties";
 
 // These are the available plural functions that give the appropriate index
 // based on the plural rule number specified. The first element is the number
 // of plural forms and the second is the function to figure out the index.
 let gFunctions = [
   // 0: Chinese
-  [1, function(n) 0],
+  [1, (n) => 0],
   // 1: English
-  [2, function(n) n!=1?1:0],
+  [2, (n) => n!=1?1:0],
   // 2: French
-  [2, function(n) n>1?1:0],
+  [2, (n) => n>1?1:0],
   // 3: Latvian
-  [3, function(n) n%10==1&&n%100!=11?1:n!=0?2:0],
+  [3, (n) => n%10==1&&n%100!=11?1:n!=0?2:0],
   // 4: Scottish Gaelic
-  [4, function(n) n==1||n==11?0:n==2||n==12?1:n>0&&n<20?2:3],
+  [4, (n) => n==1||n==11?0:n==2||n==12?1:n>0&&n<20?2:3],
   // 5: Romanian
-  [3, function(n) n==1?0:n==0||n%100>0&&n%100<20?1:2],
+  [3, (n) => n==1?0:n==0||n%100>0&&n%100<20?1:2],
   // 6: Lithuanian
-  [3, function(n) n%10==1&&n%100!=11?0:n%10>=2&&(n%100<10||n%100>=20)?2:1],
+  [3, (n) => n%10==1&&n%100!=11?0:n%10>=2&&(n%100<10||n%100>=20)?2:1],
   // 7: Russian
-  [3, function(n) n%10==1&&n%100!=11?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2],
+  [3, (n) => n%10==1&&n%100!=11?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2],
   // 8: Slovak
-  [3, function(n) n==1?0:n>=2&&n<=4?1:2],
+  [3, (n) => n==1?0:n>=2&&n<=4?1:2],
   // 9: Polish
-  [3, function(n) n==1?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2],
+  [3, (n) => n==1?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2],
   // 10: Slovenian
-  [4, function(n) n%100==1?0:n%100==2?1:n%100==3||n%100==4?2:3],
+  [4, (n) => n%100==1?0:n%100==2?1:n%100==3||n%100==4?2:3],
   // 11: Irish Gaeilge
-  [5, function(n) n==1?0:n==2?1:n>=3&&n<=6?2:n>=7&&n<=10?3:4],
+  [5, (n) => n==1?0:n==2?1:n>=3&&n<=6?2:n>=7&&n<=10?3:4],
   // 12: Arabic
-  [6, function(n) n==0?5:n==1?0:n==2?1:n%100>=3&&n%100<=10?2:n%100>=11&&n%100<=99?3:4],
+  [6, (n) => n==0?5:n==1?0:n==2?1:n%100>=3&&n%100<=10?2:n%100>=11&&n%100<=99?3:4],
   // 13: Maltese
-  [4, function(n) n==1?0:n==0||n%100>0&&n%100<=10?1:n%100>10&&n%100<20?2:3],
+  [4, (n) => n==1?0:n==0||n%100>0&&n%100<=10?1:n%100>10&&n%100<20?2:3],
   // 14: Macedonian
-  [3, function(n) n%10==1?0:n%10==2?1:2],
+  [3, (n) => n%10==1?0:n%10==2?1:2],
   // 15: Icelandic
-  [2, function(n) n%10==1&&n%100!=11?0:1],
+  [2, (n) => n%10==1&&n%100!=11?0:1],
   // 16: Breton
-  [5, function(n) n%10==1&&n%100!=11&&n%100!=71&&n%100!=91?0:n%10==2&&n%100!=12&&n%100!=72&&n%100!=92?1:(n%10==3||n%10==4||n%10==9)&&n%100!=13&&n%100!=14&&n%100!=19&&n%100!=73&&n%100!=74&&n%100!=79&&n%100!=93&&n%100!=94&&n%100!=99?2:n%1000000==0&&n!=0?3:4],
+  [5, (n) => n%10==1&&n%100!=11&&n%100!=71&&n%100!=91?0:n%10==2&&n%100!=12&&n%100!=72&&n%100!=92?1:(n%10==3||n%10==4||n%10==9)&&n%100!=13&&n%100!=14&&n%100!=19&&n%100!=73&&n%100!=74&&n%100!=79&&n%100!=93&&n%100!=94&&n%100!=99?2:n%1000000==0&&n!=0?3:4],
 ];
 
 this.PluralForm = {
   /**
    * Get the correct plural form of a word based on the number
    *
    * @param aNum
    *        The number to decide which plural form to use
@@ -141,17 +141,17 @@ this.PluralForm = {
         log(["Index #", index, " of '", aWords, "' for value ", aNum,
             " is invalid -- plural rule #", aRuleNum, "; called by ", caller]);
 
         // Default to the first entry (which might be empty, but not undefined)
         ret = words[0];
       }
 
       return ret;
-    }, function() numForms];
+    }, () => numForms];
   },
 
   /**
    * Get the number of forms for the current plural rule
    *
    * @return The number of forms
    */
   get numForms()
--- a/intl/locale/tests/unit/test_bug22310.js
+++ b/intl/locale/tests/unit/test_bug22310.js
@@ -1,16 +1,21 @@
-String.prototype.has = function(s) this.indexOf(s) != -1;
+String.prototype.has = function(s) { return this.indexOf(s) != -1; }
+
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 const dts = Cc["@mozilla.org/intl/scriptabledateformat;1"]
         .getService(Ci.nsIScriptableDateFormat);
-function dt(locale) dts.FormatDateTime(locale, dts.dateFormatLong,
-  dts.timeFormatSeconds, 2008, 6, 30, 13, 56, 34);
+
+function dt(locale) {
+  return dts.FormatDateTime(locale, dts.dateFormatLong,
+                            dts.timeFormatSeconds, 2008, 6, 30, 13, 56, 34);
+}
+
 var all_passed = true;
 const tests = 
 [
  [dt("en-US").has("June"), "month name in en-US"],
  [dt("en-US").has("2008"), "year in en-US"],
  [dt("da").has("jun"), "month name in da"],
  [dt("da-DK") == dt("da"), "da same as da-DK"],
  [dt("en-GB").has("30") && dt("en-GB").has("June") &&