e6d208b6a0
Add tests for 'quarter' unit in Intl.RelativeTimeFormat#format Bug: v8:7869 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Change-Id: I03077d5d89e1b9e459af0c31b5bf7378d9c4a1f0 Reviewed-on: https://chromium-review.googlesource.com/1244758 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#56249}
29 lines
953 B
JavaScript
29 lines
953 B
JavaScript
// Copyright 2018 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-relative-time-format
|
|
|
|
// Check plural w/ formatToParts
|
|
// http://tc39.github.io/proposal-intl-relative-time/
|
|
|
|
let rtf = new Intl.RelativeTimeFormat();
|
|
|
|
// Test 1.4.4 Intl.RelativeTimeFormat.prototype.formatToParts( value, unit )
|
|
function verifyElement(part, expectedUnit) {
|
|
assertEquals(true, part.type == 'literal' || part.type == 'integer');
|
|
assertEquals('string', typeof part.value);
|
|
if (part.type == 'integer') {
|
|
assertEquals('string', typeof part.unit);
|
|
assertEquals(expectedUnit, part.unit);
|
|
}
|
|
};
|
|
|
|
['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second'].forEach(
|
|
function(unit) {
|
|
rtf.formatToParts(100, unit + 's').forEach(
|
|
function(part) {
|
|
verifyElement(part, unit);
|
|
});
|
|
});
|