Behavior specs cleanup: Improve sequence specs
This commit is contained in:
parent
548209b48b
commit
b3828919e2
|
@ -770,16 +770,28 @@ describe("generated parser behavior", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("sequence", function() {
|
describe("sequence", function() {
|
||||||
it("matches correctly", function() {
|
describe("when all expressions match", function() {
|
||||||
var parser = PEG.buildParser('start = "a" "b" "c"', options);
|
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"]);
|
expect(parser).toParse("abc", ["a", "b", "c"]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not advance position on failure", function() {
|
describe("when any expression doesn't match", function() {
|
||||||
var parser = PEG.buildParser('start = "a" "b" / "a"', options);
|
it("reports match failure", function() {
|
||||||
|
var parser = PEG.buildParser('start = "a" "b" "c"', options);
|
||||||
|
|
||||||
expect(parser).toParse("a", "a");
|
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue