03_test_environment.md 7.25 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11


Test of parser: "block_environment"
===================================


Match-test "1"
--------------

### Test-code:
    \begin{generic}
12
13
        A generic block element is a block element
        that is unknown to DHParser.
14
    
15
16
17
18
19
        Unknown begin-end-structures are always
        considered as block elements and not
        as inline elements.
        \end{generic}
        
20
21
22

### AST
    (generic_block
eckhart's avatar
eckhart committed
23
24
        (begin_environment
            "generic"
25
        )
eckhart's avatar
eckhart committed
26
27
28
29
        (paragraph
            (text
                "A generic block element is a block element"
                "that is unknown to DHParser."
30
31
            )
        )
eckhart's avatar
eckhart committed
32
33
34
35
36
        (paragraph
            (text
                "Unknown begin-end-structures are always"
                "considered as block elements and not"
                "as inline elements."
37
            )
eckhart's avatar
eckhart committed
38
            (:Whitespace
39
40
41
42
                ""
                ""
            )
        )
eckhart's avatar
eckhart committed
43
44
45
        (end_environment
            "generic"
        )
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    )

Match-test "2"
--------------

### Test-code:
    \begin{generic}
    a single block paragraph
    \end{generic} % ending with
    % a comment
    

### AST
    (generic_block
eckhart's avatar
eckhart committed
60
61
62
63
64
65
        (begin_environment
            "generic"
        )
        (paragraph
            (text
                "a single block paragraph"
66
            )
eckhart's avatar
eckhart committed
67
            (:Whitespace
68
69
70
71
                ""
                ""
            )
        )
eckhart's avatar
eckhart committed
72
73
        (end_environment
            "generic"
74
75
76
77
78
79
80
81
82
83
84
85
86
        )
    )

Match-test "3"
--------------

### Test-code:
    \begin{quote}
    a known block element
    \end{quote}

### AST
    (quotation
eckhart's avatar
eckhart committed
87
88
89
90
91
92
93
        (paragraph
            (text
                "a known block element"
            )
            (:Whitespace
                ""
                ""
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
            )
        )
    )

Fail-test "10"
--------------

### Test-code:
    \begin{generic}inline environment\end{generic}
    

Fail-test "11"
--------------

### Test-code:
    \begin{generic}inline environment
    \end{generic}
    

Fail-test "12"
--------------

### Test-code:
    \begin{generic}
    invalid enivronment \end{generic}
    


Test of parser: "inline_environment"
====================================


Match-test "1"
--------------

### Test-code:
    \begin{generic}inline environment\end{generic}

### AST
    (generic_inline_env
        (begin_environment
            "generic"
        )
        (paragraph
138
139
            (text
                "inline environment"
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
            )
        )
        (end_environment
            "generic"
        )
    )

Match-test "2"
--------------

### Test-code:
    \begin{generic}inline environment
    \end{generic}

### AST
    (generic_inline_env
        (begin_environment
            "generic"
        )
        (paragraph
160
161
            (text
                "inline environment"
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
            )
            (:Whitespace
                ""
                ""
            )
        )
        (end_environment
            "generic"
        )
    )

Match-test "3"
--------------

### Test-code:
    $ inline math $

### AST
    (inline_math
        " inline math "
    )

Fail-test "10"
--------------

### Test-code:
    \begin{generic}
    invalid enivronment \end{generic}
    


Test of parser: "itemize"
=========================


Match-test "1"
--------------

### Test-code:
    \begin{itemize}
    \item Items doe not need to be
    \item separated by empty lines.
    \end{itemize}

### AST
eckhart's avatar
eckhart committed
207
    (itemize)
208
209
210
211
212
213
214

Match-test "2"
--------------

### Test-code:
    \begin{itemize}
    
215
        \item But items may be
216
    
217
        \item separated by blank lines.
218
    
219
        \item
220
    
221
        Empty lines at the beginning of an item will be ignored.
222
    
223
        \end{itemize}
224
225
226
227

