Sort expected strings in the error messages.

redux
David Majda 15 years ago
parent 37521cffa5
commit 74830d4f8f

@ -124,6 +124,7 @@ PEG.Parser.prototype = {
case 1:
return failuresExpected[0];
default:
failuresExpected.sort();
return failuresExpected.slice(0, failuresExpected.length - 1).join(", ")
+ " or "
+ failuresExpected[failuresExpected.length - 1];

@ -463,6 +463,13 @@ test("error messages", function() {
"",
'Expected "a" but end of input found.'
);
var unsortedErrorsParser = PEG.buildParser('start: "b" / "a"');
doesNotParseWithMessage(
unsortedErrorsParser,
"",
'Expected "a" or "b" but end of input found.'
);
});
test("error positions", function() {

Loading…
Cancel
Save