From deaadc19c8a59b69bc53b735f9f66e93304010e9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 30 Apr 2018 10:35:04 -0700 Subject: [PATCH] Port collation tests to glibc 2.27 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. --- test/src/fns-tests.el | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index f8554636ba..491915f56a 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el @@ -119,10 +119,9 @@ fns-tests--collate-enabled-p ;; 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" "en_US.UTF-8"))) ;; Ignore case. (should (string-collate-equalp "xyzzy" "XYZZY" nil t)) @@ -154,8 +153,6 @@ fns-tests--collate-enabled-p (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 @@ fns-tests--collate-enabled-p (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 @@ fns-tests--collate-enabled-p (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")) -- 2.17.0