tor-browser

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

test_pluralForm-irish.js (1260B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 /**
      8 * This unit test makes sure the plural form for Irish Gaelic is working.
      9 */
     10 
     11 const { PluralForm } = require("resource://devtools/shared/plural-form.js");
     12 
     13 function run_test() {
     14  const origAvLocales = Services.locale.availableLocales;
     15  registerCleanupFunction(() => {
     16    Services.locale.availableLocales = origAvLocales;
     17  });
     18 
     19  Services.locale.availableLocales = ["ga-IE", "en-US"];
     20  Services.locale.requestedLocales = ["ga-IE"];
     21  PluralForm.init();
     22 
     23  // Irish has 5 plural forms
     24  Assert.equal(5, PluralForm.numForms());
     25 
     26  // I don't really know Irish, so I'll stick in some dummy text
     27  const words = "is 1;is 2;is 3-6;is 7-10;everything else";
     28 
     29  const test = function (text, low, high) {
     30    for (let num = low; num <= high; num++) {
     31      Assert.equal(text, PluralForm.get(num, words));
     32    }
     33  };
     34 
     35  // Make sure for good inputs, things work as expected
     36  test("everything else", 0, 0);
     37  test("is 1", 1, 1);
     38  test("is 2", 2, 2);
     39  test("is 3-6", 3, 6);
     40  test("is 7-10", 7, 10);
     41  test("everything else", 11, 200);
     42 }