From 74830d4f8f1d7d215c0b60c1ff31f823dc520822 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 11 Apr 2010 15:34:30 +0200 Subject: [PATCH] Sort expected strings in the error messages. --- lib/runtime.js | 1 + test/compiler-test.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/runtime.js b/lib/runtime.js index e45394e..22d28d9 100644 --- a/lib/runtime.js +++ b/lib/runtime.js @@ -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]; diff --git a/test/compiler-test.js b/test/compiler-test.js index 0d05ddc..3e7e61e 100644 --- a/test/compiler-test.js +++ b/test/compiler-test.js @@ -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() {