Behavior specs cleanup: Improve sequence specs

This commit is contained in:
David Majda 2015-01-24 20:02:06 +01:00
parent 548209b48b
commit b3828919e2

View file

@ -770,18 +770,30 @@ describe("generated parser behavior", function() {
});
describe("sequence", function() {
it("matches correctly", function() {
describe("when all expressions match", function() {
it("returns an array of their match results", function() {
var parser = PEG.buildParser('start = "a" "b" "c"', options);
expect(parser).toParse("abc", ["a", "b", "c"]);
});
});
it("does not advance position on failure", function() {
describe("when any expression doesn't match", function() {
it("reports match failure", function() {
var parser = PEG.buildParser('start = "a" "b" "c"', options);
expect(parser).toFailToParse("dbc");
expect(parser).toFailToParse("adc");
expect(parser).toFailToParse("abd");
});
it("resets parse position", function() {
var parser = PEG.buildParser('start = "a" "b" / "a"', options);
expect(parser).toParse("a", "a");
});
});
});
describe("action", function() {
it("tranforms the expression result by returnung a value", function() {