|
@@ -7,6 +7,107 @@ import { NodeFactory } from '../../../../src/node/NodeFactory';
|
|
import { NodeUtils } from '../../../../src/node/NodeUtils';
|
|
import { NodeUtils } from '../../../../src/node/NodeUtils';
|
|
|
|
|
|
describe('NodeGuards', () => {
|
|
describe('NodeGuards', () => {
|
|
|
|
+ describe('isIfStatementNodeWithSingleStatementBody', () => {
|
|
|
|
+ describe('truthful checks', () => {
|
|
|
|
+ describe('Variant #1: single statement `consequent`', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.IfStatement = NodeFactory.ifStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isIfStatementNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `IfStatement` node has single statement `consequent`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #2: single statement `alternate`', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.IfStatement = NodeFactory.ifStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isIfStatementNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `IfStatement` node has single statement `alternate`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #3: single statement `consequent` and `alternate`', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.IfStatement = NodeFactory.ifStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isIfStatementNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `IfStatement` node has single statement `consequent` and `alternate`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('false checks', () => {
|
|
|
|
+ describe('Variant #1: multiple statements `consequent` and `alternate`', () => {
|
|
|
|
+ const expectedResult: boolean = false;
|
|
|
|
+ const node: ESTree.IfStatement = NodeFactory.ifStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ])
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isIfStatementNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `IfStatement` node has multiple statements `consequent` and `alternate`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
describe('isNodeWithLexicalScopeStatements', () => {
|
|
describe('isNodeWithLexicalScopeStatements', () => {
|
|
describe('truthful checks', () => {
|
|
describe('truthful checks', () => {
|
|
describe('Variant #1: block statement of function declaration', () => {
|
|
describe('Variant #1: block statement of function declaration', () => {
|
|
@@ -138,6 +239,425 @@ describe('NodeGuards', () => {
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ describe('isNodeWithSingleStatementBody', () => {
|
|
|
|
+ describe('truthful checks', () => {
|
|
|
|
+ describe('Variant #1: `IfStatement` node', () => {
|
|
|
|
+ describe('Variant #1: single statement `consequent`', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.IfStatement = NodeFactory.ifStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `IfStatement` node has single statement `consequent`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #2: single statement `alternate`', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.IfStatement = NodeFactory.ifStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `IfStatement` node has single statement `alternate`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #3: single statement `consequent` and `alternate`', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.IfStatement = NodeFactory.ifStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `IfStatement` node has single statement `consequent` and `alternate`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #2: `ForStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.ForStatement = NodeFactory.forStatementNode(
|
|
|
|
+ NodeFactory.variableDeclarationNode([
|
|
|
|
+ NodeFactory.variableDeclaratorNode(
|
|
|
|
+ NodeFactory.identifierNode('i'),
|
|
|
|
+ NodeFactory.literalNode(0)
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.binaryExpressionNode(
|
|
|
|
+ '<',
|
|
|
|
+ NodeFactory.identifierNode('i'),
|
|
|
|
+ NodeFactory.literalNode(10)
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.updateExpressionNode(
|
|
|
|
+ '++',
|
|
|
|
+ NodeFactory.identifierNode('i')
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `ForStatement` node has single statement `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #3: `ForInStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.ForInStatement = NodeFactory.forInStatementNode(
|
|
|
|
+ NodeFactory.variableDeclarationNode([
|
|
|
|
+ NodeFactory.variableDeclaratorNode(
|
|
|
|
+ NodeFactory.identifierNode('key'),
|
|
|
|
+ null
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.objectExpressionNode(
|
|
|
|
+ []
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `ForInStatement` node has single statement `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #4: `ForOfStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.ForOfStatement = NodeFactory.forOfStatementNode(
|
|
|
|
+ false,
|
|
|
|
+ NodeFactory.variableDeclarationNode([
|
|
|
|
+ NodeFactory.variableDeclaratorNode(
|
|
|
|
+ NodeFactory.identifierNode('key'),
|
|
|
|
+ null
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.objectExpressionNode(
|
|
|
|
+ []
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `ForOfStatement` node has single statement `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #5: `WhileStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.WhileStatement = NodeFactory.whileStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `WhileStatement` node has single statement `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #6: `DoWhileStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.DoWhileStatement = NodeFactory.doWhileStatementNode(
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `DoWhileStatement` node has single statement `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #7: `LabeledStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = true;
|
|
|
|
+ const node: ESTree.LabeledStatement = NodeFactory.labeledStatementNode(
|
|
|
|
+ NodeFactory.identifierNode('label'),
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `LabeledStatement` node has single statement `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('false checks', () => {
|
|
|
|
+ describe('Variant #1: `IfStatement` node', () => {
|
|
|
|
+ describe('Variant #1: multiple statements `consequent` and `alternate`', () => {
|
|
|
|
+ const expectedResult: boolean = false;
|
|
|
|
+ const node: ESTree.IfStatement = NodeFactory.ifStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ])
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `IfStatement` node has multiple statements `consequent` and `alternate`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #2: `ForStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = false;
|
|
|
|
+ const node: ESTree.ForStatement = NodeFactory.forStatementNode(
|
|
|
|
+ NodeFactory.variableDeclarationNode([
|
|
|
|
+ NodeFactory.variableDeclaratorNode(
|
|
|
|
+ NodeFactory.identifierNode('i'),
|
|
|
|
+ NodeFactory.literalNode(0)
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.binaryExpressionNode(
|
|
|
|
+ '<',
|
|
|
|
+ NodeFactory.identifierNode('i'),
|
|
|
|
+ NodeFactory.literalNode(10)
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.updateExpressionNode(
|
|
|
|
+ '++',
|
|
|
|
+ NodeFactory.identifierNode('i')
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ])
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `ForStatement` node has multiple statements `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #3: `ForInStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = false;
|
|
|
|
+ const node: ESTree.ForInStatement = NodeFactory.forInStatementNode(
|
|
|
|
+ NodeFactory.variableDeclarationNode([
|
|
|
|
+ NodeFactory.variableDeclaratorNode(
|
|
|
|
+ NodeFactory.identifierNode('key'),
|
|
|
|
+ null
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.objectExpressionNode(
|
|
|
|
+ []
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ])
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `ForInStatement` node has multiple statements `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #4: `ForOfStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = false;
|
|
|
|
+ const node: ESTree.ForOfStatement = NodeFactory.forOfStatementNode(
|
|
|
|
+ false,
|
|
|
|
+ NodeFactory.variableDeclarationNode([
|
|
|
|
+ NodeFactory.variableDeclaratorNode(
|
|
|
|
+ NodeFactory.identifierNode('key'),
|
|
|
|
+ null
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.objectExpressionNode(
|
|
|
|
+ []
|
|
|
|
+ ),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ])
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `ForOfStatement` node has multiple statements `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #5: `WhileStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = false;
|
|
|
|
+ const node: ESTree.WhileStatement = NodeFactory.whileStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ])
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `WhileStatement` node has multiple statements `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #6: `DoWhileStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = false;
|
|
|
|
+ const node: ESTree.DoWhileStatement = NodeFactory.doWhileStatementNode(
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ]),
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `DoWhileStatement` node has multiple statements `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #7: `LabeledStatement` node', () => {
|
|
|
|
+ const expectedResult: boolean = false;
|
|
|
|
+ const node: ESTree.LabeledStatement = NodeFactory.labeledStatementNode(
|
|
|
|
+ NodeFactory.identifierNode('label'),
|
|
|
|
+ NodeFactory.blockStatementNode([
|
|
|
|
+ NodeFactory.expressionStatementNode(
|
|
|
|
+ NodeFactory.literalNode(true)
|
|
|
|
+ )
|
|
|
|
+ ])
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ let result: boolean;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ result = NodeGuards.isNodeWithSingleStatementBody(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should check if `LabeledStatement` node has multiple statements `body`', () => {
|
|
|
|
+ assert.equal(result, expectedResult);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
describe('isNodeWithStatements', () => {
|
|
describe('isNodeWithStatements', () => {
|
|
describe('truthful checks', () => {
|
|
describe('truthful checks', () => {
|
|
describe('Variant #1: program node', () => {
|
|
describe('Variant #1: program node', () => {
|