Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Aug 28, 2020
1 parent e7e4b62 commit e137260
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
14 changes: 10 additions & 4 deletions src/ast/nodes/IfStatement.ts
Expand Up @@ -70,12 +70,18 @@ export default class IfStatement extends StatementBase implements DeoptimizableE

parseNode(esTreeNode: GenericEsTreeNode) {
this.consequentScope = new TrackingScope(this.scope);
this.consequent = new (this.context.nodeConstructors[esTreeNode.consequent.type] ||
this.context.nodeConstructors.UnknownNode)(esTreeNode.consequent, this, this.consequentScope);
this.consequent = new this.context.nodeConstructors[esTreeNode.consequent.type](
esTreeNode.consequent,
this,
this.consequentScope
);
if (esTreeNode.alternate) {
this.alternateScope = new TrackingScope(this.scope);
this.alternate = new (this.context.nodeConstructors[esTreeNode.alternate.type] ||
this.context.nodeConstructors.UnknownNode)(esTreeNode.alternate, this, this.alternateScope);
this.alternate = new this.context.nodeConstructors[esTreeNode.alternate.type](
esTreeNode.alternate,
this,
this.alternateScope
);
}
super.parseNode(esTreeNode);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ast/scopes/BlockScope.ts
Expand Up @@ -9,7 +9,7 @@ export default class BlockScope extends ChildScope {
addDeclaration(
identifier: Identifier,
context: AstContext,
init: ExpressionEntity | null = null,
init: ExpressionEntity | null,
isHoisted: boolean
): LocalVariable {
if (isHoisted) {
Expand Down
2 changes: 1 addition & 1 deletion src/ast/scopes/Scope.ts
Expand Up @@ -13,7 +13,7 @@ export default class Scope {
addDeclaration(
identifier: Identifier,
context: AstContext,
init: ExpressionEntity | null = null,
init: ExpressionEntity | null,
_isHoisted: boolean
) {
const name = identifier.name;
Expand Down
4 changes: 1 addition & 3 deletions src/ast/scopes/TrackingScope.ts
Expand Up @@ -13,9 +13,7 @@ export default class TrackingScope extends BlockScope {
init: ExpressionEntity | null = null,
isHoisted: boolean
): LocalVariable {
if (isHoisted) {
this.hoistedDeclarations.push(identifier);
}
this.hoistedDeclarations.push(identifier);
return this.parent.addDeclaration(identifier, context, init, isHoisted);
}
}

0 comments on commit e137260

Please sign in to comment.