2016-07-29 15:16:56 +02:00
|
|
|
"use strict";
|
|
|
|
|
2017-10-25 20:19:42 +02:00
|
|
|
const chai = require( "chai" );
|
|
|
|
const helpers = require( "./helpers" );
|
2018-09-08 03:39:12 +02:00
|
|
|
const pass = require( "pegjs" ).compiler.passes.check.reportUndefinedRules;
|
2017-10-25 20:19:42 +02:00
|
|
|
|
|
|
|
chai.use( helpers );
|
|
|
|
|
|
|
|
const expect = chai.expect;
|
|
|
|
|
|
|
|
describe( "compiler pass |reportUndefinedRules|", function () {
|
|
|
|
|
|
|
|
it( "reports undefined rules", function () {
|
|
|
|
|
|
|
|
expect( pass ).to.reportError( "start = undefined", {
|
|
|
|
message: "Rule \"undefined\" is not defined.",
|
|
|
|
location: {
|
|
|
|
start: { offset: 8, line: 1, column: 9 },
|
2019-09-29 04:24:42 +02:00
|
|
|
end: { offset: 17, line: 1, column: 18 },
|
|
|
|
},
|
2017-10-25 20:19:42 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( "checks allowedStartRules", function () {
|
|
|
|
|
2019-09-29 04:24:42 +02:00
|
|
|
expect( pass ).to.reportError(
|
|
|
|
"start = 'a'",
|
|
|
|
{
|
|
|
|
message: "Start rule \"missing\" is not defined.",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
allowedStartRules: [ "missing" ],
|
|
|
|
}
|
|
|
|
);
|
2017-10-25 20:19:42 +02:00
|
|
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
} );
|