mirror of
https://github.com/nodejs/node.git
synced 2025-05-17 02:30:33 +00:00

PR-URL: https://github.com/nodejs/node/pull/35700 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
assertThrows(
|
|
() => (new Intl.DateTimeFormat("en", {fractionalSecondDigits: 0})),
|
|
RangeError,
|
|
"fractionalSecondDigits value is out of range.");
|
|
|
|
assertThrows(
|
|
() => (new Intl.DateTimeFormat("en", {fractionalSecondDigits: 4})),
|
|
RangeError,
|
|
"fractionalSecondDigits value is out of range.");
|
|
|
|
assertEquals(
|
|
1,
|
|
(new Intl.DateTimeFormat("en", {fractionalSecondDigits: 1}))
|
|
.resolvedOptions().fractionalSecondDigits);
|
|
|
|
assertEquals(
|
|
2,
|
|
(new Intl.DateTimeFormat("en", {fractionalSecondDigits: 2}))
|
|
.resolvedOptions().fractionalSecondDigits);
|
|
|
|
assertEquals(
|
|
3,
|
|
(new Intl.DateTimeFormat("en", {fractionalSecondDigits: 3}))
|
|
.resolvedOptions().fractionalSecondDigits);
|
|
|
|
// When timeStyle and dateStyle is not present, GetNumberOption will fallback
|
|
// to undefined as default regardless fractionalSecondDigits is present in the option or
|
|
// not.
|
|
assertEquals(
|
|
undefined,
|
|
(new Intl.DateTimeFormat()).resolvedOptions().fractionalSecondDigits);
|
|
|
|
assertEquals(
|
|
undefined,
|
|
(new Intl.DateTimeFormat("en", {fractionalSecondDigits: undefined}))
|
|
.resolvedOptions().fractionalSecondDigits);
|
|
|
|
// When timeStyle or dateStyle is present, we should throw TypeError
|
|
assertThrows(
|
|
() => (new Intl.DateTimeFormat(
|
|
"en", {timeStyle: "short", fractionalSecondDigits: 3})),
|
|
TypeError,
|
|
"Can't set option fractionalSecondDigits when timeStyle is used");
|
|
|
|
assertThrows(
|
|
() => (new Intl.DateTimeFormat(
|
|
"en", {dateStyle: "short", fractionalSecondDigits: 3})),
|
|
TypeError,
|
|
"Can't set option fractionalSecondDigits when dateStyle is used");
|