v8/test/intl/regress-9408.js
Frank Tang 25c11657fc [Intl] Clean up by removing the following flags
harmony_intl_bigint shipped in m76
  harmony_intl_date_format_range shipped in m76
  harmony_intl_datetime_style shipped in m76
  harmony_intl_numberformat_unified shipped in m77

Bug: v8:9272, v8:9273, v8:9274
Change-Id: Icc640e011021e691373bc61725013578b7185e50
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1799263
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63736}
2019-09-12 22:25:41 +00:00

28 lines
1.2 KiB
JavaScript

// Copyright 2019 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.
// Test precision of compact-rounding
let compact = {notation: "compact"};
assertEquals("1.2K", (1234).toLocaleString("en", compact));
assertEquals("12K", (12345).toLocaleString("en", compact));
assertEquals("123K", (123456).toLocaleString("en", compact));
assertEquals("1.2M", (1234567).toLocaleString("en", compact));
assertEquals("54K", (54321).toLocaleString("en", compact));
let compact_no_rounding = {notation: "compact", minimumFractionDigits: 0};
assertEquals("1.234K", (1234).toLocaleString("en", compact_no_rounding));
assertEquals("12.345K", (12345).toLocaleString("en", compact_no_rounding));
assertEquals("123.456K", (123456).toLocaleString("en", compact_no_rounding));
assertEquals("1.235M", (1234567).toLocaleString("en", compact_no_rounding));
assertEquals("54.321K", (54321).toLocaleString("en", compact_no_rounding));
let fmt = new Intl.NumberFormat("en", compact_no_rounding);
assertEquals("1", fmt.format(1));
assertEquals("1K", fmt.format(1000));
assertEquals("1.234K", fmt.format(1234));
assertEquals("1.25K", fmt.format(1250));