pegjs/spec/unit/compiler/passes/report-left-recursion.spec.js
David Majda 850ddf5889 Specs cleanup: Simplify compiler passes specs
After 898a7b5a2d the specs mostly tested
the visitor implementation, not actual code in the passes.
2014-06-07 10:50:55 +02:00

30 lines
916 B
JavaScript

describe("compiler pass |reportLeftRecursion|", function() {
var pass = PEG.compiler.passes.check.reportLeftRecursion;
it("reports direct left recursion", function() {
expect(pass).toReportError('start = start', {
message: 'Left recursion detected for rule \"start\".'
});
});
it("reports indirect left recursion", function() {
expect(pass).toReportError([
'start = stop',
'stop = start'
].join("\n"), {
message: 'Left recursion detected for rule \"start\".'
});
});
describe("in sequences", function() {
it("reports left recursion only for the first element", function() {
expect(pass).toReportError('start = start "a" "b"', {
message: 'Left recursion detected for rule \"start\".'
});
expect(pass).not.toReportError('start = "a" start "b"');
expect(pass).not.toReportError('start = "a" "b" start');
});
});
});