-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): add onInsertedSemicolon option
- Loading branch information
dmichon
committed
Mar 4, 2024
1 parent
755876f
commit 557a893
Showing
4 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as t from 'assert'; | ||
import { parseScript } from '../../../src/meriyah'; | ||
|
||
describe('Miscellaneous - oninsertedSemicolon', () => { | ||
it('invokes the callback when automatic semicolon insertion occurs', () => { | ||
const semicolons: number[] = []; | ||
const lines = ['"use strict"', 'self.a;', 'self.b']; | ||
const input = lines.join('\n'); | ||
parseScript(input, { | ||
onInsertedSemicolon: (pos) => semicolons.push(pos) | ||
}); | ||
t.deepEqual(semicolons, [lines[0].length, input.length]); | ||
}); | ||
}); |