File: cl.el

package info (click to toggle)
python-docutils 0.13.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,728 kB
  • ctags: 7,259
  • sloc: python: 43,776; lisp: 13,142; xml: 1,644; sh: 164; makefile: 151
file content (67 lines) | stat: -rw-r--r-- 2,462 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
;; Tests for replacement functions for `cl.el'

(add-to-list 'load-path ".")
(load "init" nil t)
(init-rst-ert nil)

(ert-deftest rst-signum ()
  "Test `rst-signum'."
  (should (equal (rst-signum 10) 1))
  (should (equal (rst-signum -10) -1))
  (should (equal (rst-signum 0) 0))
  )

(ert-deftest rst-some ()
  "Test `rst-some'."
  (should (equal (rst-some nil) nil))
  (should (equal (rst-some '(t)) t))
  (should (equal (rst-some '(0)) 0))
  (should (equal (rst-some '(1)) 1))
  (should (equal (rst-some '(nil 1)) 1))
  (should (equal (rst-some '(nil nil)) nil))
  (should (equal (rst-some nil 'not) nil))
  (should (equal (rst-some '(t) 'not) nil))
  (should (equal (rst-some '(0) 'not) nil))
  (should (equal (rst-some '(1 nil) 'not) t))
  (should (equal (rst-some '(nil 1) 'not) t))
  (should (equal (rst-some '(nil nil) 'not) t))
  )

(ert-deftest rst-position ()
  "Test `rst-position'."
  (should (equal (rst-position nil nil) nil))
  (should (equal (rst-position t '(nil)) nil))
  (should (equal (rst-position nil '(t)) nil))
  (should (equal (rst-position nil '(nil)) 0))
  (should (equal (rst-position t '(t)) 0))
  (should (equal (rst-position t '(nil t)) 1))
  (should (equal (rst-position t '(nil t t nil sym)) 1))
  (should (equal (rst-position t '(nil (t) t nil sym)) 2))
  (should (equal (rst-position 'sym '(nil (t) t nil sym)) 4))
  (should (equal (rst-position 'sym '(nil (t) t nil t)) nil))
  (should (equal (rst-position '(t) '(nil (t) t nil sym)) 1))
  (should (equal (rst-position '(1 2 3) '(nil (t) t nil sym)) nil))
  (should (equal (rst-position '(1 2 3) '(nil (t) t (1 2 3) t)) 3))
  (should (equal (rst-position '(1 2 3) '(nil (t) t (1 2 3) (1 2 3))) 3))
  )

(ert-deftest rst-position-if ()
  "Test `rst-position-if'."
  (should (equal (rst-position-if 'not '(t nil nil)) 1))

  (should (equal (rst-position-if 'not nil) nil))
  (should (equal (rst-position-if 'identity '(nil)) nil))
  (should (equal (rst-position-if 'not '(t)) nil))
  (should (equal (rst-position-if 'not '(nil)) 0))
  (should (equal (rst-position-if 'not '(nil nil)) 0))
  (should (equal (rst-position-if 'not '(t t nil)) 2))
  )

(ert-deftest rst-member-if ()
  "Test `rst-member-if'."
  (let ((eql-3 (lambda (el) (equal el 3))))
    (should (equal (rst-member-if eql-3 nil) nil))
    (should (equal (rst-member-if eql-3 '(1 2)) nil))
    (should (equal (rst-member-if eql-3 '(1 2 3)) '(3)))
    (should (equal (rst-member-if eql-3 '(1 2 3 4)) '(3 4)))
    ))