Jasmine: Convert tests of parser's "suffixed" rule
This commit is contained in:
parent
45f825c24f
commit
3e083cc51b
|
@ -1,6 +1,7 @@
|
|||
describe("PEG.js grammar parser", function() {
|
||||
var trivialGrammar,
|
||||
literalAbcd = { type: "literal", value: "abcd", ignoreCase: false };
|
||||
literalAbcd = { type: "literal", value: "abcd", ignoreCase: false },
|
||||
optionalLiteral = { type: "optional", expression: literalAbcd };
|
||||
|
||||
function oneRuleGrammar(displayName, expression) {
|
||||
return {
|
||||
|
@ -134,6 +135,20 @@ describe("PEG.js grammar parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
/* Canonical suffixed is "\"abcd\"?". */
|
||||
it("parses suffixed", function() {
|
||||
expect('start = "abcd"?').toParseAs(oneRuleGrammar(null, optionalLiteral));
|
||||
expect('start = "abcd"*').toParseAs(oneRuleGrammar(null, {
|
||||
type: "zero_or_more",
|
||||
expression: literalAbcd
|
||||
}));
|
||||
expect('start = "abcd"+').toParseAs(oneRuleGrammar(null, {
|
||||
type: "one_or_more",
|
||||
expression: literalAbcd
|
||||
}));
|
||||
expect('start = "abcd"' ).toParseAs(literalGrammar("abcd"));
|
||||
});
|
||||
|
||||
/* Canonical primary is "\"abcd\"". */
|
||||
it("parses primary", function() {
|
||||
expect('start = a' ).toParseAs(ruleRefGrammar("a"));
|
||||
|
|
|
@ -285,12 +285,4 @@ test("parses prefixed", function() {
|
|||
parserParses('start = "abcd"?', oneRuleGrammar(optionalLiteral));
|
||||
});
|
||||
|
||||
/* Canonical suffixed is "\"abcd\"?". */
|
||||
test("parses suffixed", function() {
|
||||
parserParses('start = "abcd"?', oneRuleGrammar(optionalLiteral));
|
||||
parserParses('start = "abcd"*', oneRuleGrammar(zeroOrMore(literalAbcd)));
|
||||
parserParses('start = "abcd"+', oneRuleGrammar(oneOrMore(literalAbcd)));
|
||||
parserParses('start = "abcd"', literalGrammar("abcd"));
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue