summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfEven.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfEven.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfEven.js')
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfEven.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfEven.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfEven.js
new file mode 100644
index 0000000000..84d09a9bae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfEven.js
@@ -0,0 +1,40 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plaindatetime.prototype.tostring
+description: halfEven value for roundingMode option
+features: [Temporal]
+---*/
+
+const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 123, 987, 500);
+
+const result1 = datetime.toString({ smallestUnit: "microsecond", roundingMode: "halfEven" });
+assert.sameValue(result1, "2000-05-02T12:34:56.123988",
+ "roundingMode is halfEven (with 6 digits from smallestUnit)");
+
+const result2 = datetime.toString({ fractionalSecondDigits: 6, roundingMode: "halfEven" });
+assert.sameValue(result2, "2000-05-02T12:34:56.123988",
+ "roundingMode is halfEven (with 6 digits from fractionalSecondDigits)");
+
+const result3 = datetime.toString({ smallestUnit: "millisecond", roundingMode: "halfEven" });
+assert.sameValue(result3, "2000-05-02T12:34:56.124",
+ "roundingMode is halfEven (with 3 digits from smallestUnit)");
+
+const result4 = datetime.toString({ fractionalSecondDigits: 3, roundingMode: "halfEven" });
+assert.sameValue(result4, "2000-05-02T12:34:56.124",
+ "roundingMode is halfEven (with 3 digits from fractionalSecondDigits)");
+
+const result5 = datetime.toString({ smallestUnit: "second", roundingMode: "halfEven" });
+assert.sameValue(result5, "2000-05-02T12:34:56",
+ "roundingMode is halfEven (with 0 digits from smallestUnit)");
+
+const result6 = datetime.toString({ fractionalSecondDigits: 0, roundingMode: "halfEven" });
+assert.sameValue(result6, "2000-05-02T12:34:56",
+ "roundingMode is halfEven (with 0 digits from fractionalSecondDigits)");
+
+const result7 = datetime.toString({ smallestUnit: "minute", roundingMode: "halfEven" });
+assert.sameValue(result7, "2000-05-02T12:35", "roundingMode is halfEven (round to minute)");
+
+reportCompare(0, 0);