Port collation tests to glibc 2.27

* test/src/fns-tests.el (fns-tests-collate-strings)
(fns-tests-collate-sort): Don’t make unportable assumptions
about how en_US.UTF-8 collation works.  These assumptions
are not true on Fedora 28, which ships with glibc 2.27.
This commit is contained in:
Paul Eggert 2018-05-02 11:14:07 -07:00
parent 65ac27783a
commit f4b5ff20a6

View file

@ -119,10 +119,9 @@
;; In POSIX or C locales, collation order is lexicographic.
(should (string-collate-lessp "XYZZY" "xyzzy" "POSIX"))
;; In a language specific locale, collation order is different.
(should (string-collate-lessp
"xyzzy" "XYZZY"
(if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8")))
;; In a language specific locale on MS-Windows, collation order is different.
(when (eq system-type 'windows-nt)
(should (string-collate-lessp "xyzzy" "XYZZY" "enu_USA")))
;; Ignore case.
(should (string-collate-equalp "xyzzy" "XYZZY" nil t))
@ -154,8 +153,6 @@
(9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")])))
(ert-deftest fns-tests-collate-sort ()
;; See https://lists.gnu.org/r/emacs-devel/2015-10/msg02505.html.
:expected-result (if (eq system-type 'cygwin) :failed :passed)
(skip-unless (fns-tests--collate-enabled-p))
;; Punctuation and whitespace characters are relevant for POSIX.
@ -165,15 +162,16 @@
(lambda (a b) (string-collate-lessp a b "POSIX")))
'("1 1" "1 2" "1.1" "1.2" "11" "12")))
;; Punctuation and whitespace characters are not taken into account
;; for collation in other locales.
(should
(equal
(sort '("11" "12" "1 1" "1 2" "1.1" "1.2")
(lambda (a b)
(let ((w32-collate-ignore-punctuation t))
(string-collate-lessp
a b (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8")))))
'("11" "1 1" "1.1" "12" "1 2" "1.2")))
;; for collation in other locales, on MS-Windows systems.
(when (eq system-type 'windows-nt)
(should
(equal
(sort '("11" "12" "1 1" "1 2" "1.1" "1.2")
(lambda (a b)
(let ((w32-collate-ignore-punctuation t))
(string-collate-lessp
a b "enu_USA"))))
'("11" "1 1" "1.1" "12" "1 2" "1.2"))))
;; Diacritics are different letters for POSIX, they sort lexicographical.
(should
@ -181,15 +179,17 @@
(sort '("Ævar" "Agustín" "Adrian" "Eli")
(lambda (a b) (string-collate-lessp a b "POSIX")))
'("Adrian" "Agustín" "Eli" "Ævar")))
;; Diacritics are sorted between similar letters for other locales.
(should
(equal
(sort '("Ævar" "Agustín" "Adrian" "Eli")
(lambda (a b)
(let ((w32-collate-ignore-punctuation t))
(string-collate-lessp
a b (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8")))))
'("Adrian" "Ævar" "Agustín" "Eli"))))
;; Diacritics are sorted between similar letters for other locales,
;; on MS-Windows systems.
(when (eq system-type 'windows-nt)
(should
(equal
(sort '("Ævar" "Agustín" "Adrian" "Eli")
(lambda (a b)
(let ((w32-collate-ignore-punctuation t))
(string-collate-lessp
a b "enu_USA"))))
'("Adrian" "Ævar" "Agustín" "Eli")))))
(ert-deftest fns-tests-string-version-lessp ()
(should (string-version-lessp "foo2.png" "foo12.png"))