diff --git a/js/test/date/testDayOfWeek.js b/js/test/date/testDayOfWeek.js index 55abc95c29..75f33e8212 100644 --- a/js/test/date/testDayOfWeek.js +++ b/js/test/date/testDayOfWeek.js @@ -1969,6 +1969,16 @@ module.exports.testweekdata = { test.equal(info.getWeekEndEnd(), 0); test.done(); }, + testWeekData_be_BY: function(test) { + test.expect(4); + var info = new LocaleInfo("be-BY"); + test.ok(info !== null); + + test.equal(info.getFirstDayOfWeek(), 1); + test.equal(info.getWeekEndStart(), 6); + test.equal(info.getWeekEndEnd(), 0); + test.done(); + }, testWeekData_lo_LA: function(test) { test.expect(4); var info = new LocaleInfo("lo-LA"); diff --git a/js/test/date/testMeridiems.js b/js/test/date/testMeridiems.js index 3329d86275..3b0119e044 100644 --- a/js/test/date/testMeridiems.js +++ b/js/test/date/testMeridiems.js @@ -1974,6 +1974,15 @@ module.exports.testmeridiems = { test.done(); }, + testMeridiem_be_BY: function(test) { + test.expect(3); + var fmt = DateFmt.getMeridiemsRange({locale:"be-BY"}); + test.ok(fmt !== null); + + test.equal(fmt[0].name, "AM"); + test.equal(fmt[1].name, "PM"); + test.done(); + }, testMeridiem_lo_LA: function(test) { test.expect(3); var fmt = DateFmt.getMeridiemsRange({locale:"lo-LA"}); diff --git a/js/test/date/testMonthTranslation.js b/js/test/date/testMonthTranslation.js index 47dc6d2fa2..144a986503 100644 --- a/js/test/date/testMonthTranslation.js +++ b/js/test/date/testMonthTranslation.js @@ -7317,6 +7317,31 @@ module.exports.testmonthtranslation = { test.done(); }, + testMonthTranslate_be_BY: function(test) { + test.expect(12); + + // full, long: MMMM + // short, medium: MM + + var value = [], i; + var fmt = new DateFmt({locale:"be-BY", date:"m", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 12; i++) { + value[i] = fmt.format(DateFactory({month:i+1, type:"gregorian"})); + } + test.equal(value[0], "студзень"); + test.equal(value[1], "люты"); + test.equal(value[2], "сакавік"); + test.equal(value[3], "красавік"); + test.equal(value[4], "май"); + test.equal(value[5], "чэрвень"); + test.equal(value[6], "ліпень"); + test.equal(value[7], "жнівень"); + test.equal(value[8], "верасень"); + test.equal(value[9], "кастрычнік"); + test.equal(value[10], "лістапад"); + test.equal(value[11], "снежань"); + test.done(); + }, testMonthTranslate_lo_LA: function(test) { test.expect(24); diff --git a/js/test/date/testSuite.html b/js/test/date/testSuite.html index 69584848b6..7ce652766d 100644 --- a/js/test/date/testSuite.html +++ b/js/test/date/testSuite.html @@ -48,6 +48,7 @@ + diff --git a/js/test/date/testSuiteFiles.js b/js/test/date/testSuiteFiles.js index adbfc093ae..bbba5893c1 100644 --- a/js/test/date/testSuiteFiles.js +++ b/js/test/date/testSuiteFiles.js @@ -36,6 +36,7 @@ module.exports.files = [ "testdatefmt_ar_SA.js", "testdatefmt_as_IN.js", "testdatefmt_az_Latn_AZ.js", + "testdatefmt_be_BY.js", "testdatefmt_bg.js", "testdatefmt_bn_IN.js", "testdatefmt_bs_Cyrl_BA.js", diff --git a/js/test/date/testWeekdayTranslation.js b/js/test/date/testWeekdayTranslation.js index a3854bc6d3..005876b15b 100644 --- a/js/test/date/testWeekdayTranslation.js +++ b/js/test/date/testWeekdayTranslation.js @@ -11223,6 +11223,76 @@ module.exports.testWeekdayTranslation = { test.done(); }, + testWeekdayTranslationFull_be_BY: function(test) { + // full -> wide + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"be-BY", date:"w", length: "full", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "нядзеля"); + test.equal(value[1], "панядзелак"); + test.equal(value[2], "аўторак"); + test.equal(value[3], "серада"); + test.equal(value[4], "чацвер"); + test.equal(value[5], "пятніца"); + test.equal(value[6], "субота"); + test.done(); + }, + testWeekdayTranslationLong_be_BY: function(test) { + // long -> abbreviate + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"be-BY", date:"w", length: "long", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "нд"); + test.equal(value[1], "пн"); + test.equal(value[2], "аў"); + test.equal(value[3], "ср"); + test.equal(value[4], "чц"); + test.equal(value[5], "пт"); + test.equal(value[6], "сб"); + + test.done(); + }, + testWeekdayTranslationMedium_be_BY: function(test) { + // medium -> short + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"be-BY", date:"w", length: "medium", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "нд"); + test.equal(value[1], "пн"); + test.equal(value[2], "аў"); + test.equal(value[3], "ср"); + test.equal(value[4], "чц"); + test.equal(value[5], "пт"); + test.equal(value[6], "сб"); + + test.done(); + }, + testWeekdayTranslationShort_be_BY: function(test) { + // short: narrow + test.expect(7); + var fmt, value = [], i; + fmt = new DateFmt({locale:"be-BY", date:"w", length: "short", useNative:false, timezone:"local"}) + for (i=0; i < 7; i++) { + value[i] = fmt.format(DateFactory({year: 2015, month: 8, day:i+2, type:"gregorian"})); + } + test.equal(value[0], "н"); + test.equal(value[1], "п"); + test.equal(value[2], "а"); + test.equal(value[3], "с"); + test.equal(value[4], "ч"); + test.equal(value[5], "п"); + test.equal(value[6], "с"); + test.done(); + }, testWeekdayTranslationFull_lo_LA: function(test) { // full -> wide test.expect(7); diff --git a/js/test/date/testcalendar.js b/js/test/date/testcalendar.js index 9abf9d16e5..c7c3bc69a3 100644 --- a/js/test/date/testcalendar.js +++ b/js/test/date/testcalendar.js @@ -23,10 +23,10 @@ if (typeof(LocaleInfo) === "undefined") { module.exports.testcalendar = { testDefaultCalendar_GregorianCaseAll: function(test) { - test.expect(201); + test.expect(202); var localeList = ["ar-AE","ar-BH","ar-DJ","ar-DZ","ar-EG","ar-IQ","ar-JO","ar-KW","ar-LB","ar-LY","ar-MA","ar-MR", - "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", + "ar-OM","ar-QA","ar-SA","ar-SD","ar-SY","ar-TN","ar-YE","as-IN","az-Latn-AZ","be-BY","bg-BG","bn-IN","bs-Latn-BA,bs-Latn-ME", "ca-AD", "ca-ES", "cs-CZ","da-DK","de-AT","de-CH","de-DE","de-LU","et-EE","el-CY","el-GR","en-AM","en-AU","en-AZ","en-CA","en-GB","en-GH", "en-GM","en-HK","en-IE","en-IN","en-IS","en-JP","en-KE","en-KR","en-LK","en-LR","en-MM","en-MW","en-MY","en-NG","en-NZ", "en-PH","en-PK","en-PR","en-RW","en-SD","en-SG","en-SL","en-TW","en-TZ","en-UG","en-US","en-ZA","en-ZM","es-AR","es-BO", diff --git a/js/test/date/testclock.js b/js/test/date/testclock.js index 632ed47afe..3af65c92b8 100644 --- a/js/test/date/testclock.js +++ b/js/test/date/testclock.js @@ -1775,6 +1775,15 @@ module.exports.testclock = { test.done(); }, + testClock_be_BY: function(test) { + test.expect(2); + var info = new LocaleInfo("be-BY"); + test.ok(info !== null); + + test.equal(info.getClock(), 24); + + test.done(); + }, testClock_lo_LA: function(test) { test.expect(2); var info = new LocaleInfo("lo-LA"); diff --git a/js/test/date/testdatefmt_be_BY.js b/js/test/date/testdatefmt_be_BY.js new file mode 100644 index 0000000000..b85b836d6e --- /dev/null +++ b/js/test/date/testdatefmt_be_BY.js @@ -0,0 +1,1788 @@ +/* + * testdatefmt_be_BY.js - test the date formatter object in Belarus + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(JulianDate) === "undefined") { + var JulianDate = require("../../lib/JulianDate.js"); +} +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateFmt) === "undefined") { + var DateFmt = require("../../lib/DateFmt.js"); +} +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmt_be_BY = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateFmtConstructorEmpty_be_BY: function(test) { + test.expect(1); + var fmt = new DateFmt({locale: "be-BY"}); + + test.ok(fmt !== null); + test.done(); + }, + + testDateFmtSimpleShort_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29.09.11"); + test.done(); + }, + + testDateFmtSimpleMedium_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29.09.2011"); + test.done(); + }, + + testDateFmtSimpleLong_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29 верасня 2011 г."); + test.done(); + }, + + testDateFmtSimpleFull_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня 2011 г.'); + test.done(); + }, + + testDateFmtSimpleTimeShort_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "short", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeMedium_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "medium", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeLong_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", timelength: "long", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtSimpleTimeFull_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 1, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '01:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleShort_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "short", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11, 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleMedium_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "medium", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.2011, 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleLong_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "long", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня 2011 г. у 13:45'); + test.done(); + }, + + testDateFmtDateTimeSimpleFull_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня 2011 г. у 13:45'); + test.done(); + }, + + + testDateFmtTemplateCalendar_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", calendar: "julian", template: "yyyy-MM-dd"}); + test.ok(fmt !== null); + + var date = new JulianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011-09-29"); + test.done(); + }, + + testDateFmtTemplateCalendarIncompatibleDateType_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", calendar: "julian", template: "yyyy-MM-dd HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + // convert automatically to a Julian calendar date + test.equal(fmt.format(date), "2011-09-16 13:45"); + test.done(); + }, + + testDateFmtTemplateClock12SwitchHH_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", clock: "12", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock12Switchkk_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", clock: "12", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateClock24Switchhh_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", clock: "24", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateClock24SwitchKK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", clock: "24", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12hh_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", template: "hh:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault12KK: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", template: "KK:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "01:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24HH_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", template: "HH:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtTemplateNoClockDoNotFollowLocaleDefault24kk_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", template: "kk:mm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + + testDateFmtTypeDate_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "date"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11'); + test.done(); + }, + + testDateFmtTypeTime_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '13:45'); + test.done(); + }, + + testDateFmtTypeDateTime_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "datetime"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11, 13:45'); + test.done(); + }, + + testDateFmtShortDateComponentsY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "11"); + test.done(); + }, + + testDateFmtShortDateComponentsM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "ве"); + test.done(); + }, + + testDateFmtShortDateComponentsN_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "n"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'в'); + test.done(); + }, + + testDateFmtShortDateComponentsD_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtShortDateComponentsDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09'); + test.done(); + }, + + testDateFmtShortDateComponentsMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '09.11'); + test.done(); + }, + + testDateFmtShortDateComponentsDMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29.09.11'); + test.done(); + }, + + testDateFmtShortDateComponentsWDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'ч, 29.09'); + test.done(); + }, + + testDateFmtShortDateComponentsWDMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'ч, 29.09.11'); + test.done(); + }, + + testDateFmtLongDateComponentsWDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", date: "wdm", length: "long"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'чц, 29 верасня'); + test.done(); + }, + + testDateFmtFullDateComponentsY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "y"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "2011"); + test.done(); + }, + + testDateFmtFullDateComponentsM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "верасень"); + test.done(); + }, + + testDateFmtFullDateComponentsD_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "d"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), "29"); + test.done(); + }, + + testDateFmtFullDateComponentsDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "dm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня'); + test.done(); + }, + + testDateFmtFullDateComponentsMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "my"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'верасень 2011 г.'); + test.done(); + }, + + testDateFmtFullDateComponentsDMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "dmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), '29 верасня 2011 г.'); + test.done(); + }, + + testDateFmtFullDateComponentsWDM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "wdm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'чацвер, 29 верасня'); + test.done(); + }, + + testDateFmtFullDateComponentsWDMY_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full", date: "wdmy"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(date), 'чацвер, 29 верасня 2011 г.'); + test.done(); + }, + + testDateFmtShortTimeComponentsS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtShortTimeComponentsM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtShortTimeComponentsH_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtShortTimeComponentsMS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMA_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + time: "hmz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 +03"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMAZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + time: "hmaz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 +03"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSA_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + time: "hmsz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +03"); + test.done(); + }, + + testDateFmtShortTimeComponentsHMSAZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + time: "hmsaz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +03"); + test.done(); + }, + + testDateFmtFullTimeComponentsS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "s"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "37"); + test.done(); + }, + + testDateFmtFullTimeComponentsM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "m"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45"); + test.done(); + }, + + testDateFmtFullTimeComponentsH_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "h"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13"); + test.done(); + }, + + testDateFmtFullTimeComponentsMS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "ms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHM_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "hm"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMS_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "hms"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMA_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "hma"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 +03"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMAZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmaz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45 +03"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSA_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", type: "time", length: "full", time: "hmsa"}); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmsz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +03"); + test.done(); + }, + + testDateFmtFullTimeComponentsHMSAZ_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmsaz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +03"); + test.done(); + }, + + testDateFmtWithTimeZoneAndNoDST_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({ + locale: "be-BY", + type: "time", + length: "full", + time: "hmsz", + timezone: "Europe/Minsk" + }); + test.ok(fmt !== null); + + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 12, + day: 29, + hour: 13, + minute: 45, + second: 37, + millisecond: 0 + }); + test.equal(fmt.format(date), "13:45:37 +03"); + test.done(); + }, + + testDateFmtFormatRelativeWithinMinuteAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "праз 30 секунд"); + test.done(); + }, +testDateFmtFormatRelativeWithinMinuteBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 44, + second: 30, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "30 секунд таму"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), "праз 10 хвілін"); + test.done(); + }, +testDateFmtFormatRelativeWithinHourBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '10 хвілін таму'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 17, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 4 гадзіны'); + test.done(); + }, +testDateFmtFormatRelativeWithinDayBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 гадзіны таму'); + test.done(); + }, + + testDateFmtFormatRelativeWithinFortnightAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 4 дні'); + test.done(); + }, +testDateFmtFormatRelativeWithinFortnightBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 16, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '4 дні таму'); + test.done(); + }, + + testDateFmtFormatRelativeWithinQuarterAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 11, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 9 тыдняў'); + test.done(); + }, +testDateFmtFormatRelativeWithinQuarterBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '9 тыдняў таму'); + test.done(); + }, + + testDateFmtFormatRelativeWithinTwoYearsAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2013, + month: 1, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 16 месяцаў'); + test.done(); + }, +testDateFmtFormatRelativeWithinTwoYearsBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2010, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '14 месяцаў таму'); + test.done(); + }, + + testDateFmtFormatRelativeYearsAfter_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 2025, + month: 10, + day: 24, + hour: 15, + minute: 55, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), 'праз 14 гадоў'); + test.done(); + }, +testDateFmtFormatRelativeYearsBefore_be_BY: function(test) { + test.expect(2); + var fmt = new DateFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var reference = new GregorianDate({ + locale: "be-BY", + year: 2011, + month: 9, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var date = new GregorianDate({ + locale: "be-BY", + year: 1990, + month: 7, + day: 18, + hour: 9, + minute: 35, + second: 0, + millisecond: 0 + }); + test.equal(fmt.formatRelative(reference, date), '21 год таму'); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/date/testdatetimefmt.js b/js/test/date/testdatetimefmt.js index 08ce5416fd..a1c97f1627 100644 --- a/js/test/date/testdatetimefmt.js +++ b/js/test/date/testdatetimefmt.js @@ -5130,6 +5130,31 @@ module.exports.testdatetimeformat = { test.done(); }, + testDateTimeFormat_be_BY: function(test) { + test.expect(7); + + var result1, result2, result3, result4; + result1 = new DateFmt({locale:"be-BY", type:"date", date:"dmwy", length: "full", useNative:false, timezone:"local"}).template; + result2 = new DateFmt({locale:"be-BY", type:"date", date:"dmwy", length: "long", useNative:false, timezone:"local"}).template; + result3 = new DateFmt({locale:"be-BY", type:"date", date:"dmwy", length: "medium", useNative:false, timezone:"local"}).template; + result4 = new DateFmt({locale:"be-BY", type:"date", date:"dmwy", length: "short", useNative:false, timezone:"local"}).template; + + test.equal(result1, "EEEE, d MMMM yyyy \'г\'."); + test.equal(result2, "EEE, d MMMM yyyy \'г\'."); + test.equal(result3, "EE, d.MM.yyyy"); + test.equal(result4, "E, d.MM.yy"); + + result1 = new DateFmt({locale:"be-BY", type:"datetime", date:"dmwy", length: "full", useNative:false, timezone:"local"}).template; + result2 = new DateFmt({locale:"be-BY", type:"datetime", date:"dmwy", length: "short", useNative:false, timezone:"local"}).template; + + test.equal(result1, "EEEE, d MMMM yyyy \'г\'. \'у\' HH:mm"); + test.equal(result2, "E, d.MM.yy, HH:mm"); + + result1 = new DateFmt({locale:"be-BY", type:"time", time:"ahmsz", length:"full", useNative:false, timezone:"local"}).template; + test.equal(result1, "HH:mm:ss z"); + + test.done(); + }, testDateTimeFormat_lo_LA: function(test) { test.expect(7); diff --git a/js/test/daterange/testSuite.html b/js/test/daterange/testSuite.html index 1616bbfb14..55b7f69dcb 100644 --- a/js/test/daterange/testSuite.html +++ b/js/test/daterange/testSuite.html @@ -38,6 +38,7 @@ + diff --git a/js/test/daterange/testSuiteFiles.js b/js/test/daterange/testSuiteFiles.js index d040951fe1..08fe2e31c7 100644 --- a/js/test/daterange/testSuiteFiles.js +++ b/js/test/daterange/testSuiteFiles.js @@ -26,6 +26,7 @@ module.exports.files = [ "testdatefmtrange_ar_SA.js", "testdatefmtrange_as_IN.js", "testdatefmtrange_az_Latn_AZ.js", + "testdatefmtrange_be_BY.js", "testdatefmtrange_bg_BG.js", "testdatefmtrange_bn_IN.js", "testdatefmtrange_bs_Latn_BA.js", diff --git a/js/test/daterange/testdatefmtrange_be_BY.js b/js/test/daterange/testdatefmtrange_be_BY.js new file mode 100644 index 0000000000..53704e2832 --- /dev/null +++ b/js/test/daterange/testdatefmtrange_be_BY.js @@ -0,0 +1,692 @@ +/* + * testdatefmtrange_be_BY.js - test the date range formatter object Belarussian/Belarus + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(GregorianDate) === "undefined") { + var GregorianDate = require("../../lib/GregorianDate.js"); +} +if (typeof(DateRngFmt) === "undefined") { + var DateRngFmt = require("../../lib/DateRngFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testdatefmtrange_be_BY = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + + testDateRngFmtbeBYRangeInDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31.12.11, 13:45 – 14:30"); + test.done(); + }, + testDateRngFmtbeBYRangeInDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31.12.2011, 13:45 – 14:30"); + test.done(); + }, + testDateRngFmtbeBYRangeInDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31 снежня 2011 г. у 13:45 – 14:30"); + test.done(); + }, + testDateRngFmtbeBYRangeInDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "31 снежня 2011 г. у 13:45 – 14:30"); + test.done(); + }, + + testDateRngFmtbeBYRangeNextDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30.12.11, 13:45 – 31.12.11, 14:30"); + test.done(); + }, + testDateRngFmtbeBYRangeNextDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30.12.2011, 13:45 – 31.12.2011, 14:30"); + test.done(); + }, + testDateRngFmtbeBYRangeNextDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30 снежня 2011 г. у 13:45 – 31 снежня 2011 г. у 14:30"); + test.done(); + }, + testDateRngFmtbeBYRangeNextDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 30, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "30 снежня 2011 г. у 13:45 – 31 снежня 2011 г. у 14:30"); + test.done(); + }, + + testDateRngFmtbeBYRangeMultiDayShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31.12.11"); + test.done(); + }, + testDateRngFmtbeBYRangeMultiDayMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31.12.2011"); + test.done(); + }, + testDateRngFmtbeBYRangeMultiDayLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 снежня 2011 г."); + test.done(); + }, + testDateRngFmtbeBYRangeMultiDayFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 12, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 – 31 снежня 2011 г."); + test.done(); + }, + + testDateRngFmtbeBYRangeNextMonthShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11 – 31.12.11"); + test.done(); + }, + testDateRngFmtbeBYRangeNextMonthMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11 – 31.12.2011"); + test.done(); + }, + testDateRngFmtbeBYRangeNextMonthLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 лістапада – 31 снежня 2011 г."); + test.done(); + }, + testDateRngFmtbeBYRangeNextMonthFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2011, + month: 12, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 лістапада – 31 снежня 2011 г."); + test.done(); + }, + + testDateRngFmtbeBYRangeNextYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11.11 – 31.01.12"); + test.done(); + }, + testDateRngFmtbeBYRangeNextYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20.11.2011 – 31.01.2012"); + test.done(); + }, + testDateRngFmtbeBYRangeNextYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 лістапада 2011 г. – 31 студзеня 2012 г."); + test.done(); + }, + testDateRngFmtbeBYRangeNextYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2012, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "20 лістапада 2011 г. – 31 студзеня 2012 г."); + test.done(); + }, + + testDateRngFmtbeBYRangeMultiYearShort: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "short"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11.11 – 01.14"); + test.done(); + }, + testDateRngFmtbeBYRangeMultiYearMedium: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "medium"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "11.2011 – 01.2014"); + test.done(); + }, + testDateRngFmtbeBYRangeMultiYearLong: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "long"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "лістапада 2011 г. – студзеня 2014 г."); + test.done(); + }, + testDateRngFmtbeBYRangeMultiYearFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2014, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "лістапада 2011 г. – студзеня 2014 г."); + test.done(); + }, + testDateRngFmtbeBYManyYearsFull: function(test) { + test.expect(2); + var fmt = new DateRngFmt({locale: "be-BY", length: "full"}); + test.ok(fmt !== null); + + var start = new GregorianDate({ + year: 2011, + month: 11, + day: 20, + hour: 13, + minute: 45, + second: 0, + millisecond: 0 + }); + var end = new GregorianDate({ + year: 2064, + month: 1, + day: 31, + hour: 14, + minute: 30, + second: 0, + millisecond: 0 + }); + test.equal(fmt.format(start, end), "2011 – 2064"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/daterange/testdatefmtrange_fmttemplate.js b/js/test/daterange/testdatefmtrange_fmttemplate.js index fb5f495587..9bd12a458c 100644 --- a/js/test/daterange/testdatefmtrange_fmttemplate.js +++ b/js/test/daterange/testdatefmtrange_fmttemplate.js @@ -13866,7 +13866,7 @@ module.exports.testdaterangefmt = { test.done(); }, - testDateRngFmt_lo_LA: function(test) { + testDateRngFmt_be_BY: function(test) { test.expect(36); var fmt; var data = setVariables(); @@ -13878,6 +13878,75 @@ module.exports.testdaterangefmt = { var templatec30 = []; //dmy + for (var i=0; i < 4; i++) { + fmt = new DateRngFmt({locale:"be-BY", length: length[i]}) + templatec00.push(fmt.dateFmt.formats.range["c00"][abbrLength[i]]); + templatec01.push(fmt.dateFmt.formats.range["c01"][abbrLength[i]]); + templatec02.push(fmt.dateFmt.formats.range["c02"][abbrLength[i]]); + templatec03.push(fmt.dateFmt.formats.range["c03"][abbrLength[i]]); + templatec10.push(fmt.dateFmt.formats.range["c10"][abbrLength[i]]); + templatec11.push(fmt.dateFmt.formats.range["c11"][abbrLength[i]]); + templatec12.push(fmt.dateFmt.formats.range["c12"][abbrLength[i]]); + templatec20.push(fmt.dateFmt.formats.range["c20"][abbrLength[i]]); + templatec30.push(fmt.dateFmt.formats.range["c30"][abbrLength[i]]); + } + test.equal(templatec00[0], '{sd} {sm} {sy} г. у {st} – {et}'); + test.equal(templatec00[1], '{sd} {sm} {sy} г. у {st} – {et}'); + test.equal(templatec00[2], '{sd}.{sm}.{sy}, {st} – {et}'); + test.equal(templatec00[3], '{sd}.{sm}.{sy}, {st} – {et}'); + + test.equal(templatec01[0], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec01[1], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec01[2], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec01[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec02[1], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec02[0], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec02[2], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec02[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec03[0], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec03[1], '{sd} {sm} {sy} г. у {st} – {ed} {em} {ey} г. у {et}'); + test.equal(templatec03[2], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + test.equal(templatec03[3], '{sd}.{sm}.{sy}, {st} – {ed}.{em}.{ey}, {et}'); + + test.equal(templatec10[0], '{sd} – {ed} {em} {ey} г.'); + test.equal(templatec10[1], '{sd} – {ed} {em} {ey} г.'); + test.equal(templatec10[2], '{sd} – {ed}.{em}.{ey}'); + test.equal(templatec10[3], '{sd} – {ed}.{em}.{ey}'); + + test.equal(templatec11[0], '{sd} {sm} – {ed} {em} {ey} г.'); + test.equal(templatec11[1], '{sd} {sm} – {ed} {em} {ey} г.'); + test.equal(templatec11[2], '{sd}.{sm} – {ed}.{em}.{ey}'); + test.equal(templatec11[3], '{sd}.{sm} – {ed}.{em}.{ey}'); + + test.equal(templatec12[0], '{sd} {sm} {sy} г. – {ed} {em} {ey} г.'); + test.equal(templatec12[1], '{sd} {sm} {sy} г. – {ed} {em} {ey} г.'); + test.equal(templatec12[2], '{sd}.{sm}.{sy} – {ed}.{em}.{ey}'); + test.equal(templatec12[3], '{sd}.{sm}.{sy} – {ed}.{em}.{ey}'); + + test.equal(templatec20[0], '{sm} {sy} г. – {em} {ey} г.'); + test.equal(templatec20[1], '{sm} {sy} г. – {em} {ey} г.'); + test.equal(templatec20[2], '{sm}.{sy} – {em}.{ey}'); + test.equal(templatec20[3], '{sm}.{sy} – {em}.{ey}'); + test.equal(templatec30[0], "{sy} – {ey}"); + test.equal(templatec30[1], "{sy} – {ey}"); + test.equal(templatec30[2], "{sy} – {ey}"); + test.equal(templatec30[3], "{sy} – {ey}"); + + test.done(); + }, + testDateRngFmt_lo_LA: function(test) { + test.expect(36); + var fmt; + var data = setVariables(); + var length = data["fullLength"]; + var abbrLength = data["abbrLength"]; + + var templatec00 = [],templatec01 = [],templatec02 = [],templatec03 = []; + var templatec10 = [],templatec11 = [],templatec12 = [],templatec20 = []; + var templatec30 = []; + for (var i=0; i < 4; i++) { fmt = new DateRngFmt({locale:"lo-LA", length: length[i]}) templatec00.push(fmt.dateFmt.formats.range["c00"][abbrLength[i]]); @@ -13890,6 +13959,7 @@ module.exports.testdaterangefmt = { templatec20.push(fmt.dateFmt.formats.range["c20"][abbrLength[i]]); templatec30.push(fmt.dateFmt.formats.range["c30"][abbrLength[i]]); } + test.equal(templatec00[0], '{sd} {sm} {sy}, {st} – {et}'); test.equal(templatec00[1], '{sd} {sm} {sy}, {st} – {et}'); test.equal(templatec00[2], '{sd} {sm} {sy}, {st} – {et}'); diff --git a/js/test/durfmt/testdurfmt2.js b/js/test/durfmt/testdurfmt2.js index 6982716cdc..b906854395 100644 --- a/js/test/durfmt/testdurfmt2.js +++ b/js/test/durfmt/testdurfmt2.js @@ -9037,6 +9037,58 @@ module.exports.testdurfmt2 = { test.done(); }, + testDurFmt_be_BY: function(test) { + test.expect(24); + // 1 3 100 + var textfmt; + var data = setVariable(); + var length = data["fullLength"]; + + var textformatted_1 = [], textformatted_3 = [], textformatted_100 = []; + var clockformatted_1 = [], clockformatted_3 = [], clockformatted_100 = []; + + for (var i=0; i<4; i++) { + textfmt = new DurationFmt({locale: "be-BY", style:"text", length:length[i]}); + textformatted_1.push(textfmt.format({year: 1,month: 1,week: 1,day: 1}).toString()); + textformatted_3.push(textfmt.format({year: 3,month: 3,week: 3,day: 3}).toString()); + textformatted_100.push(textfmt.format({year: 100,month: 100,week: 100,day: 100}).toString()); + + clockformatted_1.push(textfmt.format({hour: 1,minute: 1,second: 1}).toString()); + clockformatted_3.push(textfmt.format({hour: 3,minute: 3,second: 3}).toString()); + clockformatted_100.push(textfmt.format({hour: 100,minute: 100,second: 100}).toString()); + } + + test.equal(textformatted_1[0], '1 год 1 месяц 1 тыдзень 1 суткі'); + test.equal(textformatted_1[1], '1 г. 1 мес. 1 тыдз. 1 сут'); + test.equal(textformatted_1[2], '1 г. 1 мес. 1 тыдз. 1 сут'); + test.equal(textformatted_1[3], '1 г. 1 мес. 1 тыдз. 1 сут'); + + test.equal(textformatted_3[0], '3 гады 3 месяца 3 тыдні 3 сутак'); + test.equal(textformatted_3[1], '3 г. 3 мес. 3 тыдз. 3 сут'); + test.equal(textformatted_3[2], '3 г. 3 мес. 3 тыдз. 3 сут'); + test.equal(textformatted_3[3], '3 г. 3 мес. 3 тыдз. 3 сут'); + + test.equal(textformatted_100[0], '100 гадоў 100 месяцаў 100 тыдняў 100 сутак'); + test.equal(textformatted_100[1], '100 г. 100 мес. 100 тыдз. 100 сут'); + test.equal(textformatted_100[2], '100 г. 100 мес. 100 тыдз. 100 сут'); + test.equal(textformatted_100[3], '100 г. 100 мес. 100 тыдз. 100 сут'); + + test.equal(clockformatted_1[0], '1 гадзіна 1 хвіліна 1 секунда'); + test.equal(clockformatted_1[1], '1 гадз 1 хв 1 с'); + test.equal(clockformatted_1[2], '1 гадз 1 хв 1 с'); + test.equal(clockformatted_1[3], '1 гадз 1 хв 1 с'); + + test.equal(clockformatted_3[0], '3 гадзіны 3 хвіліны 3 секунды'); + test.equal(clockformatted_3[1], '3 гадз 3 хв 3 с'); + test.equal(clockformatted_3[2], '3 гадз 3 хв 3 с'); + test.equal(clockformatted_3[3], '3 гадз 3 хв 3 с'); + + test.equal(clockformatted_100[0], '100 гадзін 100 хвілін 100 секунд'); + test.equal(clockformatted_100[1], '100 гадз 100 хв 100 с'); + test.equal(clockformatted_100[2], '100 гадз 100 хв 100 с'); + test.equal(clockformatted_100[3], '100 гадз 100 хв 100 с'); + test.done(); + }, testDurFmt_lo_LA: function(test) { test.expect(16); // 1 18 diff --git a/js/test/number/testcurrency.js b/js/test/number/testcurrency.js index 2d85416c4c..63d3037f5e 100644 --- a/js/test/number/testcurrency.js +++ b/js/test/number/testcurrency.js @@ -1904,6 +1904,14 @@ module.exports.testcurrency = { test.done(); }, + testCurrency_be_BY: function(test) { + test.expect(2); + var info = new LocaleInfo("be-BY"); + test.ok(info !== null); + + test.equal(info.getCurrency(), "BYN"); + test.done(); + }, testCurrency_ne_NP: function(test) { test.expect(2); var info = new LocaleInfo("ne-NP"); diff --git a/js/test/number/testnumfmt2.js b/js/test/number/testnumfmt2.js index 75960d619f..b89bbc46e7 100644 --- a/js/test/number/testnumfmt2.js +++ b/js/test/number/testnumfmt2.js @@ -3774,6 +3774,25 @@ module.exports.testnumfmt2 = { test.equal(curfmt.format(57.05), "57,05 ₾"); //GEL test.done(); }, + testNumFmt_be_BY: function(test) { + test.expect(9); + var li = new LocaleInfo("be-BY"); + var fmt = new NumFmt({locale:"be-BY", type:"standard", useNative:false}); + test.equal(li.getDecimalSeparator(), ","); + test.equal(li.getGroupingSeparator(), " "); + test.equal(fmt.format(123456789.45), "123 456 789,45"); + + var pctfmt = new NumFmt({locale:"be-BY", type:"percentage", useNative:false}); + test.equal(li.getPercentageFormat(), "{n} %"); + test.equal(li.getNegativePercentageFormat(), "-{n} %"); + test.equal(pctfmt.format(34), "34 %"); + + var curfmt = new NumFmt({locale: "be-BY", type: "currency", useNative:false, currency:li.getCurrency()}); + test.equal(li.getCurrencyFormats().common, "{n} {s}"); + test.equal(li.getCurrencyFormats().commonNegative, "-{n} {s}"); + test.equal(curfmt.format(57.05), "57,05 р."); //BYN + test.done(); + }, testNumFmt_lo_LA: function(test) { test.expect(9); var li = new LocaleInfo("lo-LA"); diff --git a/js/test/root/testcountry.js b/js/test/root/testcountry.js index ef90099674..a7a33391f6 100644 --- a/js/test/root/testcountry.js +++ b/js/test/root/testcountry.js @@ -172,6 +172,19 @@ module.exports.testcountry = { test.equal(locale.toString(), "en-AU"); test.done(); }, + testCountryLocale9: function(test) { + test.expect(4); + var ctry = new Country({ + locale: "be-BY" + }); + test.ok(ctry !== null); + + test.equal(ctry.getName("MO"),"Макаа, САР (Кітай)" ); + test.equal(ctry.getCode("Макаа, САР (Кітай)"), "MO"); + var locale = ctry.getLocale(); + test.equal(locale.toString(), "be-BY"); + test.done(); + }, testCountryLocale_lo_LA: function(test) { test.expect(4); var ctry = new Country({ diff --git a/js/test/root/testlocaleinfo.js b/js/test/root/testlocaleinfo.js index 50fb68bd03..1719d2d3ad 100644 --- a/js/test/root/testlocaleinfo.js +++ b/js/test/root/testlocaleinfo.js @@ -13389,6 +13389,16 @@ module.exports.testlocaleinfo = { test.equal(info.getPaperSize(), "A4"); test.done(); }, + testLocaleInfoQuotation_be_BY: function(test) { + test.expect(4); + var info = new LocaleInfo("be-BY"); + test.ok(info !== null); + + test.equal(info.getDelimiterQuotationStart(), "«"); + test.equal(info.getDelimiterQuotationEnd(), "»"); + test.equal(info.getPaperSize(), "A4"); + test.done(); + }, testLocaleInfoQuotation_lo_LA: function(test) { test.expect(4); var info = new LocaleInfo("lo-LA"); diff --git a/js/test/root/testlocalematch.js b/js/test/root/testlocalematch.js index ac36aba1cc..ffab5b1874 100644 --- a/js/test/root/testlocalematch.js +++ b/js/test/root/testlocalematch.js @@ -1106,6 +1106,39 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-Geor-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleByLocaleCode63: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "be-BY" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "be-Cyrl-BY"); + test.done(); + }, + testLocaleMatcherGetLikelyLocaleByLocaleCode64: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "be" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "be-Cyrl-BY"); + test.done(); + }, + testLocaleMatcherGetLikelyLocaleByLocaleCode65: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "BY" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocale(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "be-Cyrl-BY"); + test.done(); + }, testLocaleMatcherGetLikelyLocaleByLocaleCode_lo: function(test) { test.expect(3); var lm = new LocaleMatcher({ @@ -1715,6 +1748,17 @@ module.exports.testlocalematch = { test.equal(locale.getSpec(), "ka-GE"); test.done(); }, + testLocaleMatcherGetLikelyLocaleMinimalByLanguage4: function(test) { + test.expect(3); + var lm = new LocaleMatcher({ + locale: "be" + }); + test.ok(typeof(lm) !== "undefined"); + var locale = lm.getLikelyLocaleMinimal(); + test.ok(typeof(locale) !== "undefined"); + test.equal(locale.getSpec(), "be-BY"); + test.done(); + }, testLocaleMatcherGetLikelyLocaleMinimalByLanguage_ky: function(test) { test.expect(3); var lm = new LocaleMatcher({ diff --git a/js/test/root/testscriptinfo.js b/js/test/root/testscriptinfo.js index 3b1bf1fda2..a70b3eba2d 100644 --- a/js/test/root/testscriptinfo.js +++ b/js/test/root/testscriptinfo.js @@ -2186,6 +2186,16 @@ module.exports.testscriptinfo = { test.equal(scinfo.getScriptDirection(), "ltr"); test.done(); }, + testScriptInfo_be_BY: function(test) { + test.expect(4); + var li = new LocaleInfo("be-BY"); + var scinfo = new ScriptInfo(li.getScript()); + test.ok(li !== null); + test.ok(scinfo !== null); + test.equal(li.getScript(), "Cyrl"); + test.equal(scinfo.getScriptDirection(), "ltr"); + test.done(); + }, testScriptInfo_lo_LA: function(test) { test.expect(4); var li = new LocaleInfo("lo-LA"); diff --git a/js/test/root/teststrings.js b/js/test/root/teststrings.js index 5f0228f74c..2cf1339a11 100644 --- a/js/test/root/teststrings.js +++ b/js/test/root/teststrings.js @@ -3263,7 +3263,25 @@ module.exports.teststrings = { test.equal(str.formatChoice(1), "There items are one"); test.done(); }, + testStringFormatChoiceCharClasses25: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + test.equal(str.formatChoice(0), "There are no items."); + test.done(); + }, + testStringFormatChoiceCharClasses26: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + test.ok(str !== null); + + test.equal(str.formatChoice(1), "There items are one"); + test.done(); + }, testStringFormatChoiceCharClasses32: function(test) { test.expect(2); var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); @@ -3274,6 +3292,37 @@ module.exports.teststrings = { test.equal(str.formatChoice(1), "There items are one"); test.done(); }, + testStringFormatChoiceCharClasses27: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(3), "The items are few"); + test.done(); + }, + testStringFormatChoiceCharClasses28: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(100), "The items are many"); + test.done(); + }, + testStringFormatChoiceCharClasses29: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(8), "The items are many"); + test.done(); + }, + testStringFormatChoiceCharClasses30: function(test) { test.expect(2); @@ -3785,6 +3834,36 @@ module.exports.teststrings = { test.equal(str.formatChoice(1.7), "Default items"); test.done(); }, + testStringFormatChoiceDecimal26: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(21.0), "There items are one"); + test.done(); + }, + testStringFormatChoiceDecimal27: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(33.0), "The items are few"); + test.done(); + }, + testStringFormatChoiceDecimal28: function(test) { + test.expect(2); + var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); + str.setLocale("be-BY"); + + test.ok(str !== null); + + test.equal(str.formatChoice(100.1), "Default items"); + test.done(); + }, testStringFormatChoiceDecimal_lo_LA: function(test) { test.expect(2); var str = new IString("0#There are no items.|one#There items are one|few#The items are few|many#The items are many|#Default items"); diff --git a/js/test/strings-ext/testSuite.html b/js/test/strings-ext/testSuite.html index 5e13700c00..f730fef158 100644 --- a/js/test/strings-ext/testSuite.html +++ b/js/test/strings-ext/testSuite.html @@ -35,6 +35,7 @@ + diff --git a/js/test/strings-ext/testSuiteCompiled.html b/js/test/strings-ext/testSuiteCompiled.html index 3b91555bed..aaa46776d0 100644 --- a/js/test/strings-ext/testSuiteCompiled.html +++ b/js/test/strings-ext/testSuiteCompiled.html @@ -35,6 +35,7 @@ + diff --git a/js/test/strings-ext/testSuiteFiles.js b/js/test/strings-ext/testSuiteFiles.js index c2dd7559ea..e506d05d90 100644 --- a/js/test/strings-ext/testSuiteFiles.js +++ b/js/test/strings-ext/testSuiteFiles.js @@ -23,6 +23,7 @@ module.exports.files = [ "testlistfmt.js", "testlistfmt_am_ET.js", "testlistfmt_ar.js", + "testlistfmt_be_BY.js", "testlistfmt_bs.js", "testlistfmt_ca.js", "testlistfmt_de.js", diff --git a/js/test/strings-ext/testlistfmt_be_BY.js b/js/test/strings-ext/testlistfmt_be_BY.js new file mode 100644 index 0000000000..b2469dc1aa --- /dev/null +++ b/js/test/strings-ext/testlistfmt_be_BY.js @@ -0,0 +1,253 @@ +/* + * testlistfmt_be_BY.js - test the list formatter object + * + * Copyright © 2020, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSe-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(ListFmt) === "undefined") { + var ListFmt = require("../../lib/ListFmt.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testlistfmt_be_BY = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testListFmtbeBYNumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін"]), "адзін"); + test.done(); + }, + testListFmtbeBYNumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два"]), "адзін і два"); + test.done(); + }, + testListFmtbeBYNumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры"]), "адзін, два і тры"); + test.done(); + }, + testListFmtbeBYNumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін, два, тры і чатыры"); + test.done(); + }, + testListFmtbeBYNumberFormatFive: function(test) { + var fmt = new ListFmt({ + locale: "be-BY" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін, два, тры, чатыры і пяць"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatOneShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін"]), "адзін"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatTwoShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два"]), "адзін два"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatThreeShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры"]), "адзін два тры"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatFourShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін два тры чатыры"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatFiveShort: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін два тры чатыры пяць"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatOneFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін"]), "адзін"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatTwoFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два"]), "адзін два"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatThreeFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры"]), "адзін два тры"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatFourFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін два тры чатыры"); + test.done(); + }, + testListFmtUnitStylebeBYNumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "unit", + length: "full" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін два тры чатыры пяць"); + test.done(); + }, + testListFmtORStylebeBYNumberFormatOne: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін"]), "адзін"); + test.done(); + }, + testListFmtORStylebeBYNumberFormatTwo: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два"]), "адзін ці два"); + test.done(); + }, + testListFmtORStylebeBYNumberFormatThree: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры"]), "адзін, два ці тры"); + test.done(); + }, + testListFmtORStylebeBYNumberFormatFour: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры"]), "адзін, два, тры ці чатыры"); + test.done(); + }, + testListFmtORStylebeBYNumberFormatFiveFull: function(test) { + var fmt = new ListFmt({ + locale: "be-BY", + style: "disjunction" + }); + + test.expect(2); + test.ok(fmt !== null); + test.equal(fmt.format(["адзін", "два", "тры", "чатыры", "пяць"]), "адзін, два, тры, чатыры ці пяць"); + test.done(); + } +}; \ No newline at end of file diff --git a/js/test/units/testSuite.html b/js/test/units/testSuite.html index 9a59990d8c..7cc4f9559d 100644 --- a/js/test/units/testSuite.html +++ b/js/test/units/testSuite.html @@ -43,6 +43,7 @@ + diff --git a/js/test/units/testSuiteFiles.js b/js/test/units/testSuiteFiles.js index 3584f9beb9..c18e7b01bc 100644 --- a/js/test/units/testSuiteFiles.js +++ b/js/test/units/testSuiteFiles.js @@ -32,6 +32,7 @@ module.exports.files = [ "testtime.js", "testunits.js", "testunitfmt.js", + "testunitfmt_be_BY.js", "testunitfmt_ca.js", "testunitfmt_eu_ES.js", "testunitfmt_gl_ES.js", diff --git a/js/test/units/testmeasurement.js b/js/test/units/testmeasurement.js index 5480878c96..f5aa03cb8d 100644 --- a/js/test/units/testmeasurement.js +++ b/js/test/units/testmeasurement.js @@ -715,6 +715,12 @@ module.exports.testmeasurement = { test.equal(Measurement.getMeasurementSystemForLocale("zu-ZA"), "metric"); test.done(); }, + testMeasurementGetMeasurementSystemOther4: function(test) { + test.expect(1); + + test.equal(Measurement.getMeasurementSystemForLocale("be-BY"), "metric"); + test.done(); + }, testMeasurementGetMeasurementSystemOtherWithLocaleObj: function(test) { test.expect(1); diff --git a/js/test/units/testunitfmt.js b/js/test/units/testunitfmt.js index 9905fb5758..37db9b1d41 100644 --- a/js/test/units/testunitfmt.js +++ b/js/test/units/testunitfmt.js @@ -1936,6 +1936,30 @@ module.exports.testunitfmt = { test.equal(str, "1,000兆字节/秒"); test.done(); }, + testUnitFormatDigitalSpeed5: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "megabyte/s", + amount: 1000 + }); + + var uf = new UnitFmt({locale: "be-BY",length:"long",autoConvert:false,autoScale: false}); + var str = uf.format(m1); + test.equal(str, "1 000 мегабайта у секунду"); + test.done(); + }, + testUnitFormatDigitalSpeed6: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "megabyte/s", + amount: 1000 + }); + + var uf = new UnitFmt({locale: "be-BY",length:"short",autoConvert:false,autoScale: false}); + var str = uf.format(m1); + test.equal(str, "1 000 МБ/с"); + test.done(); + }, testUnitFormatEnergy11: function(test) { test.expect(1); diff --git a/js/test/units/testunitfmt_be_BY.js b/js/test/units/testunitfmt_be_BY.js new file mode 100644 index 0000000000..8d8835914e --- /dev/null +++ b/js/test/units/testunitfmt_be_BY.js @@ -0,0 +1,330 @@ +/* + * testunitfmt_be_BY.js - test the unitfmt for be-BY + * + * Copyright © 2020 JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof(UnitFmt) === "undefined") { + var UnitFmt = require("../../lib/UnitFmt.js"); +} +if (typeof(Measurement) === "undefined") { + var Measurement = require("../../lib/Measurement.js"); +} + +if (typeof(MeasurementFactory) === "undefined") { + var MeasurementFactory = require("../../lib/MeasurementFactory.js"); +} + +if (typeof(ilib) === "undefined") { + var ilib = require("../../lib/ilib.js"); +} + +module.exports.testunitfmt_be_BY = { + setUp: function(callback) { + ilib.clearCache(); + callback(); + }, + testUnitFormatGetLocale_be_BY: function(test) { + test.expect(2); + var uf = new UnitFmt({ + locale: "be-BY" + }); + test.ok(uf.getLocale()); + test.equal(uf.getLocale().getSpec(), "be-BY"); + test.done(); + }, + testGetMeasurementSystem_be_BY: function(test) { + test.expect(1); + + test.equal(Measurement.getMeasurementSystemForLocale("be-BY"), "metric"); + test.done(); + }, + testUnitFormatTemperature1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + length: "short", + autoConvert: true, + maxFractionDigits: 2, + roundingMode: "down" + }); + var str = uf.format(m1); + test.equal(str, "-16,66 °C"); + test.done(); + }, + testUnitFormatTemperature2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "fahrenheit", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + autoScale: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "-16,666666666666668 градусы Цэльсія"); + test.done(); + }, + testUnitFormatArea1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert:true, + length:"short" + }); + + var str = uf.format(m1); + test.equal(str, "2 см²"); + test.done(); + }, + testUnitFormatArea2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "square centimeter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "2 квадратныя сантыметры"); + test.done(); + }, + testUnitFormatArea3_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "short" + }); + + var str = uf.format(m1); + test.equal(str, "10 км²"); + test.done(); + }, + testUnitFormatArea4_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "hectare", + amount: 1000 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "long" + }); + + var str = uf.format(m1); + test.equal(str, "10 квадратных кіламетраў"); + test.done(); + }, + testUnitFormatFuelConsumption1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "2 км/л"); + test.done(); + }, + testUnitFormatFuelConsumption2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km/liter", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "2 кіламетра на літр"); + test.done(); + }, + testUnitFormatLength1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "meter", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "short" + }); + var str = uf.format(m1); + test.equal(str, "2 км"); + test.done(); + }, + testUnitFormatLength2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "meter", + amount: 2000 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + autoConvert: true, + length: "long" + }); + var str = uf.format(m1); + test.equal(str, "2 кіламетры"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "vehicleDistance", + length: "short", + autoConvert: true, + }); + var str = uf.format(m1); + test.equal(str, "10 км"); + test.done(); + }, + testUnitFormatWithUsageVehicleDistance2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "km", + amount: 10 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "vehicleDistance", + length: "long", + autoConvert: true + }); + var str = uf.format(m1); + test.equal(str, "10 кіламетраў"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "fuelVolume", + length: "short", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 л"); + test.done(); + }, + testUnitFormatWithUsageFuelVolume2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "imperial gallon", + amount: 2 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "fuelVolume", + length: "long", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "9,09 літра"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits1_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "electricalEnergy", + length: "short", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 кВт·г"); + test.done(); + }, + testUnitFormatWithUsageOverrideSignificantDigits2_be_BY: function(test) { + test.expect(1); + var m1 = MeasurementFactory({ + unit: "kWh", + amount: 102.338322234 + }); + + var uf = new UnitFmt({ + locale: "be-BY", + usage: "electricalEnergy", + length: "long", + significantDigits: "6", + autoConvert: true + }); + + var str = uf.format(m1); + test.equal(str, "102,338 кілават-гадзіны"); + test.done(); + } +} \ No newline at end of file