diff options
| author | Philipp Stephani | 2019-01-17 23:39:19 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2019-01-20 00:04:19 +0100 |
| commit | 551051596fe51d6e232315eeda8a0a79eb43bfdf (patch) | |
| tree | dd2b179cb2dbe29fbea8d26fdd73ca8a29dae154 | |
| parent | 3e1255172334f3c0645d37eb92c05a628fa3d548 (diff) | |
| download | emacs-551051596fe51d6e232315eeda8a0a79eb43bfdf.tar.gz emacs-551051596fe51d6e232315eeda8a0a79eb43bfdf.zip | |
Improve error data when passing a wrong type to 'sort' (Bug#34104)
* src/fns.c (Fsort): Use 'list-or-vector-p' for error message.
(syms_of_fns): Define 'list-or-vector-p'.
* test/src/fns-tests.el (fns-tests-sort): Extend unit test.
| -rw-r--r-- | src/fns.c | 3 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 5 |
2 files changed, 6 insertions, 2 deletions
| @@ -2084,7 +2084,7 @@ the second. */) | |||
| 2084 | else if (VECTORP (seq)) | 2084 | else if (VECTORP (seq)) |
| 2085 | sort_vector (seq, predicate); | 2085 | sort_vector (seq, predicate); |
| 2086 | else if (!NILP (seq)) | 2086 | else if (!NILP (seq)) |
| 2087 | wrong_type_argument (Qsequencep, seq); | 2087 | wrong_type_argument (Qlist_or_vector_p, seq); |
| 2088 | return seq; | 2088 | return seq; |
| 2089 | } | 2089 | } |
| 2090 | 2090 | ||
| @@ -5358,6 +5358,7 @@ Used by `featurep' and `require', and altered by `provide'. */); | |||
| 5358 | DEFSYM (Qsubfeatures, "subfeatures"); | 5358 | DEFSYM (Qsubfeatures, "subfeatures"); |
| 5359 | DEFSYM (Qfuncall, "funcall"); | 5359 | DEFSYM (Qfuncall, "funcall"); |
| 5360 | DEFSYM (Qplistp, "plistp"); | 5360 | DEFSYM (Qplistp, "plistp"); |
| 5361 | DEFSYM (Qlist_or_vector_p, "list-or-vector-p"); | ||
| 5361 | 5362 | ||
| 5362 | #ifdef HAVE_LANGINFO_CODESET | 5363 | #ifdef HAVE_LANGINFO_CODESET |
| 5363 | DEFSYM (Qcodeset, "codeset"); | 5364 | DEFSYM (Qcodeset, "codeset"); |
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 3d1a8b37b4e..d6cc99e8e33 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -161,7 +161,10 @@ | |||
| 161 | '(9 . "ppp") '(8 . "ttt") '(8 . "eee") '(9 . "fff")) | 161 | '(9 . "ppp") '(8 . "ttt") '(8 . "eee") '(9 . "fff")) |
| 162 | (lambda (x y) (< (car x) (car y)))) | 162 | (lambda (x y) (< (car x) (car y)))) |
| 163 | [(8 . "xxx") (8 . "bbb") (8 . "ttt") (8 . "eee") | 163 | [(8 . "xxx") (8 . "bbb") (8 . "ttt") (8 . "eee") |
| 164 | (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")]))) | 164 | (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")])) |
| 165 | ;; Bug#34104 | ||
| 166 | (should (equal (should-error (sort "cba" #'<) :type 'wrong-type-argument) | ||
| 167 | '(wrong-type-argument list-or-vector-p "cba")))) | ||
| 165 | 168 | ||
| 166 | (ert-deftest fns-tests-collate-sort () | 169 | (ert-deftest fns-tests-collate-sort () |
| 167 | (skip-unless (fns-tests--collate-enabled-p)) | 170 | (skip-unless (fns-tests--collate-enabled-p)) |