summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-08-30 10:18:13 -0400
committerTim Flynn <trflynn89@pm.me>2022-08-30 14:26:11 -0400
commit765d01667043397cdef3642da0f59bee193a2975 (patch)
tree007189d25fa45f4ac92a2d560affb5ff1ad0d9f0 /Userland
parent2fb332da7b10a3249be00cd8e947e1fbeb997cb2 (diff)
downloadserenity-765d01667043397cdef3642da0f59bee193a2975.zip
LibJS: Default to 0 for DurationFormat's fractionalDigits option
This is a normative change in the Intl.DurationFormat proposal. See: https://github.com/tc39/proposal-intl-duration-format/commit/ac7e184
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.format.js4
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.formatToParts.js4
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.resolvedOptions.js2
4 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
index 9d27011d7c..fceeda7b66 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
@@ -134,8 +134,8 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
}
}
- // 18. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined).
- duration_format->set_fractional_digits(Optional<u8>(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, {}))));
+ // 18. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, 0).
+ duration_format->set_fractional_digits(Optional<u8>(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, 0))));
// 19. Return durationFormat.
return duration_format;
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.format.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.format.js
index 89edf2322a..a2b45f04a0 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.format.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.format.js
@@ -32,7 +32,7 @@ describe("correct behavior", () => {
"1y, 2m, 3w, 3d, 4h, 5m, 6s, 7ms, 8μs, and 9ns"
);
expect(new Intl.DurationFormat("en", { style: "digital" }).format(duration)).toBe(
- "1y, 2m, 3w, 3d, and 4:05:06.007"
+ "1y, 2m, 3w, 3d, and 4:05:06"
);
expect(
new Intl.DurationFormat("en", {
@@ -52,7 +52,7 @@ describe("correct behavior", () => {
"1 J, 2 M, 3 W, 3 T, 4 Std., 5 Min., 6 Sek., 7 ms, 8 μs und 9 ns"
);
expect(new Intl.DurationFormat("de", { style: "digital" }).format(duration)).toBe(
- "1 J, 2 M, 3 W, 3 T und 4:05:06,007"
+ "1 J, 2 M, 3 W, 3 T und 4:05:06"
);
expect(
new Intl.DurationFormat("de", {
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.formatToParts.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.formatToParts.js
index c6a15383f7..45b553c715 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.formatToParts.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.formatToParts.js
@@ -131,7 +131,7 @@ describe("correct behavior", () => {
{ type: "literal", value: ", " },
{ type: "element", value: "3d" },
{ type: "literal", value: ", and " },
- { type: "element", value: "4:05:06.007" },
+ { type: "element", value: "4:05:06" },
]
);
expect(
@@ -233,7 +233,7 @@ describe("correct behavior", () => {
{ type: "literal", value: ", " },
{ type: "element", value: "3 T" },
{ type: "literal", value: " und " },
- { type: "element", value: "4:05:06,007" },
+ { type: "element", value: "4:05:06" },
]
);
expect(
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.resolvedOptions.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.resolvedOptions.js
index bfd6e10083..1ac210479f 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.resolvedOptions.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/DurationFormat/DurationFormat.prototype.resolvedOptions.js
@@ -284,7 +284,7 @@ describe("correct behavior", () => {
test("fractionalDigits", () => {
const en1 = new Intl.DurationFormat("en");
- expect(en1.resolvedOptions().fractionalDigits).toBeUndefined();
+ expect(en1.resolvedOptions().fractionalDigits).toBe(0);
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(fractionalDigits => {
const en2 = new Intl.DurationFormat("en", { fractionalDigits: fractionalDigits });