Skip to content

Commit

Permalink
multi nesting test failing
Browse files Browse the repository at this point in the history
  • Loading branch information
trueberryless committed Jan 15, 2025
1 parent 8255273 commit 6ed6e0f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const nesting = [
'\'One "sentence". Two sentences.\''
].join('\n\n')

const multiNesting = [
'A sentence “with ‘multi «mutli “nested ‘quotes’”»’”.', // correct case when {smart: ['“”', '‘’', '«»']} (TODO: REMOVE THESE COMMENTS!!!)
'A sentence ‘with “multi «mutli ‘nested “quotes”’»”’.', // '“”' and '‘’' are swapped -> wrong
'A sentence «with “multi ‘mutli «nested “quotes”»’”».' // that's how it is currently evalutes to be right -> but it should be wrong
].join('\n\n')

const moreApostrophes = 'Isn’t it funny? It was acceptable in the ’80s'

const soManyOpenings = '“Open this, ‘Open that, “open here, ‘open there'
Expand Down Expand Up @@ -195,6 +201,39 @@ test('retextQuotes', async function (t) {
}
)

await t.test(
'should detect nesting with more than 2 defined quotes correctly',
async function () {
const file = await retext()
.use(retextQuotes, {smart: ['“”', '‘’', '«»']})
.process(multiNesting)

console.log(file.messages.map(String))

assert.deepEqual(file.messages.map(String), [
'3:12-3:13: Unexpected `‘` at this level of nesting, expected `“`',
'3:18-3:19: Unexpected `“` at this level of nesting, expected `‘`',
'3:32-3:33: Unexpected `‘` at this level of nesting, expected `“`',
'3:40-3:41: Unexpected `“` at this level of nesting, expected `‘`',
'3:47-3:48: Unexpected `”` at this level of nesting, expected `’`',
'3:48-3:49: Unexpected `’` at this level of nesting, expected `”`',
'3:50-3:51: Unexpected `”` at this level of nesting, expected `’`',
'3:51-3:52: Unexpected `’` at this level of nesting, expected `”`',

'5:12-5:13: Unexpected `«` at this level of nesting, expected `“`',
'5:18-5:19: Unexpected `“` at this level of nesting, expected `‘`',
'5:25-5:26: Unexpected `‘` at this level of nesting, expected `«`',
'5:32-5:33: Unexpected `«` at this level of nesting, expected `“`',
'5:40-5:41: Unexpected `“` at this level of nesting, expected `‘`',
'5:47-5:48: Unexpected `”` at this level of nesting, expected `’`',
'5:48-5:49: Unexpected `»` at this level of nesting, expected `”`',
'5:49-5:50: Unexpected `’` at this level of nesting, expected `»`',
'5:50-5:51: Unexpected `”` at this level of nesting, expected `’`',
'5:51-5:52: Unexpected `»` at this level of nesting, expected `”`'
])
}
)

await t.test('should deal with funky nesting', async function () {
const file = await retext().use(retextQuotes).process(soManyOpenings)

Expand Down

0 comments on commit 6ed6e0f

Please sign in to comment.