Behavior specs cleanup: Improve optional specs
This commit is contained in:
parent
ade2c249f2
commit
c377eff876
|
@ -615,11 +615,20 @@ describe("generated parser behavior", function() {
|
|||
});
|
||||
|
||||
describe("optional", function() {
|
||||
it("matches correctly", function() {
|
||||
describe("when the expression matches", function() {
|
||||
it("returns its match result", function() {
|
||||
var parser = PEG.buildParser('start = "a"?', options);
|
||||
|
||||
expect(parser).toParse("a", "a");
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the expression doesn't match", function() {
|
||||
it("returns |null|", function() {
|
||||
var parser = PEG.buildParser('start = "a"?', options);
|
||||
|
||||
expect(parser).toParse("", null);
|
||||
expect(parser).toParse("a", "a");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue