Fix stability confusion in sort-tests

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.
This commit is contained in:
Paul Eggert 2016-04-06 01:22:00 -07:00
parent 1e4aa42aa5
commit 80128a7849

View file

@ -40,8 +40,10 @@
(funcall function reverse (point-min) (point-max)) (funcall function reverse (point-min) (point-max))
(let ((sorted-words (let ((sorted-words
(mapconcat #'identity (mapconcat #'identity
(let ((x (sort (copy-sequence words) less-predicate))) (sort (copy-sequence words)
(if reverse (reverse x) x)) (if reverse
(lambda (a b) (funcall less-predicate b a))
less-predicate))
separator))) separator)))
(should (string= (substring (buffer-string) 0 -1) sorted-words))))) (should (string= (substring (buffer-string) 0 -1) sorted-words)))))