Skip to content

Commit

Permalink
Simplify and remove empty line after debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbonnet committed Apr 5, 2021
1 parent e7e9d7c commit 47bd826
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/astring.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ export const GENERATOR = {
}),
ForOfStatement: ForInStatement,
DebuggerStatement(node, state) {
state.write('debugger;' + state.lineEnd, node)
state.write('debugger;', node)
},
FunctionDeclaration: (FunctionDeclaration = function (node, state) {
state.write(
Expand Down
16 changes: 4 additions & 12 deletions src/tests/astring.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,15 @@ test('Comment generation', (assert) => {
})

test('Source map generation', (assert) => {
const files = ['syntax', 'sourcemap-cases']
.map((subdir) => path.join(FIXTURES_FOLDER, subdir))
.flatMap((dir) =>
fs
.readdirSync(dir)
.sort()
.map((file) => path.join(dir, file)),
)

const dirname = path.join(FIXTURES_FOLDER, 'syntax')
const files = fs.readdirSync(dirname).sort()
const options = {
ecmaVersion,
sourceType: 'module',
locations: true,
}
files.forEach((filename) => {
const code = readFile(filename)
const code = readFile(path.join(dirname, filename))
const sourceMap = {
mappings: [],
_file: filename,
Expand All @@ -161,10 +154,9 @@ test('Source map generation', (assert) => {
generate(ast, {
sourceMap,
})

assert.true(
sourceMap.mappings.length > 0,
`Expected ${path.basename(filename)} to have mappings`,
`Expect ${path.basename(filename)} to have mappings`,
)
})
})
Expand Down
2 changes: 0 additions & 2 deletions src/tests/fixtures/sourcemap-cases/debugger.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/tests/fixtures/sourcemap-cases/strings.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/tests/fixtures/syntax/debugger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
debugger;
"this string should be mapped to the second line";

0 comments on commit 47bd826

Please sign in to comment.