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

redux
David Majda 13 years ago
parent 328edf667c
commit dac3b0d8d9

@ -41,10 +41,43 @@ describe("PEG.js grammar parser", function() {
return false;
}
},
toFailToParse: function() {
var result;
try {
result = PEG.parser.parse(this.actual);
this.message = function() {
return "Expected " + jasmine.pp(this.actual) + " to fail to parse, "
+ "but it parsed as " + jasmine.pp(result) + ".";
};
return false;
} catch (e) {
this.message = function() {
return "Expected " + jasmine.pp(this.actual) + " to parse, "
+ "but it failed with message "
+ jasmine.pp(e.message) + ".";
};
return true;
}
}
});
});
// Canonical multiLineComment is "/* comment */".
it("parses multiLineComment", function() {
expect('start =/**/"abcd"' ).toParseAs(trivialGrammar);
expect('start =/*a*/"abcd"' ).toParseAs(trivialGrammar);
expect('start =/*aaa*/"abcd"').toParseAs(trivialGrammar);
expect('start =/***/"abcd"' ).toParseAs(trivialGrammar);
expect('start =/**/*/"abcd"').toFailToParse();
});
/* Canonical eol is "\n". */
it("parses eol", function() {
expect('start =\n"abcd"' ).toParseAs(trivialGrammar);

@ -549,18 +549,4 @@ test("parses singleLineComment", function() {
parserParses('start = "abcd"//', simpleGrammar);
});
// Canonical multiLineComment is "\/* comment *\/".
test("parses multiLineComment", function() {
parserParses('start =/**/"abcd"', simpleGrammar);
parserParses('start =/*a*/"abcd"', simpleGrammar);
parserParses('start =/*aaa*/"abcd"', simpleGrammar);
parserParses('start =/*\n*/"abcd"', simpleGrammar);
parserParses('start =/***/"abcd"', simpleGrammar);
parserParses('start =/*a/*/"abcd"', simpleGrammar);
parserDoesNotParse('start =/*"abcd"');
parserDoesNotParse('start =/*/"abcd"');
parserDoesNotParse('start =/*/**/*/"abcd"');
});
})();

Loading…
Cancel
Save