From 52144e48cb2357d8c3914de4d28d567d6010b90f Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 16 Jan 2015 15:45:54 +0100 Subject: [PATCH] Behavior specs cleanup: Improve label specs --- spec/behavior/generated-parser-behavior.spec.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/spec/behavior/generated-parser-behavior.spec.js b/spec/behavior/generated-parser-behavior.spec.js index 10300ef..3d8e743 100644 --- a/spec/behavior/generated-parser-behavior.spec.js +++ b/spec/behavior/generated-parser-behavior.spec.js @@ -724,11 +724,20 @@ describe("generated parser behavior", function() { }); describe("label", function() { - it("delegates to the expression", function() { - var parser = PEG.buildParser('start = a:"a"', options); + describe("when the expression matches", function() { + it("returns its match result", function() { + var parser = PEG.buildParser('start = a:"a"', options); - expect(parser).toParse("a", "a"); - expect(parser).toFailToParse("b"); + expect(parser).toParse("a", "a"); + }); + }); + + describe("when the expression doesn't match", function() { + it("reports match failure", function() { + var parser = PEG.buildParser('start = a:"a"', options); + + expect(parser).toFailToParse("b"); + }); }); });