diff options
| author | Dmitry Antipov | 2014-08-29 11:29:47 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-08-29 11:29:47 +0400 |
| commit | 1764ec4414074ea0dcbd912efdfbedb119f8ed3b (patch) | |
| tree | 0d577861c3e8a3e3e7a554adef7bcb04e0de5c38 /test | |
| parent | 483dc86ad0e60a1a6da498f9eb95672f286a4ab5 (diff) | |
| download | emacs-1764ec4414074ea0dcbd912efdfbedb119f8ed3b.tar.gz emacs-1764ec4414074ea0dcbd912efdfbedb119f8ed3b.zip | |
Add vectors support to Fsort.
* configure.ac (AC_CHECK_FUNCS): Check for qsort_r.
* src/fns.c (sort_vector, sort_vector_compare): New functions.
(sort_list): Likewise, refactored out of ...
(Fsort): ... adjusted user. Mention vectors in docstring.
(sort_vector_predicate) [!HAVE_QSORT_R]: New variable.
* src/alloc.c (make_save_int_obj): New function.
* src/lisp.h (enum Lisp_Save_Type): New member SAVE_TYPE_INT_OBJ.
(make_save_int_obj): Add prototype.
* test/automated/fns-tests.el (fns-tests-sort): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/fns-tests.el | 18 |
2 files changed, 22 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 7546dd1fb46..70c2af66194 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-08-29 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/fns-tests.el (fns-tests-sort): New test. | ||
| 4 | |||
| 1 | 2014-08-28 Glenn Morris <rgm@gnu.org> | 5 | 2014-08-28 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * automated/python-tests.el (python-shell-calculate-exec-path-2): | 7 | * automated/python-tests.el (python-shell-calculate-exec-path-2): |
diff --git a/test/automated/fns-tests.el b/test/automated/fns-tests.el index d3d921f425f..a6c45443db6 100644 --- a/test/automated/fns-tests.el +++ b/test/automated/fns-tests.el | |||
| @@ -100,3 +100,21 @@ | |||
| 100 | (should (compare-strings "こんにちはコンニチハ" nil nil "こんにちはコンニチハ" nil nil)) | 100 | (should (compare-strings "こんにちはコンニチハ" nil nil "こんにちはコンニチハ" nil nil)) |
| 101 | (should (= (compare-strings "んにちはコンニチハこ" nil nil "こんにちはコンニチハ" nil nil) 1)) | 101 | (should (= (compare-strings "んにちはコンニチハこ" nil nil "こんにちはコンニチハ" nil nil) 1)) |
| 102 | (should (= (compare-strings "こんにちはコンニチハ" nil nil "んにちはコンニチハこ" nil nil) -1))) | 102 | (should (= (compare-strings "こんにちはコンニチハ" nil nil "んにちはコンニチハこ" nil nil) -1))) |
| 103 | |||
| 104 | (ert-deftest fns-tests-sort () | ||
| 105 | (should (equal (sort '(9 5 2 -1 5 3 8 7 4) (lambda (x y) (< x y))) | ||
| 106 | '(-1 2 3 4 5 5 7 8 9))) | ||
| 107 | (should (equal (sort '(9 5 2 -1 5 3 8 7 4) (lambda (x y) (> x y))) | ||
| 108 | '(9 8 7 5 5 4 3 2 -1))) | ||
| 109 | (should (equal (sort '[9 5 2 -1 5 3 8 7 4] (lambda (x y) (< x y))) | ||
| 110 | [-1 2 3 4 5 5 7 8 9])) | ||
| 111 | (should (equal (sort '[9 5 2 -1 5 3 8 7 4] (lambda (x y) (> x y))) | ||
| 112 | [9 8 7 5 5 4 3 2 -1])) | ||
| 113 | (should (equal | ||
| 114 | (sort | ||
| 115 | (vector | ||
| 116 | (cons 8 "xxx") (cons 9 "aaa") (cons 8 "bbb") (cons 9 "zzz") | ||
| 117 | (cons 9 "ppp") (cons 8 "ttt") (cons 8 "eee") (cons 9 "fff")) | ||
| 118 | (lambda (x y) (< (car x) (car y)))) | ||
| 119 | [(8 . "xxx") (8 . "bbb") (8 . "ttt") (8 . "eee") | ||
| 120 | (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")]))) | ||