git @ Cat's Eye Technologies Falderal / 78c7399
Merge pull request #5 from catseye/freestyle-input Support for input in freestyle format Chris Pressey authored 1 year, 9 months ago GitHub committed 1 year, 9 months ago
7 changed file(s) with 122 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
66 `string.replace` instead of `re.sub` so that backslash-escaping
77 is not perfomed on the replacement string. (Thanks to
88 James Holderness for bug report and patch.)
9 * In "freestyle" format, lines beginning with `<= `, `<== `, or
10 `<=== ` can supply a section of test input text (Thanks to
11 James Holderness for feature suggestion and patch.)
912
1013 Version 0.11 "Dan Ryan Expressway" (current released version):
1114
55 Status
66 ------
77
8 This document is a *draft*. It is nominally "version 0.11" because it
9 describes something that version 0.11 of `py-falderal` mostly implements.
8 This document is a *draft*. It is nominally "version 0.12" because it
9 describes something that version 0.12 of `py-falderal` mostly implements.
1010 We will deign to note which sections of this document the current released
1111 version of `py-falderal` implements, and which it does not. However,
1212 this document is a work in progress, subject to change, and subject to get
8888 * `??> `: expected error text
8989 * `???> `: expected error text
9090
91 In addition, the following introducers may be used to mark a section
92 of test input text on the first of the final lines (but may not be
93 used to end a block):
94
95 * `<= `: test input text
96 * `<== `: test input text
97 * `<=== `: test input text
98
9199 If a block is identified as a freestyle block, all lines preceding the
92 final lines with one of these introducers, are interpreted as having
93 no introducer at all (even if they begin with `| ` or some other sequence
94 already mentioned) and are used as the test body block.
100 first final line appearing with one of these introducers, are interpreted
101 as having no introducer at all (even if they begin with `| ` or some other
102 sequence already mentioned) and are used as the test body block.
95103
96104 Lines without introducers are called _intervening text_.
97105 Lines of intervening text are classified as either blank or non-blank. A
264272 thing to test
265273 ???> error to expect
266274
275 thing to test
276 <=== input to give it
277 ===> output to expect
278
279 thing to test
280 <=== input to give it
281 ???> error to expect
282
267283 Invalid examples:
268284
269285 | thing to test
273289 + input to give it
274290 = output to expect
275291
276 ...test input must be preceded by a test body (if this is the first test.)
292 ...test input must be preceded by a test body, if this is the first test.
293
294 <=== input to give it
295 ???> output to expect
296
297 ...test input must be preceded by a test body always, in freestyle format.
277298
278299 ? error to expect
279300
196196 """
197197
198198 FREESTYLE_MAP = {
199 u'<= ': u'+ ',
200 u'<== ': u'+ ',
201 u'<=== ': u'+ ',
199202 u'=> ': u'= ',
200203 u'==> ': u'= ',
201204 u'===> ': u'= ',
3030 Location: test-freestyle-format.markdown, line 68
3131 Function: Cat
3232 Impl : shell command "python cat.py"
33 Body : meow
33 Body :
34 | meow
35 ? rreoww
3436 Expected: error:
3537 bow
3638 wow
3739 Actual : output:
38 meow
40 | meow
41 ? rreoww
42
43 FAILED :
44
45 The trick of re-using the previous test body with a different
46 test input if the test body is omitted doesn't work with
47 freestyle-format test input sections (i.e., this will fail.)
48
49 Location: test-freestyle-format.markdown, line 111
50 Function: Silly Interpreter
51 Impl : shell command "python silly-interpreter.py %(test-body-file)"
52 Body :
53 Expected: output:
54 zang
55 zing
56 Actual : output:
57
3958
4059 --------------------------------
41 Total test runs: 10, failures: 3
60 Total test runs: 14, failures: 4
4261 --------------------------------
0 Falderal Test: "new" format for tests
0 Falderal Test: "freestyle" format for tests
11 -------------------------------------
22
3 This document tests the alternate format for tests introduced in
4 the Falderal Literate Test Format version 0.11. This format allows
5 the test body to consist entirely of un-prefixed text, as long as
6 it is written in a single indented block, and the final line(s) of
7 the test begin with one of the prefixes `=> ` or `==> ` or `===> `
8 or `?> ` or `??> `or `???> `.
3 This document tests the alternate ("freestyle") format for tests
4 introduced in the Falderal Literate Test Format version 0.11. This
5 format allows the test body to consist entirely of un-prefixed text,
6 as long as it is written in a single indented block, and as long as
7 the final line(s) of the test begin with one of the prefixes
8 `=> ` or `==> ` or `===> ` or `?> ` or `??> `or `???> `.
99
1010 -> Functionality "Cat" is implemented by shell command "python cat.py"
1111
3737
3838 | purr
3939 | prrr
40 | prreow
41 ==> | purr
42 ==> | prrr
43 ==> | prreow
40 = prreow
41 => | purr
42 => | prrr
43 => = prreow
4444
4545 | purr
4646 + prrr
47 + prreow
47 ? prreow
4848 => | purr
4949 => + prrr
50 => + prreow
50 => ? prreow
5151
5252 purr
5353 -> prrr
6464 meow
6565 ??> woof
6666
67 meow
67 | meow
68 ? rreoww
6869 ???> bow
6970 ???> wow
71
72 Freestyle-format tests can also contain input sections.
73
74 -> Functionality "Silly Interpreter" is implemented by
75 -> shell command "python silly-interpreter.py %(test-body-file)"
76
77 -> Tests for functionality "Silly Interpreter"
78
79 read x
80 read y
81 print y
82 print x
83 <= meow
84 <= purr
85 => purr
86 => meow
87
88 read x
89 read y
90 print y
91 print x
92 <== meow
93 <== purr
94 ==> purr
95 ==> meow
96
97 read x
98 read y
99 print y
100 print x
101 <=== meow
102 <=== purr
103 ===> purr
104 ===> meow
105
106 The trick of re-using the previous test body with a different
107 test input if the test body is omitted doesn't work with
108 freestyle-format test input sections (i.e., this will fail.)
109
110 <== zing
111 <== zang
112 ==> zang
113 ==> zing
00 --------------------------------
1 Total test runs: 5, failures: 0
1 Total test runs: 6, failures: 0
22 --------------------------------
3737 + purr
3838 = purr
3939 = meow
40
41 If the input section appears first (i.e. there is no test body),
42 the previous test body is re-used.
43
44 + zing
45 + zang
46 = zang
47 = zing