mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 19:37:34 +00:00
LibJS: Use numeric style if the previous style was numeric or 2-digit
This is a normative change in the Intl.DurationFormat proposal. See:
3a46ee3
This commit is contained in:
parent
cab1cce522
commit
127b28c940
2 changed files with 33 additions and 1 deletions
|
@ -252,7 +252,12 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String
|
|||
// i. Set style to digitalBase.
|
||||
style = digital_base;
|
||||
}
|
||||
// c. Else,
|
||||
// c. Else if prevStyle is "numeric" or "2-digit", then
|
||||
else if (previous_style == "numeric"sv || previous_style == "2-digit"sv) {
|
||||
// i. Set style to "numeric".
|
||||
style = "numeric"sv;
|
||||
}
|
||||
// d. Else,
|
||||
else {
|
||||
// i. Set style to baseStyle.
|
||||
style = base_style;
|
||||
|
|
|
@ -266,6 +266,10 @@ describe("normal behavior", () => {
|
|||
}).not.toThrow();
|
||||
});
|
||||
["numeric", "2-digit"].forEach(seconds => {
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { hours: seconds });
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { style: "digital", hours: seconds });
|
||||
}).not.toThrow();
|
||||
|
@ -287,6 +291,10 @@ describe("normal behavior", () => {
|
|||
}).not.toThrow();
|
||||
});
|
||||
["numeric", "2-digit"].forEach(seconds => {
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { minutes: seconds });
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { style: "digital", minutes: seconds });
|
||||
}).not.toThrow();
|
||||
|
@ -308,6 +316,10 @@ describe("normal behavior", () => {
|
|||
}).not.toThrow();
|
||||
});
|
||||
["numeric", "2-digit"].forEach(seconds => {
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { seconds: seconds });
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { style: "digital", seconds: seconds });
|
||||
}).not.toThrow();
|
||||
|
@ -328,6 +340,11 @@ describe("normal behavior", () => {
|
|||
new Intl.DurationFormat("en", { milliseconds: milliseconds });
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { milliseconds: "numeric" });
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { style: "digital", milliseconds: "numeric" });
|
||||
}).not.toThrow();
|
||||
|
@ -347,6 +364,11 @@ describe("normal behavior", () => {
|
|||
new Intl.DurationFormat("en", { microseconds: microseconds });
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { microseconds: "numeric" });
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { style: "digital", microseconds: "numeric" });
|
||||
}).not.toThrow();
|
||||
|
@ -366,6 +388,11 @@ describe("normal behavior", () => {
|
|||
new Intl.DurationFormat("en", { nanoseconds: nanoseconds });
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { nanoseconds: "numeric" });
|
||||
}).not.toThrow();
|
||||
|
||||
expect(() => {
|
||||
new Intl.DurationFormat("en", { style: "digital", nanoseconds: "numeric" });
|
||||
}).not.toThrow();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue