diff --git a/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-long.js b/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-long.js new file mode 100644 index 0000000000000000000000000000000000000000..44260350fe6da93fcfb5bbaeab3cd6cfb8919123 --- /dev/null +++ b/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-long.js @@ -0,0 +1,69 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat.prototype.format +description: Checks the behavior of Intl.RelativeTimeFormat.prototype.format() in Polish. +features: [Intl.RelativeTimeFormat] +locale: [pl-PL] +---*/ + +function regular(s) { + return { + "many": s, + "few": s + "y", + "one": s + "ę", + } +} + +// https://www.unicode.org/cldr/charts/33/summary/pl.html#1419 +const units = { + "second": regular("sekund"), + "minute": regular("minut"), + "hour": regular("godzin"), + "day": { + "many": "dni", + "few": "dni", + "one": "dzień", + }, + "week": { + "many": "tygodni", + "few": "tygodnie", + "one": "tydzień", + }, + "month": { + 1000: "miesięcy", + "many": "miesięcy", + "few": "miesiące", + "one": "miesiąc", + }, + "quarter": { + "many": "kwartałów", + "few": "kwartały", + "one": "kwartał", + }, + "year": { + "many": "lat", + "few": "lata", + "one": "rok", + }, +}; + +const rtf = new Intl.RelativeTimeFormat("pl-PL", { + "style": "long", +}); + +assert.sameValue(typeof rtf.format, "function", "format should be supported"); + +for (const [unitArgument, expected] of Object.entries(units)) { + assert.sameValue(rtf.format(1000, unitArgument), `za 1\u00a0000 ${expected.many}`); + assert.sameValue(rtf.format(10, unitArgument), `za 10 ${expected.many}`); + assert.sameValue(rtf.format(2, unitArgument), `za 2 ${expected.few}`); + assert.sameValue(rtf.format(1, unitArgument), `za 1 ${expected.one}`); + assert.sameValue(rtf.format(0, unitArgument), `za 0 ${expected.many}`); + assert.sameValue(rtf.format(-0, unitArgument), `0 ${expected.many} temu`); + assert.sameValue(rtf.format(-1, unitArgument), `1 ${expected.one} temu`); + assert.sameValue(rtf.format(-2, unitArgument), `2 ${expected.few} temu`); + assert.sameValue(rtf.format(-10, unitArgument), `10 ${expected.many} temu`); + assert.sameValue(rtf.format(-1000, unitArgument), `1\u00a0000 ${expected.many} temu`); +} diff --git a/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-narrow.js b/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-narrow.js new file mode 100644 index 0000000000000000000000000000000000000000..7fe3581572d33f48b3a4eca3749eee25c44d04f1 --- /dev/null +++ b/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-narrow.js @@ -0,0 +1,60 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat.prototype.format +description: Checks the behavior of Intl.RelativeTimeFormat.prototype.format() in Polish. +features: [Intl.RelativeTimeFormat] +locale: [pl-PL] +---*/ + +function always(s) { + return { + "many": s, + "few": s, + "one": s, + } +} + +// https://www.unicode.org/cldr/charts/33/summary/pl.html#1419 +const units = { + "second": always("s"), + "minute": always("min"), + "hour": always("g."), + "day": { + "many": "dni", + "few": "dni", + "one": "dzień", + }, + "week": { + "many": "tyg.", + "few": "tyg.", + "one": "tydz.", + }, + "month": always("mies."), + "quarter": always("kw."), + "year": { + "many": "lat", + "few": "lata", + "one": "rok", + }, +}; + +const rtf = new Intl.RelativeTimeFormat("pl-PL", { + "style": "narrow", +}); + +assert.sameValue(typeof rtf.format, "function", "format should be supported"); + +for (const [unitArgument, expected] of Object.entries(units)) { + assert.sameValue(rtf.format(1000, unitArgument), `za 1\u00a0000 ${expected.many}`); + assert.sameValue(rtf.format(10, unitArgument), `za 10 ${expected.many}`); + assert.sameValue(rtf.format(2, unitArgument), `za 2 ${expected.few}`); + assert.sameValue(rtf.format(1, unitArgument), `za 1 ${expected.one}`); + assert.sameValue(rtf.format(0, unitArgument), `za 0 ${expected.many}`); + assert.sameValue(rtf.format(-0, unitArgument), `0 ${expected.many} temu`); + assert.sameValue(rtf.format(-1, unitArgument), `1 ${expected.one} temu`); + assert.sameValue(rtf.format(-2, unitArgument), `2 ${expected.few} temu`); + assert.sameValue(rtf.format(-10, unitArgument), `10 ${expected.many} temu`); + assert.sameValue(rtf.format(-1000, unitArgument), `1\u00a0000 ${expected.many} temu`); +} diff --git a/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-short.js b/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-short.js new file mode 100644 index 0000000000000000000000000000000000000000..357d55b8ca3e5cabcac08d02d2a5375957650dcf --- /dev/null +++ b/test/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-short.js @@ -0,0 +1,60 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat.prototype.format +description: Checks the behavior of Intl.RelativeTimeFormat.prototype.format() in Polish. +features: [Intl.RelativeTimeFormat] +locale: [pl-PL] +---*/ + +function always(s) { + return { + "many": s, + "few": s, + "one": s, + } +} + +// https://www.unicode.org/cldr/charts/33/summary/pl.html#1419 +const units = { + "second": always("s"), + "minute": always("min"), + "hour": always("g."), + "day": { + "many": "dni", + "few": "dni", + "one": "dzień", + }, + "week": { + "many": "tyg.", + "few": "tyg.", + "one": "tydz.", + }, + "month": always("mies."), + "quarter": always("kw."), + "year": { + "many": "lat", + "few": "lata", + "one": "rok", + }, +}; + +const rtf = new Intl.RelativeTimeFormat("pl-PL", { + "style": "short", +}); + +assert.sameValue(typeof rtf.format, "function", "format should be supported"); + +for (const [unitArgument, expected] of Object.entries(units)) { + assert.sameValue(rtf.format(1000, unitArgument), `za 1\u00a0000 ${expected.many}`); + assert.sameValue(rtf.format(10, unitArgument), `za 10 ${expected.many}`); + assert.sameValue(rtf.format(2, unitArgument), `za 2 ${expected.few}`); + assert.sameValue(rtf.format(1, unitArgument), `za 1 ${expected.one}`); + assert.sameValue(rtf.format(0, unitArgument), `za 0 ${expected.many}`); + assert.sameValue(rtf.format(-0, unitArgument), `0 ${expected.many} temu`); + assert.sameValue(rtf.format(-1, unitArgument), `1 ${expected.one} temu`); + assert.sameValue(rtf.format(-2, unitArgument), `2 ${expected.few} temu`); + assert.sameValue(rtf.format(-10, unitArgument), `10 ${expected.many} temu`); + assert.sameValue(rtf.format(-1000, unitArgument), `1\u00a0000 ${expected.many} temu`); +} diff --git a/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-long.js b/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-long.js new file mode 100644 index 0000000000000000000000000000000000000000..49d43f7482baa1d5d26cef62e55a2927436c32ce --- /dev/null +++ b/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-long.js @@ -0,0 +1,123 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat.prototype.format +description: Checks the behavior of Intl.RelativeTimeFormat.prototype.format() in Polish. +features: [Intl.RelativeTimeFormat] +locale: [pl-PL] +---*/ + +function verifyFormatParts(actual, expected, message) { + assert.sameValue(actual.length, expected.length, `${message}: length`); + + for (let i = 0; i < actual.length; ++i) { + assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`); + assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`); + assert.sameValue(actual[i].unit, expected[i].unit, `${message}: parts[${i}].unit`); + } +} + +function regular(s) { + return { + "many": s, + "few": s + "y", + "one": s + "ę", + } +} + +// https://www.unicode.org/cldr/charts/33/summary/pl.html#1419 +const units = { + "second": regular("sekund"), + "minute": regular("minut"), + "hour": regular("godzin"), + "day": { + "many": "dni", + "few": "dni", + "one": "dzień", + }, + "week": { + "many": "tygodni", + "few": "tygodnie", + "one": "tydzień", + }, + "month": { + 1000: "miesięcy", + "many": "miesięcy", + "few": "miesiące", + "one": "miesiąc", + }, + "quarter": { + "many": "kwartałów", + "few": "kwartały", + "one": "kwartał", + }, + "year": { + "many": "lat", + "few": "lata", + "one": "rok", + }, +}; + +const rtf = new Intl.RelativeTimeFormat("pl-PL", { + "style": "long", +}); + +assert.sameValue(typeof rtf.formatToParts, "function", "formatToParts should be supported"); + +for (const [unitArgument, expected] of Object.entries(units)) { + verifyFormatParts(rtf.formatToParts(1000, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "1\u00a0000", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(1000, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(10, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "10", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(10, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(2, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "2", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.few}` }, + ], `formatToParts(2, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(1, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "1", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.one}` }, + ], `formatToParts(1, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(0, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "0", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(0, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-0, unitArgument), [ + { "type": "integer", "value": "0", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-0, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-1, unitArgument), [ + { "type": "integer", "value": "1", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.one} temu` }, + ], `formatToParts(-1, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-2, unitArgument), [ + { "type": "integer", "value": "2", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.few} temu` }, + ], `formatToParts(-2, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-10, unitArgument), [ + { "type": "integer", "value": "10", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-10, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-1000, unitArgument), [ + { "type": "integer", "value": "1\u00a0000", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-1000, ${unitArgument})`); +} diff --git a/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-narrow.js b/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-narrow.js new file mode 100644 index 0000000000000000000000000000000000000000..cdf74d3106e1465788e599896a592ba3bec7ea5d --- /dev/null +++ b/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-narrow.js @@ -0,0 +1,114 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat.prototype.format +description: Checks the behavior of Intl.RelativeTimeFormat.prototype.format() in Polish. +features: [Intl.RelativeTimeFormat] +locale: [pl-PL] +---*/ + +function verifyFormatParts(actual, expected, message) { + assert.sameValue(actual.length, expected.length, `${message}: length`); + + for (let i = 0; i < actual.length; ++i) { + assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`); + assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`); + assert.sameValue(actual[i].unit, expected[i].unit, `${message}: parts[${i}].unit`); + } +} + +function always(s) { + return { + "many": s, + "few": s, + "one": s, + } +} + +// https://www.unicode.org/cldr/charts/33/summary/pl.html#1419 +const units = { + "second": always("sek."), + "minute": always("min"), + "hour": always("godz."), + "day": { + "many": "dni", + "few": "dni", + "one": "dzień", + }, + "week": { + "many": "tyg.", + "few": "tyg.", + "one": "tydz.", + }, + "month": always("mies."), + "quarter": always("kw."), + "year": { + "many": "lat", + "few": "lata", + "one": "rok", + }, +}; + +const rtf = new Intl.RelativeTimeFormat("pl-PL", { + "style": "short", +}); + +assert.sameValue(typeof rtf.formatToParts, "function", "formatToParts should be supported"); + +for (const [unitArgument, expected] of Object.entries(units)) { + verifyFormatParts(rtf.formatToParts(1000, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "1\u00a0000", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(1000, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(10, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "10", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(10, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(2, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "2", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.few}` }, + ], `formatToParts(2, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(1, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "1", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.one}` }, + ], `formatToParts(1, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(0, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "0", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(0, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-0, unitArgument), [ + { "type": "integer", "value": "0", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-0, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-1, unitArgument), [ + { "type": "integer", "value": "1", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.one} temu` }, + ], `formatToParts(-1, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-2, unitArgument), [ + { "type": "integer", "value": "2", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.few} temu` }, + ], `formatToParts(-2, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-10, unitArgument), [ + { "type": "integer", "value": "10", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-10, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-1000, unitArgument), [ + { "type": "integer", "value": "1\u00a0000", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-1000, ${unitArgument})`); +} diff --git a/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-short.js b/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-short.js new file mode 100644 index 0000000000000000000000000000000000000000..cdf74d3106e1465788e599896a592ba3bec7ea5d --- /dev/null +++ b/test/intl402/RelativeTimeFormat/prototype/formatToParts/pl-pl-style-short.js @@ -0,0 +1,114 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.RelativeTimeFormat.prototype.format +description: Checks the behavior of Intl.RelativeTimeFormat.prototype.format() in Polish. +features: [Intl.RelativeTimeFormat] +locale: [pl-PL] +---*/ + +function verifyFormatParts(actual, expected, message) { + assert.sameValue(actual.length, expected.length, `${message}: length`); + + for (let i = 0; i < actual.length; ++i) { + assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`); + assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`); + assert.sameValue(actual[i].unit, expected[i].unit, `${message}: parts[${i}].unit`); + } +} + +function always(s) { + return { + "many": s, + "few": s, + "one": s, + } +} + +// https://www.unicode.org/cldr/charts/33/summary/pl.html#1419 +const units = { + "second": always("sek."), + "minute": always("min"), + "hour": always("godz."), + "day": { + "many": "dni", + "few": "dni", + "one": "dzień", + }, + "week": { + "many": "tyg.", + "few": "tyg.", + "one": "tydz.", + }, + "month": always("mies."), + "quarter": always("kw."), + "year": { + "many": "lat", + "few": "lata", + "one": "rok", + }, +}; + +const rtf = new Intl.RelativeTimeFormat("pl-PL", { + "style": "short", +}); + +assert.sameValue(typeof rtf.formatToParts, "function", "formatToParts should be supported"); + +for (const [unitArgument, expected] of Object.entries(units)) { + verifyFormatParts(rtf.formatToParts(1000, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "1\u00a0000", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(1000, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(10, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "10", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(10, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(2, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "2", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.few}` }, + ], `formatToParts(2, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(1, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "1", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.one}` }, + ], `formatToParts(1, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(0, unitArgument), [ + { "type": "literal", "value": "za " }, + { "type": "integer", "value": "0", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many}` }, + ], `formatToParts(0, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-0, unitArgument), [ + { "type": "integer", "value": "0", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-0, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-1, unitArgument), [ + { "type": "integer", "value": "1", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.one} temu` }, + ], `formatToParts(-1, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-2, unitArgument), [ + { "type": "integer", "value": "2", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.few} temu` }, + ], `formatToParts(-2, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-10, unitArgument), [ + { "type": "integer", "value": "10", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-10, ${unitArgument})`); + + verifyFormatParts(rtf.formatToParts(-1000, unitArgument), [ + { "type": "integer", "value": "1\u00a0000", "unit": unitArgument }, + { "type": "literal", "value": ` ${expected.many} temu` }, + ], `formatToParts(-1000, ${unitArgument})`); +}