Test the checks directly, do not go through |PEG.buildParser|

redux
David Majda 14 years ago
parent f82a4ebf28
commit 95f70c9562

@ -20,7 +20,10 @@ test("reports missing referenced rules", function() {
for (var i = 0; i < grammars.length; i++) { for (var i = 0; i < grammars.length; i++) {
throws( throws(
function() { PEG.buildParser(grammars[i]); }, function() {
var ast = PEG.parser.parse(grammars[i]);
PEG.compiler.checks.missingReferencedRules(ast);
},
PEG.GrammarError, PEG.GrammarError,
{ message: "Referenced rule \"missing\" does not exist." } { message: "Referenced rule \"missing\" does not exist." }
); );
@ -48,7 +51,10 @@ test("reports left recursion", function() {
for (var i = 0; i < grammars.length; i++) { for (var i = 0; i < grammars.length; i++) {
throws( throws(
function() { PEG.buildParser(grammars[i]); }, function() {
var ast = PEG.parser.parse(grammars[i]);
PEG.compiler.checks.leftRecursion(ast);
},
PEG.GrammarError, PEG.GrammarError,
{ message: "Left recursion detected for rule \"start\"." } { message: "Left recursion detected for rule \"start\"." }
); );

Loading…
Cancel
Save