test_pluralForm-english.js (892B)
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 uses the default language (for development), English. 9 */ 10 11 const { PluralForm } = require("resource://devtools/shared/plural-form.js"); 12 13 function run_test() { 14 // English has 2 plural forms 15 Assert.equal(2, PluralForm.numForms()); 16 17 // Make sure for good inputs, things work as expected 18 for (let num = 0; num <= 200; num++) { 19 Assert.equal( 20 num == 1 ? "word" : "words", 21 PluralForm.get(num, "word;words") 22 ); 23 } 24 25 // Not having enough plural forms defaults to the first form 26 Assert.equal("word", PluralForm.get(2, "word")); 27 28 // Empty forms defaults to the first form 29 Assert.equal("word", PluralForm.get(2, "word;")); 30 }