improve backwards compatibility of patch [ 120 ]
[docutils.git] / docutils / tools / editors / emacs / tests / cl.el
blob2ee56599a7692fa7a7339e433fda59f1628f6ac2
1 ;; Tests for replacement functions for `cl.el'
3 (add-to-list 'load-path ".")
4 (load "init" nil t)
5 (init-rst-ert nil)
7 (ert-deftest rst-signum ()
8 "Test `rst-signum'."
9 (should (equal (rst-signum 10) 1))
10 (should (equal (rst-signum -10) -1))
11 (should (equal (rst-signum 0) 0))
14 (ert-deftest rst-some ()
15 "Test `rst-some'."
16 (should (equal (rst-some nil) nil))
17 (should (equal (rst-some '(t)) t))
18 (should (equal (rst-some '(0)) 0))
19 (should (equal (rst-some '(1)) 1))
20 (should (equal (rst-some '(nil 1)) 1))
21 (should (equal (rst-some '(nil nil)) nil))
22 (should (equal (rst-some nil 'not) nil))
23 (should (equal (rst-some '(t) 'not) nil))
24 (should (equal (rst-some '(0) 'not) nil))
25 (should (equal (rst-some '(1 nil) 'not) t))
26 (should (equal (rst-some '(nil 1) 'not) t))
27 (should (equal (rst-some '(nil nil) 'not) t))
30 (ert-deftest rst-position ()
31 "Test `rst-position'."
32 (should (equal (rst-position nil nil) nil))
33 (should (equal (rst-position t '(nil)) nil))
34 (should (equal (rst-position nil '(t)) nil))
35 (should (equal (rst-position nil '(nil)) 0))
36 (should (equal (rst-position t '(t)) 0))
37 (should (equal (rst-position t '(nil t)) 1))
38 (should (equal (rst-position t '(nil t t nil sym)) 1))
39 (should (equal (rst-position t '(nil (t) t nil sym)) 2))
40 (should (equal (rst-position 'sym '(nil (t) t nil sym)) 4))
41 (should (equal (rst-position 'sym '(nil (t) t nil t)) nil))
42 (should (equal (rst-position '(t) '(nil (t) t nil sym)) 1))
43 (should (equal (rst-position '(1 2 3) '(nil (t) t nil sym)) nil))
44 (should (equal (rst-position '(1 2 3) '(nil (t) t (1 2 3) t)) 3))
45 (should (equal (rst-position '(1 2 3) '(nil (t) t (1 2 3) (1 2 3))) 3))
48 (ert-deftest rst-position-if ()
49 "Test `rst-position-if'."
50 (should (equal (rst-position-if 'not '(t nil nil)) 1))
52 (should (equal (rst-position-if 'not nil) nil))
53 (should (equal (rst-position-if 'identity '(nil)) nil))
54 (should (equal (rst-position-if 'not '(t)) nil))
55 (should (equal (rst-position-if 'not '(nil)) 0))
56 (should (equal (rst-position-if 'not '(nil nil)) 0))
57 (should (equal (rst-position-if 'not '(t t nil)) 2))
60 (ert-deftest rst-member-if ()
61 "Test `rst-member-if'."
62 (let ((eql-3 (lambda (el) (equal el 3))))
63 (should (equal (rst-member-if eql-3 nil) nil))
64 (should (equal (rst-member-if eql-3 '(1 2)) nil))
65 (should (equal (rst-member-if eql-3 '(1 2 3)) '(3)))
66 (should (equal (rst-member-if eql-3 '(1 2 3 4)) '(3 4)))