summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-01-30 12:45:16 -0500
committerTim Flynn <trflynn89@pm.me>2023-01-30 14:10:07 -0500
commite74e8381d52813ebb4a5a48e568d4edbae74d559 (patch)
tree942b819aacf709bc4f24332d47963dc0b5cf8d06 /Userland/Libraries/LibJS/Tests
parent5c1038e54fcf4a7de0b5b62ca5f99d521c4a12ff (diff)
downloadserenity-e74e8381d52813ebb4a5a48e568d4edbae74d559.zip
LibJS: Allow "approximately" results to differ in plural form
This is a normative change in the Intl.NumberFormat V3 spec. See: https://github.com/tc39/proposal-intl-numberformat-v3/commit/08f599b Note that this didn't seem to actually affect our implementation. The Unicode spec states: https://www.unicode.org/reports/tr35/tr35-53/tr35-numbers.html#Plural_Ranges "If there is no value for a <start,end> pair, the default result is end" Therefore, our implementation did not have the behavior noted by the issue this normative change addressed: const pr = new Intl.PluralRules("en-US"); pr.selectRange(1, 1); // Is "other", should be "one" Our implementation already returned "one" here because there is no such <start=one, end=one> value in the CLDR for en-US. Thus, we already returned the end value of "one".
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Intl/PluralRules/PluralRules.prototype.selectRange.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/PluralRules/PluralRules.prototype.selectRange.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/PluralRules/PluralRules.prototype.selectRange.js
index 716fbd7f5a..76619fafa6 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/Intl/PluralRules/PluralRules.prototype.selectRange.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/PluralRules/PluralRules.prototype.selectRange.js
@@ -39,11 +39,13 @@ describe("errors", () => {
describe("correct behavior", () => {
test("basic functionality", () => {
const en = new Intl.PluralRules("en");
+ expect(en.selectRange(1, 1)).toBe("one"); // one + one = one
expect(en.selectRange(1, 2)).toBe("other"); // one + other = other
expect(en.selectRange(0, 1)).toBe("other"); // other + one = other
expect(en.selectRange(2, 3)).toBe("other"); // other + other = other
const pl = new Intl.PluralRules("pl");
+ expect(pl.selectRange(1, 1)).toBe("one"); // one + one = one
expect(pl.selectRange(1, 2)).toBe("few"); // one + few = few
expect(pl.selectRange(1, 5)).toBe("many"); // one + many = many
expect(pl.selectRange(1, 3.14)).toBe("other"); // one + other = other