From 45f825c24f5952c9d71df6373d903c61a24f18b0 Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 20 Apr 2012 20:00:05 +0200 Subject: [PATCH] Jasmine: Convert tests of parser's "primary" rule --- spec/parser.spec.js | 9 +++++++++ test/parser-test.js | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/parser.spec.js b/spec/parser.spec.js index 1afd71d..e3919a4 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -134,6 +134,15 @@ describe("PEG.js grammar parser", function() { }); }); + /* Canonical primary is "\"abcd\"". */ + it("parses primary", function() { + expect('start = a' ).toParseAs(ruleRefGrammar("a")); + expect('start = "abcd"' ).toParseAs(literalGrammar("abcd")); + expect('start = .' ).toParseAs(oneRuleGrammar(null, { type: "any" })); + expect('start = [a-d]' ).toParseAs(classGrammar([["a", "d"]], "[a-d]")); + expect('start = ("abcd")').toParseAs(literalGrammar("abcd")); + }); + /* Canonical action is "{ code }". */ it("parses action", function() { expect('start = "abcd" { code }').toParseAs(actionGrammar(" code ")); diff --git a/test/parser-test.js b/test/parser-test.js index 9642ef9..d28b778 100644 --- a/test/parser-test.js +++ b/test/parser-test.js @@ -293,13 +293,4 @@ test("parses suffixed", function() { parserParses('start = "abcd"', literalGrammar("abcd")); }); -/* Canonical primary is "\"abcd\"". */ -test("parses primary", function() { - parserParses('start = a', identifierGrammar("a")); - parserParses('start = "abcd"', literalGrammar("abcd")); - parserParses('start = .', anyGrammar); - parserParses('start = [a-d]', classGrammar(false, [["a", "d"]], "[a-d]")); - parserParses('start = ("abcd")', literalGrammar("abcd")); -}); - })();