03_test_environment.md 8.71 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
            )
        )
    )

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

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

105
106
107
108
109
110
### Messages:
Error: Parser did not match! Invalid source file?
    Most advanced: None
    Last match:    None;
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x0000000003A93488>, {'NAME': ['generic']})

111
112
113
114
115
116
117
118
Fail-test "11"
--------------

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

119
120
121
122
123
124
125
126
127
### Messages:
Error: Parser did not match! Invalid source file?
    Most advanced: None
    Last match:    None;
Error: Parser did not match! Invalid source file?
    Most advanced: None
    Last match:    None;
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x0000000003A93598>, {'NAME': ['generic']})

128
129
130
131
132
133
134
135
Fail-test "12"
--------------

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

136
137
138
139
### Messages:
Error: -&LB end_environment LFF expected; "\end{gener" found!
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x0000000003A93488>, {'NAME': ['generic']})

140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156

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


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

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

### AST
    (generic_inline_env
        (begin_environment
            "generic"
        )
        (paragraph
157
158
            (text
                "inline environment"
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
            )
        )
        (end_environment
            "generic"
        )
    )

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

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

### AST
    (generic_inline_env
        (begin_environment
            "generic"
        )
        (paragraph
179
180
            (text
                "inline environment"
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
207
208
209
210
            )
            (: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}
    

211
212
213
214
215
216
217
218
219
### Messages:
Error: Parser did not match! Invalid source file?
    Most advanced: None
    Last match:    None;
Error: Parser did not match! Invalid source file?
    Most advanced: None
    Last match:    None;
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x0000000003A93488>, {'NAME': ['generic']})

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234

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
235
    (itemize)
236
237
238
239
240
241
242

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

### Test-code:
    \begin{itemize}
    
243
        \item But items may be
244
    
245
        \item separated by blank lines.
246
    
247
        \item
248
    
249
        Empty lines at the beginning of an item will be ignored.
250
    
251
        \end{itemize}
252
253
254
255

### AST
    (itemize
        (item
eckhart's avatar
eckhart committed
256
257
258
            (paragraph
                (text
                    "separated by blank lines."
259
260
261
262
263
264
265
266
267
268
                )
            )
        )
    )

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

### Test-code:
    \begin{itemize}
269
        \item Items can consist of
270
    
271
272
273
              several paragraphs.
        \item Or of one paragraph
        \end{itemize}
274
275

### AST
eckhart's avatar
eckhart committed
276
    (itemize)
277
278
279
280
281
282
283

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

### Test-code:
    \begin{itemize}
    \item
284
285
286
      \begin{itemize}
        \item Item-lists can be nested!
      \end{itemize}
287
288
289
290
291
    \end{itemize}

### AST
    (itemize
        (item
eckhart's avatar
eckhart committed
292
293
294
295
296
297
298
299
300
            (itemize
                (item
                    (paragraph
                        (text
                            "Item-lists can be nested!"
                        )
                        (:Whitespace
                            ""
                            ""
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
                        )
                    )
                )
            )
        )
    )

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
319
320
321
322
323
324
325
            (paragraph
                (text
                    "Item-lists may consist of just one item."
                )
                (:Whitespace
                    ""
                    ""
326
327
328
329
330
331
332
333
334
335
336
337
338
                )
            )
        )
    )

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

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

339
340
341
342
343
344
345
### Messages:
Error: "\end{itemize}" expected; "Free text " found!
Error: Parser stopped before end! trying to recover...
Error: Parser did not match! Invalid source file?
    Most advanced: None
    Last match:    None;

346
347
348
349
350
351
352
353
354
355
356
357
358
359
360

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
361
    (enumerate)
362
363
364
365
366
367
368

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

### Test-code:
    \begin{enumerate}
    \item \begin{itemize}
369
370
371
372
373
374
375
376
          \item Item-lists and
          \item Enumeration-lists
             \begin{enumerate}
                \item can be nested
                \item arbitrarily
             \end{enumerate}
          \item Another item
          \end{itemize}
377
378
379
380
    \item Plain numerated item.
    \end{enumerate}

### AST
eckhart's avatar
eckhart committed
381
    (enumerate)
382
383
384
385
386
387
388
389

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

### Test-code:
    \begin{enumerate} % comment
    
    
390
391
        % more comments and paragraph separators
        % yet some more
392
393
    
    
394
395
        \item %another comment
              finally, the first item
396
397
    
    
398
        % comment
399
400
    
    
401
        \end{enumerate}
402
403
404
405

### AST
    (enumerate
        (item
eckhart's avatar
eckhart committed
406
407
408
            (paragraph
                (text
                    "finally, the first item"
409
410
411
412
413
414
415
416
417
418
                )
            )
        )
    )

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

### Test-code:
    \begin{enumerate}
419
        \item An item
420
    
421
422
423
424
425
              \begin{itemize}
              \item with an enumeration
              \end{itemize}
             as a separate paragraph
        \end{enumerate}
426
427
428
429

### AST
    (enumerate
        (item
eckhart's avatar
eckhart committed
430
431
432
            (paragraph
                (text
                    "An item"
433
                )
eckhart's avatar
eckhart committed
434
435
436
437
438
439
440
441
442
443
            )
            (itemize
                (item
                    (paragraph
                        (text
                            "with an enumeration"
                        )
                        (:Whitespace
                            ""
                            ""
444
445
446
                        )
                    )
                )
eckhart's avatar
eckhart committed
447
448
449
450
451
452
453
454
            )
            (paragraph
                (text
                    "as a separate paragraph"
                )
                (:Whitespace
                    ""
                    ""
455
456
457
458
                )
            )
        )
    )