From 9d3bf9ffdc8aaf2a04288c743116716ad6e4e78a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 6 Apr 2016 01:22:00 -0700 Subject: [PATCH] Fix stability confusion in sort-tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem reported by Philipp Stephani (Bug#23205). * test/automated/sort-tests.el: (sort-tests--insert-words-sort-and-compare): Don’t assume that reversing a sorted list is the same as sorting with the reverse predicate. This is not true for stable sorts when items compare equal. --- test/automated/sort-tests.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/automated/sort-tests.el b/test/automated/sort-tests.el index 5297329..f3a182c 100644 --- a/test/automated/sort-tests.el +++ b/test/automated/sort-tests.el @@ -40,8 +40,10 @@ sort-tests--insert-words-sort-and-compare (funcall function reverse (point-min) (point-max)) (let ((sorted-words (mapconcat #'identity - (let ((x (sort (copy-sequence words) less-predicate))) - (if reverse (reverse x) x)) + (sort (copy-sequence words) + (if reverse + (lambda (a b) (funcall less-predicate b a)) + less-predicate)) separator))) (should (string= (substring (buffer-string) 0 -1) sorted-words))))) -- 2.5.5