250b2e2972
Implement ALL in NumberFormat v3 except: * Add PluralRules.prototype.selectRange * Add NumberFormat.prototype.formatRange(ToParts)? (which will be reviewed in later CLs) * Change NumberFormat.prototpe.resolvedOptions https://github.com/tc39/proposal-intl-numberformat-v3 https://chromestatus.com/guide/edit/5707621009981440 Design Doc: https://docs.google.com/document/d/19jAogPBb6W4Samt8NWGZKu47iv0_KoQhBvLgQH3xvr8/edit Bug: v8:10776 Change-Id: I1acf833ec25fb05437cb0b21c5510bb99d1c4583 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3405649 Reviewed-by: Shu-yu Guo <syg@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/main@{#78878}
25 lines
1.0 KiB
JavaScript
25 lines
1.0 KiB
JavaScript
// Copyright 2021 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.
|
|
|
|
// Flags: --harmony-intl-number-format-v3
|
|
|
|
let defaultFmt = new Intl.NumberFormat("en",
|
|
{ minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
let autoFmt = new Intl.NumberFormat("en",
|
|
{ minimumFractionDigits: 2, maximumFractionDigits: 2,
|
|
trailingZeroDisplay: 'auto'});
|
|
let stripIfIntegerFmt = new Intl.NumberFormat("en",
|
|
{ minimumFractionDigits: 2, maximumFractionDigits: 2,
|
|
trailingZeroDisplay: 'stripIfInteger'});
|
|
|
|
assertEquals("3.14", defaultFmt.format(3.1411));
|
|
assertEquals("3.14", autoFmt.format(3.1411));
|
|
assertEquals("3.14", stripIfIntegerFmt.format(3.1411));
|
|
assertEquals("3.00", defaultFmt.format(3.001411));
|
|
assertEquals("3.00", autoFmt.format(3.001411));
|
|
assertEquals("3", stripIfIntegerFmt.format(3.001411));
|
|
assertEquals("3.00", defaultFmt.format(2.999411));
|
|
assertEquals("3.00", autoFmt.format(2.999411));
|
|
assertEquals("3", stripIfIntegerFmt.format(2.999411));
|