Jasmine: Convert tests of parser's "eolEscapeSequence" rule
This commit is contained in:
parent
4f91286013
commit
a27dc5ae4a
|
@ -1,8 +1,8 @@
|
||||||
describe("PEG.js grammar parser", function() {
|
describe("PEG.js grammar parser", function() {
|
||||||
var trivialGrammar;
|
var trivialGrammar;
|
||||||
|
|
||||||
beforeEach(function() {
|
function literalGrammar(value) {
|
||||||
trivialGrammar = {
|
return {
|
||||||
type: "grammar",
|
type: "grammar",
|
||||||
initializer: null,
|
initializer: null,
|
||||||
rules: [
|
rules: [
|
||||||
|
@ -10,11 +10,15 @@ describe("PEG.js grammar parser", function() {
|
||||||
type: "rule",
|
type: "rule",
|
||||||
name: "start",
|
name: "start",
|
||||||
displayName: null,
|
displayName: null,
|
||||||
expression: { type: "literal", value: "abcd", ignoreCase: false }
|
expression: { type: "literal", value: value, ignoreCase: false }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
startRule: "start"
|
startRule: "start"
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
trivialGrammar = literalGrammar("abcd");
|
||||||
|
|
||||||
this.addMatchers({
|
this.addMatchers({
|
||||||
toParseAs: function(expected) {
|
toParseAs: function(expected) {
|
||||||
|
@ -68,6 +72,15 @@ describe("PEG.js grammar parser", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Canonical eolEscapeSequence is "\\\n". */
|
||||||
|
it("parses eolEscapeSequence", function() {
|
||||||
|
expect('start = "\\\n"' ).toParseAs(literalGrammar("\n"));
|
||||||
|
expect('start = "\\\r\n"' ).toParseAs(literalGrammar("\r\n"));
|
||||||
|
expect('start = "\\\r"' ).toParseAs(literalGrammar("\r"));
|
||||||
|
expect('start = "\\\u2028"').toParseAs(literalGrammar("\u2028"));
|
||||||
|
expect('start = "\\\u2029"').toParseAs(literalGrammar("\u2029"));
|
||||||
|
});
|
||||||
|
|
||||||
/* Trivial character class rules are not tested. */
|
/* Trivial character class rules are not tested. */
|
||||||
|
|
||||||
/* Canonical __ is "\n". */
|
/* Canonical __ is "\n". */
|
||||||
|
|
|
@ -516,13 +516,4 @@ test("parses unicodeEscapeSequence", function() {
|
||||||
parserParses('start = "\\u01234"', literalGrammar("\u01234"));
|
parserParses('start = "\\u01234"', literalGrammar("\u01234"));
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Canonical eolEscapeSequence is "\\\n". */
|
|
||||||
test("parses eolEscapeSequence", function() {
|
|
||||||
parserParses('start = "\\\n"', literalGrammar("\n"));
|
|
||||||
parserParses('start = "\\\r\n"', literalGrammar("\r\n"));
|
|
||||||
parserParses('start = "\\\r"', literalGrammar("\r"));
|
|
||||||
parserParses('start = "\\\u2028"', literalGrammar("\u2028"));
|
|
||||||
parserParses('start = "\\\u2029"', literalGrammar("\u2029"));
|
|
||||||
});
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue