1// Flags: --expose-internals
2'use strict';
3
4const common = require('../common');
5const { strictEqual } = require('node:assert');
6const { formatList } = require('internal/errors');
7
8if (!common.hasIntl) common.skip('missing Intl');
9
10{
11  const and = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' });
12  const or = new Intl.ListFormat('en', { style: 'long', type: 'disjunction' });
13
14  const input = ['apple', 'banana', 'orange'];
15  for (let i = 0; i < input.length; i++) {
16    const slicedInput = input.slice(0, i);
17    strictEqual(formatList(slicedInput), and.format(slicedInput));
18    strictEqual(formatList(slicedInput, 'or'), or.format(slicedInput));
19  }
20}
21