Skip to content

Commit eb8d16f

Browse files
committed
feature: ExpressionStatement: inside IfStatement
1 parent b84a60f commit eb8d16f

5 files changed

Lines changed: 28 additions & 16 deletions

File tree

lib/tokenize/statements/expression-statement/comments.js renamed to lib/tokenize/statements/expression-statement/expression-statement-comments.js

File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
const {createTest} = require('#test');
4+
const {parse, transform} = require('putout');
5+
6+
const {print} = require('@putout/printer');
7+
const {test, fixture} = createTest(__dirname);
8+
9+
test('printer: tokenizer: statement: expression: leading comment', (t) => {
10+
t.print(fixture.expressionLeadingComment);
11+
t.end();
12+
});
13+
14+
test('printer: tokenizer: statement: expression: inside arrow: leading comment', (t) => {
15+
t.print(fixture.expressionInsideArrowLeadingComment);
16+
t.end();
17+
});
18+
19+
test('printer: tokenizer: statement: expression: inside body: leading comment', (t) => {
20+
t.print(fixture.expressionInsideBodyLeadingComment);
21+
t.end();
22+
});

lib/tokenize/statements/expression-statement/expression-statement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const {isInsideAssignNextAssignFunction} = require('./is-inside-assign-next-assi
1919
const {
2020
printLeadingCommentLine,
2121
printLeadingCommentBlock,
22-
} = require('./comments');
22+
} = require('./expression-statement-comments');
2323

2424
const isCommentBlock = (a) => a?.type === 'CommentBlock';
2525

lib/tokenize/statements/expression-statement/expression-statement.spec.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,6 @@ test('printer: tokenizer: statement: expression: after call: indent', (t) => {
5656
t.end();
5757
});
5858

59-
test('printer: tokenizer: statement: expression: leading comment', (t) => {
60-
t.print(fixture.expressionLeadingComment);
61-
t.end();
62-
});
63-
64-
test('printer: tokenizer: statement: expression: inside arrow: leading comment', (t) => {
65-
t.print(fixture.expressionInsideArrowLeadingComment);
66-
t.end();
67-
});
68-
69-
test('printer: tokenizer: statement: expression: inside body: leading comment', (t) => {
70-
t.print(fixture.expressionInsideBodyLeadingComment);
71-
t.end();
72-
});
73-
7459
test('printer: tokenizer: statement: expression: before if', (t) => {
7560
const source = fixture.expressionBeforeIf;
7661
const ast = parse(source);

lib/tokenize/statements/expression-statement/fixture/expression-inside-body-leading-comment.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ for (a of b) {
22
// hello
33
c = 5;
44
continue;
5+
}
6+
7+
if (error) {
8+
// @ts-ignore
9+
expect(error.message).toMatch('No package name provided in package.json');
510
}

0 commit comments

Comments
 (0)