Auto-add allowedStartRules to test options for changeAST and reportError methods if it not defined

This commit is contained in:
Mingun 2017-10-28 15:57:54 +05:00
parent 75d655409c
commit 3e89534bb7
2 changed files with 21 additions and 9 deletions

View file

@ -24,8 +24,6 @@ function reportUndefinedRules( ast, options ) {
check( ast );
if ( options.allowedStartRules ) {
options.allowedStartRules.forEach( rule => {
if ( ! asts.findRule( ast, rule ) ) {
@ -38,6 +36,4 @@ function reportUndefinedRules( ast, options ) {
}
}
module.exports = reportUndefinedRules;

View file

@ -55,6 +55,14 @@ module.exports = function ( chai, utils ) {
const ast = parser.parse( grammar );
if ( ! options.allowedStartRules ) {
options.allowedStartRules = ast.rules.length > 0
? [ ast.rules[ 0 ].name ]
: [];
}
utils.flag( this, "object" )( ast, options );
this.assert(
@ -73,6 +81,14 @@ module.exports = function ( chai, utils ) {
const ast = parser.parse( grammar );
if ( ! options.allowedStartRules ) {
options.allowedStartRules = ast.rules.length > 0
? [ ast.rules[ 0 ].name ]
: [];
}
let passed, result;
try {