summaryrefslogtreecommitdiff
path: root/deps/v8/test/intl/relative-time-format/format-to-parts-plural.js
blob: 7e5e1b79a627e3cbc14197f9140fd8aa6441b290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// 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);
          });
    });