-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.el
164 lines (136 loc) · 3.5 KB
/
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
;;; test.el --- Testing routines for ellit-org.el -*- lexical-binding:t -*-
(require 'ellit-org)
(defun ellit-org-file--on-str (content &rest props)
"Execute `ellit-org--include' on CONTENT string."
(let ((el-file (concat (make-temp-file "ellit-org-el-file") ".el")))
(write-region content nil el-file nil 'quiet)
(unwind-protect
(with-temp-buffer
(apply #'ellit-org--include el-file props)
(buffer-string))
(delete-file el-file))))
(defun ellit-org--should (content should-content &optional template-alist)
"Same as `should', but takes into account `ellit-org' specifics."
(should (equal (ellit-org-file--on-str content template-alist)
should-content)))
;; Tests
(ert-deftest ellit-org--comments-starting ()
"Test processing starting point."
;; See "* Commenting .el files" section
(ellit-org--should "\
;; * This starts processing, buffer-start
;; Processing continues
"
"\
* This starts processing, buffer-start
Processing continues
")
(ellit-org--should "\
;; * This also starts processing, empty line after buffer-start
;; Processing continues
"
"\
* This also starts processing, empty line after buffer-start
Processing continues
")
;; Heading in the middle of the commentary block
(ellit-org--should "\
;; * This starts processing, 1line
;; Processing continues
'(<--- stops processing here)
;; New not matching commentary block
;; * Heading in the middle
;; - List in the middle
;; 1) Another list
;;
;; * Second section
;; * New heading starting commentary block
"
"\
* This starts processing, 1line
Processing continues
* New heading starting commentary block
")
(ellit-org--should "\
;; #+title: included1
;; Not included
;; * Included2
;; Also included
'(code here)
;; Not icluded
"
"\
#+title: included1
* Included2
Also included
")
)
(ert-deftest ellit-org--comments-leading-trailing-strips ()
"Test leading/trailing part of the file is trimmed."
(ellit-org--should "\
'(Leading line1)
'(leading line2)
;; #+title: processing starts here
;; Processing continues
'(Processing stops here)
'(This is not processed)
"
"\
#+title: processing starts here
Processing continues
")
)
(ert-deftest ellit-org--comments-empty-line ()
"Test empty line comments is ok."
(ellit-org--should "\
;; #+title: processing starts here
;;
;; Processing continues
;; Still continue processing
'(<------- Processing stops here)
;; - And continues here
;;
;; And here still processing
'(stop here)
"
"\
#+title: processing starts here
Processing continues
Still continue processing
- And continues here
And here still processing
")
)
(ert-deftest ellit-org--comments-non-comment-stops ()
"Test that non-comment line stops processing."
(ellit-org--should "\
;; #+title: included1
;; Not included
;; * Included2
;; Also included
'(code here)
;; Not icluded
"
"\
#+title: included1
* Included2
Also included
")
)
(ert-deftest ellit-org--comments-heading-in-the-middle ()
"Test property/heading/list occurs in the middle of comment line."
(ellit-org--should "\
;; #+title: this line is included
;; Processing continues
;; This line should - not be included
;; - This line is ALSO NOT included
;; This is * not * included
;; This line #+either should not be included
"
"\
#+title: this line is included
Processing continues
")
)
;;; TODO Testing templates and exporting
;;; test.el ends here