-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_edn.el
84 lines (67 loc) · 2.53 KB
/
test_edn.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
78
79
80
81
82
83
84
(require 'ert)
(require 'edn)
(require 'dash)
;; (require 'websocket)
(ert-deftest edn-test-number-encode ()
(let ((input 150)
(output "150"))
(should (string-equal (edn-encode input) output))))
(ert-deftest edn-test-string-encode ()
(let ((input "hello world")
(output "\"hello world\""))
(should (string-equal (edn-encode input) output))))
(ert-deftest edn-test-simple-list-encode ()
(let ((input (list "hello" "world"))
(output "(\"hello\" \"world\")"))
(should (string-equal (edn-encode-list input) output))))
(ert-deftest edn-test-alist-p ()
(should (edn-alist-p '((:hello . world)
(:hola . mundo))))
;;(should (null (edn-alist-p '(:hello world how))))
)
(let ((it '(:hell "world" "blah")))
(or (not (consp (cdr it)))
(equal 2 (length it))))
(ert-deftest edn-test-alist-encode ()
(let ((input (list '(:hello . "world") '("hola" . 123)))
(output "{:hello \"world\" \"hola\" 123}"))))
(ert-deftest edn-test-simple-vector-encode ()
(let ((input ["hello" "world"])
(output "[\"hello\" \"world\"]"))
(should (string-equal (edn-encode-vector input) output))))
(ert-deftest edn-test-timestamp-encode ()
(let ((edn-encode-timestamp t)
(input '(20788 63147))
(output "#inst \"2013-03-04T11:31:55-08:00\""))
(should (string-equal (edn-encode input) output))))
(ert-deftest edn-test-true-encode ()
(let ((input t)
(output "true"))
(should (string-equal (edn-encode input) output))))
(ert-deftest edn-test-encode-with-slash ()
(let ((input "/hello/world")
(output "\"/hello/world\""))
(should (string-equal (edn-encode input) output))))
(ert-deftest edn-test-nil-encode ()
(let ((input nil)
(output "nil"))
(should (string-equal (edn-encode input) output))))
;; (ert-deftest edn-test-complex-1-encode ()
;; (let ((edn-encode-timestamp t)
;; (input (list
;; :is-modified t
;; :last-save-time "2013-03-04T11:31:55-08:00"
;; :file nil
;; :major-mode "emacs-lisp-mode"
;; :buffer-name "pulse.el"
;; :default-directory "/home/roman/Projects/pulse/"
;; :read-only nil))
;; (edn-encode input))))
;; (ert-make-test-unbound 'edn-test-complex-1-encode)
;; (ert-deftest test-list-serialization ()
;; ""
;; (let ((list ))
;; (sleep-for 0.1)
;; (should (websocket-openp conn))
;; (--dotimes 5 (websocket-send-text conn (format "Hello World %i" it)))
;; (websocket-close conn)))