tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

can-be-subclassed.js (948B)


      1 // Copyright 2016 Mozilla Corporation. All rights reserved.
      2 // This code is governed by the license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-intl-pluralrules-constructor
      6 description: Tests that Intl.PluralRules can be subclassed.
      7 author: Zibi Braniecki
      8 includes: [compareArray.js]
      9 ---*/
     10 
     11 // get a plural-rules and have it format an array of dates for comparison with the subclass
     12 var locales = ["tlh", "id", "en"];
     13 var a = [1, 5, 12];
     14 
     15 var referencePluralRules = new Intl.PluralRules(locales);
     16 var referenceSelected = a.map(referencePluralRules.select.bind(referencePluralRules));
     17 
     18 class MyPluralRules extends Intl.PluralRules {
     19  constructor(locales, options) {
     20    super(locales, options);
     21    // could initialize MyPluralRules properties
     22  }
     23  // could add methods to MyPluralRules.prototype
     24 }
     25 
     26 var pr = new MyPluralRules(locales);
     27 var actual = a.map(pr.select.bind(pr));
     28 assert.compareArray(actual, referenceSelected);
     29 
     30 reportCompare(0, 0);