Increase test coverage (#175)
* Increase test coverage * Test for error when binding `this` in destructuring pattern * Ignore coverage of inAsync check in parseAwait - already checked externally * Ignore coverage of default case in checkPropClash * Remove unused parameter isAsync from parseParenAndDistinguishExpression * Ignore coverage of an `else` branch in flowParseTypeParameterDeclaration * Flow: remove unused parameters to flowParseTypeAnnotatableIdentifier * Flow: ignore coverage of pass-through throw statement in parseConditional * Flow: Add test for error on property with type param * Flow: ignore coverage of pass-through throw statements in parseMaybeAssign, parseArrow * Add test for error on XML-style comment in module code * Update test for error on method in object pattern * Test for error: "Only '=' operator can be used for specifying default value"
This commit is contained in:
committed by
Daniel Tschinder
parent
490ae9a44c
commit
7c18bf83cc
@@ -45,6 +45,7 @@ pp.checkPropClash = function (prop, propHash) {
|
||||
name = String(key.value);
|
||||
break;
|
||||
|
||||
// istanbul ignore next: non-computed property keys are always one of the above
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -555,7 +556,7 @@ pp.parseParenExpression = function () {
|
||||
return val;
|
||||
};
|
||||
|
||||
pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow, isAsync) {
|
||||
pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow) {
|
||||
startPos = startPos || this.state.start;
|
||||
startLoc = startLoc || this.state.startLoc;
|
||||
|
||||
@@ -597,15 +598,11 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
|
||||
if (param.extra && param.extra.parenthesized) this.unexpected(param.extra.parenStart);
|
||||
}
|
||||
|
||||
return this.parseArrowExpression(arrowNode, exprList, isAsync);
|
||||
return this.parseArrowExpression(arrowNode, exprList);
|
||||
}
|
||||
|
||||
if (!exprList.length) {
|
||||
if (isAsync) {
|
||||
return;
|
||||
} else {
|
||||
this.unexpected(this.state.lastTokStart);
|
||||
}
|
||||
this.unexpected(this.state.lastTokStart);
|
||||
}
|
||||
if (optionalCommaStart) this.unexpected(optionalCommaStart);
|
||||
if (spreadStart) this.unexpected(spreadStart);
|
||||
@@ -1025,6 +1022,7 @@ pp.parseIdentifier = function (liberal) {
|
||||
// Parses await expression inside async function.
|
||||
|
||||
pp.parseAwait = function (node) {
|
||||
// istanbul ignore next: this condition is checked at the call site so won't be hit here
|
||||
if (!this.state.inAsync) {
|
||||
this.unexpected();
|
||||
}
|
||||
|
||||
@@ -670,7 +670,6 @@ pp.parseClassBody = function (node) {
|
||||
|
||||
method.static = isMaybeStatic && !this.match(tt.parenL);
|
||||
if (method.static) {
|
||||
if (isGenerator) this.unexpected();
|
||||
isGenerator = this.eat(tt.star);
|
||||
this.parsePropertyName(method);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ pp.flowParseTypeParameter = function () {
|
||||
|
||||
let variance = this.flowParseVariance();
|
||||
|
||||
let ident = this.flowParseTypeAnnotatableIdentifier(false, false);
|
||||
let ident = this.flowParseTypeAnnotatableIdentifier();
|
||||
node.name = ident.name;
|
||||
node.variance = variance;
|
||||
node.bound = ident.typeAnnotation;
|
||||
@@ -227,6 +227,7 @@ pp.flowParseTypeParameterDeclaration = function () {
|
||||
|
||||
this.state.inType = true;
|
||||
|
||||
// istanbul ignore else: this condition is already checked at all call sites
|
||||
if (this.isRelational("<") || this.match(tt.jsxTagStart)) {
|
||||
this.next();
|
||||
} else {
|
||||
@@ -705,26 +706,12 @@ pp.flowParseTypeAnnotation = function () {
|
||||
return this.finishNode(node, "TypeAnnotation");
|
||||
};
|
||||
|
||||
pp.flowParseTypeAnnotatableIdentifier = function (requireTypeAnnotation, canBeOptionalParam) {
|
||||
|
||||
pp.flowParseTypeAnnotatableIdentifier = function () {
|
||||
let ident = this.parseIdentifier();
|
||||
let isOptionalParam = false;
|
||||
|
||||
if (canBeOptionalParam && this.eat(tt.question)) {
|
||||
this.expect(tt.question);
|
||||
isOptionalParam = true;
|
||||
}
|
||||
|
||||
if (requireTypeAnnotation || this.match(tt.colon)) {
|
||||
if (this.match(tt.colon)) {
|
||||
ident.typeAnnotation = this.flowParseTypeAnnotation();
|
||||
this.finishNode(ident, ident.type);
|
||||
}
|
||||
|
||||
if (isOptionalParam) {
|
||||
ident.optional = true;
|
||||
this.finishNode(ident, ident.type);
|
||||
}
|
||||
|
||||
return ident;
|
||||
};
|
||||
|
||||
@@ -824,6 +811,7 @@ export default function (instance) {
|
||||
refNeedsArrowPos.start = err.pos || this.state.start;
|
||||
return expr;
|
||||
} else {
|
||||
// istanbul ignore next: no such error is expected
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
@@ -1208,6 +1196,7 @@ export default function (instance) {
|
||||
this.state = state;
|
||||
jsxError = err;
|
||||
} else {
|
||||
// istanbul ignore next: no such error is expected
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
@@ -1262,6 +1251,7 @@ export default function (instance) {
|
||||
if (err instanceof SyntaxError) {
|
||||
this.state = state;
|
||||
} else {
|
||||
// istanbul ignore next: no such error is expected
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,6 +365,7 @@ pp.jsxParseElementAt = function(startPos, startLoc) {
|
||||
|
||||
break;
|
||||
|
||||
// istanbul ignore next - should never happen
|
||||
default:
|
||||
this.unexpected();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user