From e17d4de7ae2fdec6bfe7f9138800f8dc5024dc08 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sat, 21 Apr 2012 11:48:38 +0200 Subject: [PATCH] Jasmine: Convert tests of parser's "expression" rule --- spec/parser.spec.js | 11 +++++++++++ test/parser-test.js | 8 -------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/spec/parser.spec.js b/spec/parser.spec.js index 2300e34..aefaa46 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -16,6 +16,10 @@ describe("PEG.js grammar parser", function() { sequenceOfLabeleds = { type: "sequence", elements: [labeledAbcd, labeledEfgh, labeledIjkl] + }, + choiceOfLiterals = { + type: "choice", + alternatives: [literalAbcd, literalEfgh, literalIjkl] }; function oneRuleGrammar(displayName, expression) { @@ -150,6 +154,13 @@ describe("PEG.js grammar parser", function() { }); }); + /* Canonical expression is "\"abcd\" / \"efgh\" / \"ijkl\"". */ + it("parses expression", function() { + expect('start = "abcd" / "efgh" / "ijkl"').toParseAs( + oneRuleGrammar(null, choiceOfLiterals) + ); + }); + /* Canonical choice is "\"abcd\" / \"efgh\" / \"ijkl\"". */ it("parses choice", function() { expect('start = "abcd" "efgh" "ijkl"').toParseAs( diff --git a/test/parser-test.js b/test/parser-test.js index 68c225c..d47255c 100644 --- a/test/parser-test.js +++ b/test/parser-test.js @@ -220,12 +220,4 @@ test("parses rule", function() { ); }); -/* Canonical expression is "\"abcd\" / \"efgh\" / \"ijkl\"". */ -test("parses expression", function() { - parserParses( - 'start = "abcd" / "efgh" / "ijkl"', - oneRuleGrammar(choiceLiterals) - ); -}); - })();