### AST
    (itemize
        (item
eckhart's avatar
eckhart committed
228
229
230
            (paragraph
                (text
                    "separated by blank lines."
231
232
233
234
235
236
237
238
239
240
                )
            )
        )
    )

Match-test "3"
--------------

### Test-code:
    \begin{itemize}
241
        \item Items can consist of
242
    
243
244
245
              several paragraphs.
        \item Or of one paragraph
        \end{itemize}
246
247

### AST
eckhart's avatar
eckhart committed
248
    (itemize)
249
250
251
252
253
254
255

Match-test "4"
--------------

### Test-code:
    \begin{itemize}
    \item
256
257
258
      \begin{itemize}
        \item Item-lists can be nested!
      \end{itemize}
259
260
261
262
263
    \end{itemize}

### AST
    (itemize
        (item
eckhart's avatar
eckhart committed
264
265
266
267
268
269
270
271
272
            (itemize
                (item
                    (paragraph
                        (text
                            "Item-lists can be nested!"
                        )
                        (:Whitespace
                            ""
                            ""
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
                        )
                    )
                )
            )
        )
    )

Match-test "5"
--------------

### Test-code:
    \begin{itemize}
    \item Item-lists may consist of just one item.
    \end{itemize}

### AST
    (itemize
        (item
eckhart's avatar
eckhart committed
291
292
293
294
295
296
297
            (paragraph
                (text
                    "Item-lists may consist of just one item."
                )
                (:Whitespace
                    ""
                    ""
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
                )
            )
        )
    )

Fail-test "11"
--------------

### Test-code:
    \begin{itemize}
    Free text is not allowed within an itemized environment!
    \end{itemize}


Test of parser: "enumerate"
===========================


Match-test "1"
--------------

### Test-code:
    \begin{enumerate}
    \item Enumerations work just like item-lists.
    \item Only that the bullets are numbers.
    \end{enumerate}

### AST
eckhart's avatar
eckhart committed
326
    (enumerate)
327
328
329
330
331
332
333

Match-test "2"
--------------

### Test-code:
    \begin{enumerate}
    \item \begin{itemize}
334
335
336
337
338
339
340
341
          \item Item-lists and
          \item Enumeration-lists
             \begin{enumerate}
                \item can be nested
                \item arbitrarily
             \end{enumerate}
          \item Another item
          \end{itemize}
342
343
344
345
    \item Plain numerated item.
    \end{enumerate}

### AST
eckhart's avatar
eckhart committed
346
    (enumerate)
347
348
349
350
351
352
353
354

Match-test "3"
--------------

### Test-code:
    \begin{enumerate} % comment
    
    
355
356
        % more comments and paragraph separators
        % yet some more
357
358
    
    
359
360
        \item %another comment
              finally, the first item
361
362
    
    
363
        % comment
364
365
    
    
366
        \end{enumerate}
367
368
369
370

### AST
    (enumerate
        (item
eckhart's avatar
eckhart committed
371
372
373
            (paragraph
                (text
                    "finally, the first item"
374
375
376
377
378
379
380
381
382
383
                )
            )
        )
    )

Match-test "4"
--------------

### Test-code:
    \begin{enumerate}
384
        \item An item
385
    
386
387
388
389
390
              \begin{itemize}
              \item with an enumeration
              \end{itemize}
             as a separate paragraph
        \end{enumerate}
391
392
393
394

### AST
    (enumerate
        (item
eckhart's avatar
eckhart committed
395
396
397
            (paragraph
                (text
                    "An item"
398
                )
eckhart's avatar
eckhart committed
399
400
401
402
403
404
405
406
407
408
            )
            (itemize
                (item
                    (paragraph
                        (text
                            "with an enumeration"
                        )
                        (:Whitespace
                            ""
                            ""
409
410
411
                        )
                    )
                )
eckhart's avatar
eckhart committed
412
413
414
415
416
417
418
419
            )
            (paragraph
                (text
                    "as a separate paragraph"
                )
                (:Whitespace
                    ""
                    ""
420
421
422
423
                )
            )
        )
    )