Behavior specs cleanup: Improve rule reference specs

redux
David Majda 9 years ago
parent 936d6453a5
commit ade2c249f2

@ -391,15 +391,26 @@ describe("generated parser behavior", function() {
}); });
describe("rule reference", function() { describe("rule reference", function() {
it("follows rule references", function() { describe("when referenced rule's expression matches", function() {
var parser = PEG.buildParser([ it("returns its result", function() {
'start = static / dynamic', var parser = PEG.buildParser([
'static = "C" / "C++" / "Java" / "C#"', 'start = a',
'dynamic = "Ruby" / "Python" / "JavaScript"' 'a = "a"',
].join("\n"), options); ].join("\n"), options);
expect(parser).toParse("Java", "Java"); expect(parser).toParse("a", "a");
expect(parser).toParse("Python", "Python"); });
});
describe("when referenced rule's expression doesn't match", function() {
it("reports match failure", function() {
var parser = PEG.buildParser([
'start = a',
'a = "a"',
].join("\n"), options);
expect(parser).toFailToParse("b");
});
}); });
}); });

Loading…
Cancel
Save