]> code.delx.au - gnu-emacs/commitdiff
Fix stability confusion in sort-tests
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 6 Apr 2016 08:22:00 +0000 (01:22 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 6 Apr 2016 08:22:32 +0000 (01:22 -0700)
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

index 529732978185f83b120912b6c96bace2e356e79d..f3a182cdc14036ddbaadea9987b1fd57e8c289f8 100644 (file)
     (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)))))