1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/locale/tests/unit/test_pluralForm_makeGetter.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +/** 1.9 + * This unit test makes sure the plural form for Irish Gaeilge is working by 1.10 + * using the makeGetter method instead of using the default language (by 1.11 + * development), English. 1.12 + */ 1.13 + 1.14 +Components.utils.import("resource://gre/modules/PluralForm.jsm"); 1.15 + 1.16 +function run_test() 1.17 +{ 1.18 + // Irish is plural rule #11 1.19 + let [get, numForms] = PluralForm.makeGetter(11); 1.20 + 1.21 + // Irish has 5 plural forms 1.22 + do_check_eq(5, numForms()); 1.23 + 1.24 + // I don't really know Irish, so I'll stick in some dummy text 1.25 + let words = "is 1;is 2;is 3-6;is 7-10;everything else"; 1.26 + 1.27 + let test = function(text, low, high) { 1.28 + for (let num = low; num <= high; num++) 1.29 + do_check_eq(text, get(num, words)); 1.30 + }; 1.31 + 1.32 + // Make sure for good inputs, things work as expected 1.33 + test("everything else", 0, 0); 1.34 + test("is 1", 1, 1); 1.35 + test("is 2", 2, 2); 1.36 + test("is 3-6", 3, 6); 1.37 + test("is 7-10", 7, 10); 1.38 + test("everything else", 11, 200); 1.39 +}