Make sure estree test should not throw if babel parser does not throw (#12443)
* test: run estree on tests that does not expect an errors * fix: record the directive expression value to extra AST properties
This commit is contained in:
parent
208acb1d6c
commit
3bd6a3d781
@ -61,7 +61,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
directiveLiteral.loc.start,
|
||||
);
|
||||
|
||||
expression.value = directiveLiteral.value;
|
||||
expression.value = directiveLiteral.extra.expressionValue;
|
||||
expression.raw = directiveLiteral.extra.raw;
|
||||
|
||||
stmt.expression = this.finishNodeAt(
|
||||
@ -118,9 +118,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
const directive = super.stmtToDirective(stmt);
|
||||
const value = stmt.expression.value;
|
||||
|
||||
// Reset value to the actual value as in estree mode we want
|
||||
// the stmt to have the real value and not the raw value
|
||||
directive.value.value = value;
|
||||
// Record the expression value as in estree mode we want
|
||||
// the stmt to have the real value e.g. ("use strict") and
|
||||
// not the raw value e.g. ("use\\x20strict")
|
||||
this.addExtra(directive.value, "expressionValue", value);
|
||||
|
||||
return directive;
|
||||
}
|
||||
|
||||
@ -83,14 +83,6 @@ export function runThrowTestsWithEstree(fixturesPath, parseFunction) {
|
||||
Object.keys(fixtures).forEach(function (name) {
|
||||
fixtures[name].forEach(function (testSuite) {
|
||||
testSuite.tests.forEach(function (task) {
|
||||
if (!task.options.throws) {
|
||||
const hasErrors =
|
||||
!task.disabled && "errors" in JSON.parse(task.expect.code);
|
||||
if (!hasErrors) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
task.options.plugins = task.options.plugins || [];
|
||||
task.options.plugins.push("estree");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user