diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-04-06 01:22:00 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-04-06 01:22:32 -0700 |
commit | 80128a784912096c6b0ee46b76b068e019cff057 (patch) | |
tree | fcec0d4ae33eac780b308b45b5b5044b6f942353 | |
parent | 1e4aa42aa50fe4429f0a8d147af5254d5ec960a5 (diff) |
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.
-rw-r--r-- | test/automated/sort-tests.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/automated/sort-tests.el b/test/automated/sort-tests.el index 5297329781..f3a182cdc1 100644 --- a/test/automated/sort-tests.el +++ b/test/automated/sort-tests.el @@ -40,8 +40,10 @@ (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))))) |