-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-tests.el
77 lines (64 loc) · 2.07 KB
/
v-tests.el
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
68
69
70
71
72
73
74
75
76
77
;; v-tests.el --- -*- lexical-binding: t; -*-
;; Copyright (C) Sergey Vinokurov
;;
;; Author: Sergey Vinokurov <sergey@debian>
;; Created: 21 February 2020
;; Description:
(require 'v)
(ert-deftest v/v-find ()
(let ((xs [1 2 3 4 5]))
(should (equal 3
(v--find (< 2 it) xs)))
(should (equal 5
(v--find (= 5 it) xs)))
(should (equal nil
(v--find (= 6 it) xs)))))
(ert-deftest v/v-find-idx ()
(let ((xs [1 2 3 4 5]))
(should (equal 3
(v--find-idx (> it 3) xs)))
(should (equal 2
(v--find-idx (< 2 it) xs)))
(should (equal 4
(v--find-idx (= 5 it) xs)))
(should (equal nil
(v--find-idx (= 6 it) xs)))))
(ert-deftest v/v-assq ()
(let ((xs (vector (cons 'x 1) (cons 'y "foo") (cons 'z nil))))
(should (equal (cons 'x 1)
(v-assq 'x xs)))
(should (equal (cons 'y "foo")
(v-assq 'y xs)))
(should (equal (cons 'z nil)
(v-assq 'z xs)))
(should (equal nil
(v-assq 'w xs)))))
(ert-deftest v/v-member ()
(let ((xs (vector (cons 'x 1) (cons 'y "foo") (cons 'z nil) "foo" "bar" "baz")))
(should-not (v-member 'x xs))
(should-not (v-member 'y xs))
(should-not (v-member 'z xs))
(should-not (v-member 'w xs))
(should (v-member "foo" xs))
(should (v-member "bar" xs))
(should (v-member "baz" xs))
(should (v-member (cons 'x 1) xs))))
(ert-deftest v/v-memq ()
(let ((xs (vector (cons 'x 1) (cons 'y "foo") (cons 'z nil) "foo" "bar" "baz" 1 2 'a 'b)))
(should-not (v-memq 'x xs))
(should-not (v-memq 'y xs))
(should-not (v-memq 'z xs))
(should-not (v-memq 'w xs))
(should-not (v-memq "foo" xs))
(should-not (v-memq "bar" xs))
(should-not (v-memq "baz" xs))
(should-not (v-memq (cons 'x 1) xs))
(should (v-memq 1 xs))
(should (v-memq 2 xs))
(should (v-memq 'a xs))
(should (v-memq 'b xs))
(should-not (v-memq 'c xs))))
(ert "v/.*")
;; Local Variables:
;; End:
;; v-tests.el ends here