]> ocean-lang.org Git - ocean/blob - csrc/scanner-tests.mdc
oceani: update min_depth promptly.
[ocean] / csrc / scanner-tests.mdc
1 # Scanner test code
2
3 The focus of these tests is coverage of the code in scanner.mdc
4 with the aim of being able to detect regressions.
5
6 We have a few different input files, and scan each with a variety
7 of different setting and ensure the output is as expected.
8
9 The inputs are in sectoins called "test: name" and the expected
10 outputs are in "test: name,arg,arg,arg".  As we cannot (yet)
11 extract a list of section names, we need to tell the make script
12 about each test.
13
14 ###### File: scanner-tests.mk
15
16         scanner_tests :=
17         ## test list
18
19         tests:: scanner_test_suite
20         scanner_test_suite : md2c coverage_scanner
21                 @rm -rf coverage; mkdir -p coverage
22                 @cp *.gcno coverage
23                 @for T in $(scanner_tests); do \
24                     echo -n "Tests $$T ... ";  \
25                     i="$IFS"; IFS=,; set $$T; IFS="$$i"; t=$$1; shift; \
26                     ./md2c scanner-tests.mdc "output: $$T" | grep -v '^#' > .tmp.want; \
27                     echo '~~~~~~~' > .tmp.code ;\
28                     ./md2c scanner-tests.mdc "test: $$t" | grep -v '^#' >> .tmp.code; \
29                     ./coverage_scanner --file .tmp.code $${1+"$$@"} > .tmp.have; \
30                     if ! cmp -s .tmp.want .tmp.have; then \
31                         echo "FAILED"; diff -u .tmp.want .tmp.have; exit 1; fi ; \
32                     echo "PASSED"; \
33                 done
34
35                 ## other tests
36                 @for i in coverage/#*.gcda; do mv $$i coverage/$${i##*#}; done
37                 @gcov -o coverage scanner.c libscanner.c > /dev/null 2> /dev/null
38                 @mv *.gcov coverage; [ -f .gcov ] && mv .gcov coverage || true
39                 @awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
40                     END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \
41                          if (ran < (ran + skip) *0.94) exit(1) }' \
42                         coverage/scanner.mdc.gcov
43                 @rm -f .tmp*
44
45         coverage_scanner: scanner.c libscanner.c libmdcode.o libnumber.o libstring.o
46                 $(CC) $(CFLAGS) --coverage -fprofile-dir=coverage -o coverage_scanner \
47                         scanner.c libscanner.c \
48                         libmdcode.o libnumber.o libstring.o -licuuc -lgmp
49
50 ## Basic tests
51
52 Some simple tests... maybe all tests are simple.
53 Include a special test for numbers, as they are interesting.
54
55 ###### test list
56         scanner_tests += "test1,-r,if,then,+,-"
57         scanner_tests += "test1,-r,if,then,+,-,/"
58         scanner_tests += "test1,-r,--ignore-indent,if,then,+,-,/"
59         scanner_tests += "test1,-r,--ignore-indent,--ignore-newline,if,then,+,-,/"
60         scanner_tests += "test1,--ignore-indent,--ignore-newline,if,then,+,-,/"
61         scanner_tests += "test1,-Sz,--ignore-indent,--ignore-newline,if,then,+,-,/"
62
63 ###### test: test1
64
65         A B C
66           D E
67            F G
68          H
69         I
70
71         A
72           B
73             C
74             D
75           E
76         F
77           G
78         H
79
80         if else then fi while
81         1234,  1.234 -123.456e45
82         0x1234 +  0x543p+3
83         "This is a string" &"so is this"a
84         a = """
85            This is a multi-
86            line string that
87            has three lines
88            """bb
89         I think # some comments are like this
90         and // some are like this
91         and some /* can go
92         over multiplt
93         lines */
94         divident /+ divisor
95
96 ###### output: test1,-r,if,then,+,-
97         Tokenizing: 
98         2:0 ident(A)
99         2:2 ident(B)
100         2:4 ident(C)
101         3:2 in()
102         3:2 ident(D)
103         3:4 ident(E)
104         4:3 in()
105         4:3 ident(F)
106         4:5 ident(G)
107         5:1 newline()
108         5:1 out()
109         5:1 newline()
110         5:1 out()
111         5:1 in()
112         5:1 ident(H)
113         6:0 newline()
114         6:0 out()
115         6:0 newline()
116         6:0 ident(I)
117         8:0 newline()
118         8:0 newline()
119         8:0 ident(A)
120         9:2 in()
121         9:2 ident(B)
122         10:4 in()
123         10:4 ident(C)
124         11:4 newline()
125         11:4 ident(D)
126         12:2 newline()
127         12:2 out()
128         12:2 newline()
129         12:2 ident(E)
130         13:0 newline()
131         13:0 out()
132         13:0 newline()
133         13:0 ident(F)
134         14:2 in()
135         14:2 ident(G)
136         15:0 newline()
137         15:0 out()
138         15:0 newline()
139         15:0 ident(H)
140         17:0 newline()
141         17:0 newline()
142         17:0 if
143         17:3 ident(else)
144         17:8 then
145         17:13 ident(fi)
146         17:16 ident(while)
147         18:0 newline()
148         18:0 number(1234)  1234
149         18:4 mark(,)
150         18:7 number(1.234)  617/500
151         18:13 -
152         18:14 number(123.456e45)  123456000000000000000000000000000000000000000000
153         19:0 newline()
154         19:0 number(0x1234)  4660
155         19:7 +
156         19:10 number(0x543p+3)  10776
157         20:0 newline()
158         20:0 string("This is a string")  This is a string
159         20:19 mark(&)
160         20:20 string("so is this"a) a so is this
161         21:0 newline()
162         21:0 ident(a)
163         21:2 mark(=)
164         21:4 mstring("""\x0a   This is a m..) bb This is a multi-\x0al..
165         26:0 newline()
166         26:0 ident(I)
167         26:2 ident(think)
168         26:8 lcomment(# some comments ar..)
169         27:0 newline()
170         27:0 ident(and)
171         27:4 lcomment(// some are like t..)
172         28:0 newline()
173         28:0 ident(and)
174         28:4 ident(some)
175         28:9 bcomment(/* can go\x0aover mul..)
176         31:0 newline()
177         31:0 ident(divident)
178         31:9 mark(/+)
179         31:12 ident(divisor)
180         32:0 newline()
181         32:0 eof()
182
183 ###### output: test1,-r,if,then,+,-,/
184         Tokenizing: 
185         2:0 ident(A)
186         2:2 ident(B)
187         2:4 ident(C)
188         3:2 in()
189         3:2 ident(D)
190         3:4 ident(E)
191         4:3 in()
192         4:3 ident(F)
193         4:5 ident(G)
194         5:1 newline()
195         5:1 out()
196         5:1 newline()
197         5:1 out()
198         5:1 in()
199         5:1 ident(H)
200         6:0 newline()
201         6:0 out()
202         6:0 newline()
203         6:0 ident(I)
204         8:0 newline()
205         8:0 newline()
206         8:0 ident(A)
207         9:2 in()
208         9:2 ident(B)
209         10:4 in()
210         10:4 ident(C)
211         11:4 newline()
212         11:4 ident(D)
213         12:2 newline()
214         12:2 out()
215         12:2 newline()
216         12:2 ident(E)
217         13:0 newline()
218         13:0 out()
219         13:0 newline()
220         13:0 ident(F)
221         14:2 in()
222         14:2 ident(G)
223         15:0 newline()
224         15:0 out()
225         15:0 newline()
226         15:0 ident(H)
227         17:0 newline()
228         17:0 newline()
229         17:0 if
230         17:3 ident(else)
231         17:8 then
232         17:13 ident(fi)
233         17:16 ident(while)
234         18:0 newline()
235         18:0 number(1234)  1234
236         18:4 mark(,)
237         18:7 number(1.234)  617/500
238         18:13 -
239         18:14 number(123.456e45)  123456000000000000000000000000000000000000000000
240         19:0 newline()
241         19:0 number(0x1234)  4660
242         19:7 +
243         19:10 number(0x543p+3)  10776
244         20:0 newline()
245         20:0 string("This is a string")  This is a string
246         20:19 mark(&)
247         20:20 string("so is this"a) a so is this
248         21:0 newline()
249         21:0 ident(a)
250         21:2 mark(=)
251         21:4 mstring("""\x0a   This is a m..) bb This is a multi-\x0al..
252         26:0 newline()
253         26:0 ident(I)
254         26:2 ident(think)
255         26:8 lcomment(# some comments ar..)
256         27:0 newline()
257         27:0 ident(and)
258         27:4 lcomment(// some are like t..)
259         28:0 newline()
260         28:0 ident(and)
261         28:4 ident(some)
262         28:9 bcomment(/* can go\x0aover mul..)
263         31:0 newline()
264         31:0 ident(divident)
265         31:9 /
266         31:10 +
267         31:12 ident(divisor)
268         32:0 newline()
269         32:0 eof()
270
271 ###### output: test1,-r,--ignore-indent,if,then,+,-,/
272         Tokenizing: 
273         2:0 ident(A)
274         2:2 ident(B)
275         2:4 ident(C)
276         2:5 newline()
277         3:2 ident(D)
278         3:4 ident(E)
279         3:5 newline()
280         4:3 ident(F)
281         4:5 ident(G)
282         4:6 newline()
283         5:1 ident(H)
284         5:2 newline()
285         6:0 ident(I)
286         6:1 newline()
287         7:0 newline()
288         8:0 ident(A)
289         8:1 newline()
290         9:2 ident(B)
291         9:3 newline()
292         10:4 ident(C)
293         10:5 newline()
294         11:4 ident(D)
295         11:5 newline()
296         12:2 ident(E)
297         12:3 newline()
298         13:0 ident(F)
299         13:1 newline()
300         14:2 ident(G)
301         14:3 newline()
302         15:0 ident(H)
303         15:1 newline()
304         16:0 newline()
305         17:0 if
306         17:3 ident(else)
307         17:8 then
308         17:13 ident(fi)
309         17:16 ident(while)
310         17:21 newline()
311         18:0 number(1234)  1234
312         18:4 mark(,)
313         18:7 number(1.234)  617/500
314         18:13 -
315         18:14 number(123.456e45)  123456000000000000000000000000000000000000000000
316         18:24 newline()
317         19:0 number(0x1234)  4660
318         19:7 +
319         19:10 number(0x543p+3)  10776
320         19:18 newline()
321         20:0 string("This is a string")  This is a string
322         20:19 mark(&)
323         20:20 string("so is this"a) a so is this
324         20:33 newline()
325         21:0 ident(a)
326         21:2 mark(=)
327         21:4 mstring("""\x0a   This is a m..) bb This is a multi-\x0al..
328         25:8 newline()
329         26:0 ident(I)
330         26:2 ident(think)
331         26:8 lcomment(# some comments ar..)
332         26:37 newline()
333         27:0 ident(and)
334         27:4 lcomment(// some are like t..)
335         27:25 newline()
336         28:0 ident(and)
337         28:4 ident(some)
338         28:9 bcomment(/* can go\x0aover mul..)
339         30:8 newline()
340         31:0 ident(divident)
341         31:9 /
342         31:10 +
343         31:12 ident(divisor)
344         31:19 newline()
345         32:0 eof()
346
347 ###### output: test1,-r,--ignore-indent,--ignore-newline,if,then,+,-,/
348         Tokenizing: 
349         2:0 ident(A)
350         2:2 ident(B)
351         2:4 ident(C)
352         3:2 ident(D)
353         3:4 ident(E)
354         4:3 ident(F)
355         4:5 ident(G)
356         5:1 ident(H)
357         6:0 ident(I)
358         8:0 ident(A)
359         9:2 ident(B)
360         10:4 ident(C)
361         11:4 ident(D)
362         12:2 ident(E)
363         13:0 ident(F)
364         14:2 ident(G)
365         15:0 ident(H)
366         17:0 if
367         17:3 ident(else)
368         17:8 then
369         17:13 ident(fi)
370         17:16 ident(while)
371         18:0 number(1234)  1234
372         18:4 mark(,)
373         18:7 number(1.234)  617/500
374         18:13 -
375         18:14 number(123.456e45)  123456000000000000000000000000000000000000000000
376         19:0 number(0x1234)  4660
377         19:7 +
378         19:10 number(0x543p+3)  10776
379         20:0 string("This is a string")  This is a string
380         20:19 mark(&)
381         20:20 string("so is this"a) a so is this
382         21:0 ident(a)
383         21:2 mark(=)
384         21:4 mstring("""\x0a   This is a m..) bb This is a multi-\x0al..
385         26:0 ident(I)
386         26:2 ident(think)
387         26:8 lcomment(# some comments ar..)
388         27:0 ident(and)
389         27:4 lcomment(// some are like t..)
390         28:0 ident(and)
391         28:4 ident(some)
392         28:9 bcomment(/* can go\x0aover mul..)
393         31:0 ident(divident)
394         31:9 /
395         31:10 +
396         31:12 ident(divisor)
397         32:0 eof()
398
399 ###### output: test1,--ignore-indent,--ignore-newline,if,then,+,-,/
400         Tokenizing: 
401         2:0 ident(A)
402         2:2 ident(B)
403         2:4 ident(C)
404         3:2 ident(D)
405         3:4 ident(E)
406         4:3 ident(F)
407         4:5 ident(G)
408         5:1 ident(H)
409         6:0 ident(I)
410         8:0 ident(A)
411         9:2 ident(B)
412         10:4 ident(C)
413         11:4 ident(D)
414         12:2 ident(E)
415         13:0 ident(F)
416         14:2 ident(G)
417         15:0 ident(H)
418         17:0 if
419         17:3 ident(else)
420         17:8 then
421         17:13 ident(fi)
422         17:16 ident(while)
423         18:0 number(1234)  1234
424         18:4 mark(,)
425         18:7 number(1.234)  617/500
426         18:13 -
427         18:14 number(123.456e45)  123456000000000000000000000000000000000000000000
428         19:0 number(0x1234)  4660
429         19:7 +
430         19:10 number(0x543p+3)  10776
431         20:0 string("This is a string")  This is a string
432         20:19 mark(&)
433         20:20 string("so is this"a) a so is this
434         21:0 ident(a)
435         21:2 mark(=)
436         21:4 mstring("""\x0a   This is a m..) bb This is a multi-\x0al..
437         26:0 ident(I)
438         26:2 ident(think)
439         27:0 ident(and)
440         28:0 ident(and)
441         28:4 ident(some)
442         31:0 ident(divident)
443         31:9 /
444         31:10 +
445         31:12 ident(divisor)
446         32:0 eof()
447
448 ###### output: test1,-Sz,--ignore-indent,--ignore-newline,if,then,+,-,/
449         Tokenizing: 
450         2:0 ident(A)
451         2:2 ident(B)
452         2:4 ident(C)
453         3:2 ident(D)
454         3:4 ident(E)
455         4:3 ident(F)
456         4:5 ident(G)
457         5:1 ident(H)
458         6:0 ident(I)
459         8:0 ident(A)
460         9:2 ident(B)
461         10:4 ident(C)
462         11:4 ident(D)
463         12:2 ident(E)
464         13:0 ident(F)
465         14:2 ident(G)
466         15:0 ident(H)
467         17:0 if
468         17:3 ident(else)
469         17:8 then
470         17:13 ident(fi)
471         17:16 ident(while)
472         18:0 number(1234)  1234
473         18:4 mark(,)
474         18:7 number(1.234)  617/500
475         18:13 -
476         18:14 number(123.456e45)  123456000000000000000000000000000000000000000000
477         19:0 number(0x1234)  4660
478         19:7 +
479         19:10 number(0x543p+3)  10776
480         20:0 mark(")
481         20:1 ident(This)
482         20:6 ident(is)
483         20:9 ident(a)
484         20:11 ident(string)
485         20:17 mark(")
486         20:19 mark(&")
487         20:21 ident(so)
488         20:24 ident(is)
489         20:27 ident(this)
490         20:31 mark(")
491         20:32 ident(a)
492         21:0 ident(a)
493         21:2 mark(=)
494         21:4 mark(""")
495         22:3 ident(This)
496         22:8 ident(is)
497         22:11 ident(a)
498         22:13 ident(multi)
499         22:18 -
500         23:3 ident(line)
501         23:8 ident(string)
502         23:15 ident(that)
503         24:3 ident(has)
504         24:7 ident(three)
505         24:13 ident(lines)
506         25:3 mark(""")
507         25:6 ident(bb)
508         26:0 ident(I)
509         26:2 ident(think)
510         27:0 ident(and)
511         28:0 ident(and)
512         28:4 ident(some)
513         31:0 ident(divident)
514         31:9 /
515         31:10 +
516         31:12 ident(divisor)
517         32:0 eof()
518
519 ###### test list
520         scanner_tests += "testnum"
521
522 ###### test: testnum
523         12345
524         1234.56
525         1234.56e7
526         1234.56e-7
527         0x1234
528         0x123,456
529         0o777
530         0o111.111p4
531         0b11011110p3
532
533         123 456 789
534         0x1234_5678_9abc
535
536         "Now for some non-number"
537         1234p4
538         12-34
539         01234
540         0c1234
541         123.456e1a
542         123.e4
543         0x123 456
544         0b1234
545         123_345_.34
546         .75
547
548 ###### output: testnum
549         Tokenizing: 
550         2:0 number(12345)  12345
551         3:0 newline()
552         3:0 number(1234.56)  30864/25
553         4:0 newline()
554         4:0 number(1234.56e7)  12345600000
555         5:0 newline()
556         5:0 number(1234.56e-7)  1929/15625000
557         6:0 newline()
558         6:0 number(0x1234)  4660
559         7:0 newline()
560         7:0 number(0x123,456)  596523/2048
561         8:0 newline()
562         8:0 number(0o777)  511
563         9:0 newline()
564         9:0 number(0o111.111p4)  37449/32
565         10:0 newline()
566         10:0 number(0b11011110p3)  1776
567         12:0 newline()
568         12:0 newline()
569         12:0 number(123 456 789)  123456789
570         13:0 newline()
571         13:0 number(0x1234_5678_9abc)  20015998343868
572         15:0 newline()
573         15:0 newline()
574         15:0 string("Now for some non-..)  Now for some non-n..
575         16:0 newline()
576         16:0 number(1234p4) BAD NUMBER
577         17:0 newline()
578         17:0 number(12)  12
579         17:2 mark(-)
580         17:3 number(34)  34
581         18:0 newline()
582         18:0 number(01234) BAD NUMBER
583         19:0 newline()
584         19:0 number(0c1234) BAD NUMBER
585         20:0 newline()
586         20:0 number(123.456e1a) a 30864/25
587         21:0 newline()
588         21:0 number(123.e4)  1230000
589         22:0 newline()
590         22:0 number(0x123 456) BAD NUMBER
591         23:0 newline()
592         23:0 number(0b1234) BAD NUMBER
593         24:0 newline()
594         24:0 number(123_345)  123345
595         24:7 ident(_)
596         24:8 mark(.)
597         24:9 number(34)  34
598         25:0 newline()
599         25:0 mark(.)
600         25:1 number(75)  75
601         26:0 newline()
602         26:0 eof()
603
604 ## Error tests
605
606 Now to test for some errors ... though things I thought would be errors
607 sometimes aren't.
608
609 ###### test list
610         scanner_tests += "errtest,-r,--ignore-ident,--ignore-mark,-W_,-w_,if,then,+,-"
611         scanner_tests += "errtest,-r,--ignore-ident,--ignore-mark,-N,if,then,+,-"
612
613 ###### test: errtest
614
615         multiple decimal pointer 3.141.59
616         "Check for decimal commas" 3,14159 = 3,141,59
617         """A multi-string must not have text here
618         """
619         "or after close" + """
620                 no text ..
621                 """ here
622
623         /* No embedded /* comments */ in comments */
624         /* or content after
625          * a multiline comment */ Error
626
627         "  \\ \t \n special chars in strings"
628
629 ###### output: errtest,-r,--ignore-ident,--ignore-mark,-W_,-w_,if,then,+,-
630
631         Tokenizing: 
632         2:0 ERROR(multiple)
633         2:9 ERROR(decimal)
634         2:17 ERROR(pointer)
635         2:25 number(3.141)  3141/1000
636         2:30 ERROR(.)
637         2:31 number(59)  59
638         3:0 newline()
639         3:0 string("Check for decimal..)  Check for decimal ..
640         3:27 number(3,14159)  314159/100000
641         3:35 ERROR(=)
642         3:37 number(3,141)  3141/1000
643         3:42 ERROR(,)
644         3:43 number(59)  59
645         4:0 newline()
646         4:0 string("")  
647         4:2 ERROR("A multi-string mu..)
648         5:0 newline()
649         5:0 ERROR("""\x0a"or after clos..)
650         8:12 ERROR(here)
651         10:0 newline()
652         10:0 newline()
653         10:0 ERROR(/* No embedded /*)
654         10:15 bcomment(/* comments */)
655         10:30 ERROR(in)
656         10:33 ERROR(comments)
657         10:42 ERROR(*/)
658         11:0 newline()
659         11:0 ERROR(/* or content afte..)
660         12:26 ERROR(Error)
661         14:0 newline()
662         14:0 newline()
663         14:0 string("  \\\\ \\t \\n specia..)    \\ \x09 \x0a special ch..
664         15:0 newline()
665         15:0 eof()
666
667 ###### output: errtest,-r,--ignore-ident,--ignore-mark,-N,if,then,+,-
668         Tokenizing: 
669         2:0 ERROR(multiple)
670         2:9 ERROR(decimal)
671         2:17 ERROR(pointer)
672         2:25 ERROR(3)
673         2:26 ERROR(.)
674         2:27 ERROR(1)
675         2:28 ERROR(4)
676         2:29 ERROR(1)
677         2:30 ERROR(.)
678         2:31 ERROR(5)
679         2:32 ERROR(9)
680         3:0 newline()
681         3:0 string("Check for decimal..)  Check for decimal ..
682         3:27 ERROR(3)
683         3:28 ERROR(,)
684         3:29 ERROR(1)
685         3:30 ERROR(4)
686         3:31 ERROR(1)
687         3:32 ERROR(5)
688         3:33 ERROR(9)
689         3:35 ERROR(=)
690         3:37 ERROR(3)
691         3:38 ERROR(,)
692         3:39 ERROR(1)
693         3:40 ERROR(4)
694         3:41 ERROR(1)
695         3:42 ERROR(,)
696         3:43 ERROR(5)
697         3:44 ERROR(9)
698         4:0 newline()
699         4:0 string("")  
700         4:2 ERROR("A multi-string mu..)
701         5:0 newline()
702         5:0 ERROR("""\x0a"or after clos..)
703         8:12 ERROR(here)
704         10:0 newline()
705         10:0 newline()
706         10:0 ERROR(/* No embedded /*)
707         10:15 bcomment(/* comments */)
708         10:30 ERROR(in)
709         10:33 ERROR(comments)
710         10:42 ERROR(*/)
711         11:0 newline()
712         11:0 ERROR(/* or content afte..)
713         12:26 ERROR(Error)
714         14:0 newline()
715         14:0 newline()
716         14:0 string("  \\\\ \\t \\n specia..)    \\ \x09 \x0a special ch..
717         15:0 newline()
718         15:0 eof()
719
720 ## Nested tests.
721
722 We need to test various aspects of tokenizing code that is stored
723 in multiple nodes.  For example, comments and multi-line strings mustn't
724 cross a node boundary.
725
726 For this we tell `scanner` to extract sections directly from this file.
727 As the file changes, line numbers might change as well, so we need to factor
728 that out when testing.  A simple awk script can normalise the first line number
729 to one.
730
731 ###### other tests
732         @for T in $(scanner_section_tests); do \
733            echo -n "Test $$T ... "; \
734            i="$IFS"; IFS=,; set $$T; IFS="$$i"; section="$$1"; shift; \
735             ./md2c scanner-tests.mdc "output: $$T" | grep -v '^#' > .tmp.want; \
736            ./coverage_scanner --file scanner-tests.mdc --section "test: $$section" \
737              $${1+"$$@"} | awk -F: ' BEGIN {OFS=":"} $$1 ~ /^[0-9]/ {if (!first) first = $$1 - 1; \
738                   $$1 = $$1 - first} { print } '> .tmp.have; \
739             if ! cmp -s .tmp.want .tmp.have; then \
740                 echo "FAILED"; diff -u .tmp.want .tmp.have; exit 1; fi ; \
741             echo "PASSED"; \
742         done
743
744 ###### test list
745         scanner_section_tests += section1 section_string section_comment
746
747 ###### test: section1
748
749         foreach s in sections:
750                 ## section2
751                 print done
752
753 ###### section2
754
755                 This is another
756         section
757
758 ###### output: section1
759         Tokenizing: test: section1
760         1:8 ident(foreach)
761         1:16 ident(s)
762         1:18 ident(in)
763         1:21 ident(sections)
764         1:29 mark(:)
765         7:16 in()
766         7:16 ident(This)
767         7:21 ident(is)
768         7:24 ident(another)
769         8:8 newline()
770         8:8 out()
771         8:8 in()
772         8:8 ident(section)
773         3:16 newline()
774         3:16 ident(print)
775         3:22 ident(done)
776         4:0 newline()
777         4:0 out()
778         4:0 newline()
779         4:0 eof()
780
781 ###### test: section_string
782         a = '''
783           A sting mustn't cross
784           ## string B
785         skip
786
787 ###### string B
788         to a new node
789         '''
790
791 ###### output: section_string
792         Tokenizing: test: section_string
793         1:8 ident(a)
794         1:10 mark(=)
795         1:12 ERROR('''\x0a\x09  A sting mus..)
796         7:8 in()
797         7:8 ident(to)
798         7:11 ident(a)
799         7:13 ident(new)
800         7:17 ident(node)
801         8:8 newline()
802         8:8 ERROR(''')
803         4:8 newline()
804         4:8 out()
805         4:8 newline()
806         4:8 ident(skip)
807         5:0 newline()
808         5:0 eof()
809
810 ###### test: section_comment
811         /* Mult-line comment must stay within
812         ## comment B
813         */
814
815 ###### comment B
816         a single node, they cannot cross nodes.
817
818 ###### output: section_comment
819         Tokenizing: test: section_comment
820         1:8 ERROR(/* Mult-line comme..)
821         6:8 ident(a)
822         6:10 ident(single)
823         6:17 ident(node)
824         6:21 mark(,)
825         6:23 ident(they)
826         6:28 ident(cannot)
827         6:35 ident(cross)
828         6:41 ident(nodes)
829         6:46 mark(.)
830         3:8 newline()
831         3:8 mark(*/)
832         4:0 newline()
833         4:0 eof()
834
835 ## Ad-hoc test
836
837 These tests test bugs that were found in practice, and so prevent them recuring.
838
839 The "bad_indent" test was written because I was seeing a TK_in before the
840 "program" instead of TK_newline
841
842 ###### test list
843         scanner_tests += "bad_indent"
844
845 ###### test: bad_indent
846
847                 const:
848                         foo : number = 45
849                         bar := "string"
850                 program:
851                         foo := 4
852                         print foo, bar
853
854 ###### output: bad_indent
855         Tokenizing: 
856         2:8 in()
857         2:8 ident(const)
858         2:13 mark(:)
859         3:16 in()
860         3:16 ident(foo)
861         3:20 mark(:)
862         3:22 ident(number)
863         3:29 mark(=)
864         3:31 number(45)  45
865         4:16 newline()
866         4:16 ident(bar)
867         4:20 mark(:=)
868         4:23 string("string")  string
869         5:8 newline()
870         5:8 out()
871         5:8 newline()
872         5:8 ident(program)
873         5:15 mark(:)
874         6:16 in()
875         6:16 ident(foo)
876         6:20 mark(:=)
877         6:23 number(4)  4
878         7:16 newline()
879         7:16 ident(print)
880         7:22 ident(foo)
881         7:25 mark(,)
882         7:27 ident(bar)
883         8:0 newline()
884         8:0 out()
885         8:0 newline()
886         8:0 out()
887         8:0 newline()
888         8:0 eof()