2016-06-22 15:02:59 +02:00
|
|
|
"use strict";
|
|
|
|
|
2016-09-08 16:04:36 +02:00
|
|
|
let peg = require("../../../../lib/peg");
|
2016-09-08 13:29:06 +02:00
|
|
|
|
2016-06-22 15:02:59 +02:00
|
|
|
describe("compiler pass |reportDuplicateRules|", function() {
|
2016-09-08 16:04:36 +02:00
|
|
|
let pass = peg.compiler.passes.check.reportDuplicateRules;
|
2016-06-22 15:02:59 +02:00
|
|
|
|
|
|
|
it("reports duplicate rules", function() {
|
|
|
|
expect(pass).toReportError([
|
2016-09-21 15:06:56 +02:00
|
|
|
"start = 'a'",
|
|
|
|
"start = 'b'"
|
|
|
|
].join("\n"), {
|
2016-09-22 05:25:09 +02:00
|
|
|
message: "Rule \"start\" is already defined at line 1, column 1.",
|
2016-06-22 15:02:59 +02:00
|
|
|
location: {
|
2016-09-22 05:25:09 +02:00
|
|
|
start: { offset: 12, line: 2, column: 1 },
|
|
|
|
end: { offset: 23, line: 2, column: 12 }
|
2016-06-22 15:02:59 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|