From 171d62fce462d8b6c4dbbfc82ba2465d68411b28 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sat, 21 Apr 2012 11:52:27 +0200 Subject: [PATCH] Jasmine: Convert tests of parser's "rule" rule --- spec/parser.spec.js | 13 +++++++++++++ test/parser-test.js | 21 --------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/spec/parser.spec.js b/spec/parser.spec.js index aefaa46..56706e1 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -154,6 +154,19 @@ describe("PEG.js grammar parser", function() { }); }); + /* Canonical rule is "a: \"abcd\"". */ + it("parses rule", function() { + expect('start = "abcd" / "efgh" / "ijkl"').toParseAs( + oneRuleGrammar(null, choiceOfLiterals) + ); + expect('start "start rule" = "abcd" / "efgh" / "ijkl"').toParseAs( + oneRuleGrammar("start rule", choiceOfLiterals) + ); + expect('start = "abcd" / "efgh" / "ijkl";').toParseAs( + oneRuleGrammar(null, choiceOfLiterals) + ); + }); + /* Canonical expression is "\"abcd\" / \"efgh\" / \"ijkl\"". */ it("parses expression", function() { expect('start = "abcd" / "efgh" / "ijkl"').toParseAs( diff --git a/test/parser-test.js b/test/parser-test.js index d47255c..22caf12 100644 --- a/test/parser-test.js +++ b/test/parser-test.js @@ -199,25 +199,4 @@ test("parses initializer", function() { parserParses('{ code };a = "abcd"', initializerGrammar); }); -/* Canonical rule is "a: \"abcd\"". */ -test("parses rule", function() { - parserParses( - 'start = "abcd" / "efgh" / "ijkl"', - oneRuleGrammar(choiceLiterals) - ); - parserParses( - 'start "start rule" = "abcd" / "efgh" / "ijkl"', - { - type: "grammar", - initializer: null, - rules: [rule("start", "start rule", choiceLiterals)], - startRule: "start" - } - ); - parserParses( - 'start = "abcd" / "efgh" / "ijkl";', - oneRuleGrammar(choiceLiterals) - ); -}); - })();