From ec8889f85d2c77ea35a2aded0b17cd1f720cdba5 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sat, 21 Apr 2012 10:56:05 +0200 Subject: [PATCH] Jasmine: Convert tests of parser's "labeled" rule --- spec/parser.spec.js | 17 +++++++++++++++-- test/parser-test.js | 9 --------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/spec/parser.spec.js b/spec/parser.spec.js index 5e8c523..e872aee 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -1,7 +1,8 @@ describe("PEG.js grammar parser", function() { var trivialGrammar, - literalAbcd = { type: "literal", value: "abcd", ignoreCase: false }, - optionalLiteral = { type: "optional", expression: literalAbcd }; + literalAbcd = { type: "literal", value: "abcd", ignoreCase: false }, + optionalLiteral = { type: "optional", expression: literalAbcd }, + simpleNotLiteral = { type: "simple_not", expression: literalAbcd }; function oneRuleGrammar(displayName, expression) { return { @@ -135,6 +136,18 @@ describe("PEG.js grammar parser", function() { }); }); + /* Canonical labeled is "label:\"abcd\"". */ + it("parses labeled", function() { + expect('start = label:!"abcd"').toParseAs(oneRuleGrammar(null, { + type: "labeled", + label: "label", + expression: simpleNotLiteral + })); + expect('start = !"abcd"' ).toParseAs( + oneRuleGrammar(null, simpleNotLiteral) + ); + }); + /* Canonical prefixed is "!\"abcd\"". */ it("parses prefixed", function() { expect('start = &{ code }').toParseAs(oneRuleGrammar(null, { diff --git a/test/parser-test.js b/test/parser-test.js index 40e21a6..edbebb6 100644 --- a/test/parser-test.js +++ b/test/parser-test.js @@ -267,13 +267,4 @@ test("parses sequence", function() { ); }); -/* Canonical labeled is "label:\"abcd\"". */ -test("parses labeled", function() { - parserParses( - 'start = label:!"abcd"', - oneRuleGrammar(labeled("label", simpleNot(literalAbcd))) - ); - parserParses('start = !"abcd"', oneRuleGrammar(simpleNot(literalAbcd))); -}); - })();