xref: /third_party/node/test/parallel/test-error-format-list.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciconst common = require('../common');
51cb0ef41Sopenharmony_ciconst { strictEqual } = require('node:assert');
61cb0ef41Sopenharmony_ciconst { formatList } = require('internal/errors');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciif (!common.hasIntl) common.skip('missing Intl');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci{
111cb0ef41Sopenharmony_ci  const and = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' });
121cb0ef41Sopenharmony_ci  const or = new Intl.ListFormat('en', { style: 'long', type: 'disjunction' });
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  const input = ['apple', 'banana', 'orange'];
151cb0ef41Sopenharmony_ci  for (let i = 0; i < input.length; i++) {
161cb0ef41Sopenharmony_ci    const slicedInput = input.slice(0, i);
171cb0ef41Sopenharmony_ci    strictEqual(formatList(slicedInput), and.format(slicedInput));
181cb0ef41Sopenharmony_ci    strictEqual(formatList(slicedInput, 'or'), or.format(slicedInput));
191cb0ef41Sopenharmony_ci  }
201cb0ef41Sopenharmony_ci}
21

Indexes created Thu Nov 07 10:32:03 CST 2024