-
Notifications
You must be signed in to change notification settings - Fork 4
/
arr-test.el
77 lines (66 loc) · 2.04 KB
/
arr-test.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
;;; arr-test.el --- Tests for arr -*- lexical-binding: t -*-
;;; Commentary:
;; Tests for arrow macros
;;; Code:
(add-to-list 'load-path ".") ;; hack to get the library to load.
(require 'arr)
(ert-deftest arr->test ()
(should (= (arr-> 10 (/ 5)) 2)))
(ert-deftest arr->>test ()
(should (= (arr->> 10 (/ 5)) 0)))
(ert-deftest arr->*test ()
(should (= (arr->> 3
(/ 12)
(arr->* (/ 2)))
2)))
(ert-deftest arr-?>test ()
(should (null (arr-?> 3
(+ 5)
(member '(2 5 9))
cl-first
(* 9))))
(should (= (arr-?> 3
(+ 5)
(member '(2 5 8 9))
cl-first
(* 9))
72))
(should (= (arr-?> 3
(+ 5)
(member '(2 5 8 9))
cl-second
(* 9))
81))
(should (null (arr-?> 3
(+ 5)
(member '(2 5 8 9))
cl-third
(* 9))))
(should (null (arr-?> '(:a 1)
(cl-getf :b)
1+))))
(ert-deftest arr-?>>test ()
(should (= (arr-?>> '((:a . 3) (:b . 5))
(assoc :a)
cdr
1+)
4))
(should (null (arr-?>> '((:a . 3) (:b . 5))
(assoc :c)
cdr
1+))))
(ert-deftest arr-<>test ()
(should (equal (arr-<> 10
(list 9 <> 11)
(seq-elt 1))
10)))
(ert-deftest arr-<>>test ()
(should (equal (arr-<>> 10
(list 9 <> 11)
(seq-map #'1+)
(seq-elt <> 1))
11)))
(ert-deftest arr-fn->test ()
(should (equal (seq-map (arr-fn-> (1+) (number-to-string)) '(1 2 3))
'("2" "3" "4"))))
;;; arr-test.el ends here