From bf6d412a4f381eb1c420af392e20d07ed4e5b19f Mon Sep 17 00:00:00 2001 From: David Majda Date: Sat, 21 Apr 2012 10:45:58 +0200 Subject: [PATCH] Jasmine: Convert tests of parser's "prefixed" rule --- spec/parser.spec.js | 21 +++++++++++++++++++++ test/parser-test.js | 9 --------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/spec/parser.spec.js b/spec/parser.spec.js index 2beaf6d..5e8c523 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -135,6 +135,27 @@ describe("PEG.js grammar parser", function() { }); }); + /* Canonical prefixed is "!\"abcd\"". */ + it("parses prefixed", function() { + expect('start = &{ code }').toParseAs(oneRuleGrammar(null, { + type: "semantic_and", + code: " code " + })); + expect('start = &"abcd"?' ).toParseAs(oneRuleGrammar(null, { + type: "simple_and", + expression: optionalLiteral + })); + expect('start = !{ code }').toParseAs(oneRuleGrammar(null, { + type: "semantic_not", + code: " code " + })); + expect('start = !"abcd"?' ).toParseAs(oneRuleGrammar(null, { + type: "simple_not", + expression: optionalLiteral + })); + expect('start = "abcd"?' ).toParseAs(oneRuleGrammar(null, optionalLiteral)); + }); + /* Canonical suffixed is "\"abcd\"?". */ it("parses suffixed", function() { expect('start = "abcd"?').toParseAs(oneRuleGrammar(null, optionalLiteral)); diff --git a/test/parser-test.js b/test/parser-test.js index d05ca2e..40e21a6 100644 --- a/test/parser-test.js +++ b/test/parser-test.js @@ -276,13 +276,4 @@ test("parses labeled", function() { parserParses('start = !"abcd"', oneRuleGrammar(simpleNot(literalAbcd))); }); -/* Canonical prefixed is "!\"abcd\"". */ -test("parses prefixed", function() { - parserParses('start = &{ code }', oneRuleGrammar(semanticAnd(" code "))); - parserParses('start = &"abcd"?', oneRuleGrammar(simpleAnd(optionalLiteral))); - parserParses('start = !{ code }', oneRuleGrammar(semanticNot(" code "))); - parserParses('start = !"abcd"?', oneRuleGrammar(simpleNot(optionalLiteral))); - parserParses('start = "abcd"?', oneRuleGrammar(optionalLiteral)); -}); - })();