v8/test/intl/regress-10438.js
Frank Tang 6f356f799b [Intl] Remove flag for fractionalSecondDigits
DateTimeFormat's fractionalSecondDigits shipped in M84, so we
can drop the --harmony_intl_dateformat_fractional_second_digits
flag now.

Bug: v8:10485
Change-Id: If7a1a8599722073d7382635219a6fb46cdc47474
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2311410
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69007}
2020-07-22 16:57:43 +00:00

54 lines
1.7 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,
"Invalid option : timeStyle");
assertThrows(
() => (new Intl.DateTimeFormat(
"en", {dateStyle: "short", fractionalSecondDigits: 3})),
TypeError,
"Invalid option : dateStyle");