Jasmine: Convert tests of parser's "literal" rule

redux
David Majda 13 years ago
parent 573db92583
commit a3d93f000f

@ -18,10 +18,12 @@ describe("PEG.js grammar parser", function() {
}
function literalGrammar(value) {
var ignoreCase = arguments.length > 1 ? arguments[1] : false;
return oneRuleGrammar(null, {
type: "literal",
value: value,
ignoreCase: false
ignoreCase: ignoreCase
});
}
@ -119,6 +121,16 @@ describe("PEG.js grammar parser", function() {
});
});
/* Canonical literal is "\"abcd\"". */
it("parses literal", function() {
expect('start = "abcd"' ).toParseAs(literalGrammar("abcd"));
expect("start = 'abcd'" ).toParseAs(literalGrammar("abcd"));
expect('start = "abcd"i').toParseAs(literalGrammar("abcd", true));
expect('start = "abcd"\n').toParseAs(literalGrammar("abcd"));
});
/* Canonical string is "\"abcd\"". */
it("parses string", function() {
var grammar = oneRuleGrammar("abcd", {

@ -338,13 +338,4 @@ test("parses identifier", function() {
parserParses('start = a\n', identifierGrammar("a"));
});
/* Canonical literal is "\"abcd\"". */
test("parses literal", function() {
parserParses('start = "abcd"', literalGrammar("abcd"));
parserParses("start = 'abcd'", literalGrammar("abcd"));
parserParses('start = "abcd"i', oneRuleGrammar(literal("abcd", true)));
parserParses('start = "abcd"\n', literalGrammar("abcd"));
});
})();

Loading…
Cancel
Save