2022-12-23 09:49:11 +09:00
|
|
|
// Flags: --expose-internals
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const { strictEqual } = require('node:assert');
|
|
|
|
const { formatList } = require('internal/errors');
|
|
|
|
|
|
|
|
if (!common.hasIntl) common.skip('missing Intl');
|
|
|
|
|
|
|
|
{
|
|
|
|
const and = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' });
|
|
|
|
const or = new Intl.ListFormat('en', { style: 'long', type: 'disjunction' });
|
|
|
|
|
2023-09-29 13:04:38 +02:00
|
|
|
const input = ['apple', 'banana', 'orange', 'pear'];
|
2022-12-23 09:49:11 +09:00
|
|
|
for (let i = 0; i < input.length; i++) {
|
|
|
|
const slicedInput = input.slice(0, i);
|
|
|
|
strictEqual(formatList(slicedInput), and.format(slicedInput));
|
|
|
|
strictEqual(formatList(slicedInput, 'or'), or.format(slicedInput));
|
|
|
|
}
|
|
|
|
}
|