Jasmine: Convert tests of parser's "simpleEscapeSequence" rule
This commit is contained in:
parent
2619becb9d
commit
2bb266bbaf
|
@ -72,6 +72,21 @@ describe("PEG.js grammar parser", function() {
|
|||
});
|
||||
});
|
||||
|
||||
/* Canonical simpleEscapeSequence is "\\n". */
|
||||
it("parses simpleEscapeSequence", function() {
|
||||
expect('start = "\\b"').toParseAs(literalGrammar("\b"));
|
||||
expect('start = "\\f"').toParseAs(literalGrammar("\f"));
|
||||
expect('start = "\\n"').toParseAs(literalGrammar("\n"));
|
||||
expect('start = "\\r"').toParseAs(literalGrammar("\r"));
|
||||
expect('start = "\\t"').toParseAs(literalGrammar("\t"));
|
||||
expect('start = "\\v"').toParseAs(literalGrammar("\x0B")); // no "\v" in IE
|
||||
expect('start = "\\a"').toParseAs(literalGrammar("a"));
|
||||
|
||||
expect('start = "\\1"').toFailToParse();
|
||||
expect('start = "\\x"').toFailToParse();
|
||||
expect('start = "\\u"').toFailToParse();
|
||||
});
|
||||
|
||||
/* Canonical zeroEscapeSequence is "\\0". */
|
||||
it("parses zeroEscapeSequence", function() {
|
||||
expect('start = "\\0"').toParseAs(literalGrammar("\x00"));
|
||||
|
|
|
@ -469,20 +469,4 @@ test("parses simpleBracketDelimitedCharacter", function() {
|
|||
parserDoesNotParse("start = [\u2029]");
|
||||
});
|
||||
|
||||
/* Canonical simpleEscapeSequence is "\\n". */
|
||||
test("parses simpleEscapeSequence", function() {
|
||||
parserParses('start = "\\\'"', literalGrammar("'"));
|
||||
parserParses('start = "\\""', literalGrammar("\""));
|
||||
parserParses('start = "\\\\"', literalGrammar("\\"));
|
||||
parserParses('start = "\\b"', literalGrammar("\b"));
|
||||
parserParses('start = "\\f"', literalGrammar("\f"));
|
||||
parserParses('start = "\\n"', literalGrammar("\n"));
|
||||
parserParses('start = "\\r"', literalGrammar("\r"));
|
||||
parserParses('start = "\\t"', literalGrammar("\t"));
|
||||
/* IE does not recognize "\v". */
|
||||
parserParses('start = "\\v"', literalGrammar("\x0B"));
|
||||
|
||||
parserParses('start = "\\a"', literalGrammar("a"));
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue