v8/test/intl/regress-9475.js
Frank Tang 5bd577834b [Intl] Adding volume units.
Add 'fluid-ounce','gallon', 'liter', and 'milliliter'
Also roll ICU to 682a2309

Sync with https://github.com/tc39/proposal-unified-intl-numberformat/pull/48


Bug: v8:9475
Change-Id: If45a20f17f5973b860893b0f70e724cc93c6550a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1699759
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Jungshik Shin <jshin@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62903}
2019-07-24 17:16:46 +00:00

63 lines
1.1 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.
// Flags: --harmony-intl-numberformat-unified
// Test format of all valid units won't throw exception.
let validList = [
// IsSanctionedSimpleUnitIdentifier
'acre',
'bit',
'byte',
'celsius',
'centimeter',
'day',
'degree',
'fahrenheit',
'fluid-ounce',
'foot',
'gallon',
'gigabit',
'gigabyte',
'gram',
'hectare',
'hour',
'inch',
'kilobit',
'kilobyte',
'kilogram',
'kilometer',
'liter',
'megabit',
'megabyte',
'meter',
'mile',
'mile-scandinavian',
'millimeter',
'milliliter',
'millisecond',
'minute',
'month',
'ounce',
'percent',
'petabyte',
'pound',
'second',
'stone',
'terabit',
'terabyte',
'week',
'yard',
'year',
// -per- in IsWellFormedUnitIdentifier
'liter-per-kilometer',
'mile-per-gallon',
];
for (let unit of validList) {
let nf = new Intl.NumberFormat("en", {style: "unit", unit});
assertDoesNotThrow(() => nf.format(123.45),
"unit: '" + unit + "' should not throw");
}