Implement => & ===> & ?> & ???> and clean up a bit.
Chris Pressey
7 years ago
3 | 3 |
Version 0.11-PRE "Dan Ryan Expressway"
|
4 | 4 |
|
5 | 5 |
This is the reference distribution of Falderal, a file format for literate
|
6 | |
test suites. Falderal is particularly suited for:
|
|
6 |
test suites. What sets Falderal apart from most other test frameworks is
|
|
7 |
that it recognizes that **your tests are for a functionality, not a particular
|
|
8 |
implementation of that functionality**.
|
|
9 |
|
|
10 |
Falderal is particularly suited for:
|
7 | 11 |
|
8 | 12 |
* documenting programming languages with prose and examples
|
9 | 13 |
* testing multiple implementations of a programming language
|
195 | 195 |
|
196 | 196 |
"""
|
197 | 197 |
|
198 | |
PREFIXES = [
|
199 | |
u'==> ',
|
200 | |
u'??> ',
|
|
198 |
FREESTYLE_MAP = {
|
|
199 |
u'=> ': u'= ',
|
|
200 |
u'==> ': u'= ',
|
|
201 |
u'===> ': u'= ',
|
|
202 |
u'?> ': u'? ',
|
|
203 |
u'??> ': u'? ',
|
|
204 |
u'???> ': u'? ',
|
|
205 |
}
|
|
206 |
FREESTYLE_PREFIXES = FREESTYLE_MAP.keys()
|
|
207 |
PREFIXES = FREESTYLE_PREFIXES + [
|
201 | 208 |
u'| ',
|
202 | 209 |
u'+ ',
|
203 | 210 |
u'? ',
|
|
305 | 312 |
lines.extend([candidate_prefix + line for line in candidate_lines])
|
306 | 313 |
return [(default_prefix, lines)] + new_pattern
|
307 | 314 |
|
308 | |
# This block ends with a new-style expectation.
|
309 | |
# We interpret this according to the new, not-yet-written rules.
|
310 | |
if pattern_prefixes[-1] in [u'==> ', u'??> ']:
|
311 | |
pattern = reconstruct(pattern, u'| ', {
|
312 | |
u'==> ': u'= ',
|
313 | |
u'??> ': u'? ',
|
314 | |
})
|
|
315 |
if pattern_prefixes[-1] in self.FREESTYLE_PREFIXES:
|
|
316 |
# This block ends with an expectation indicating a freestyle block.
|
|
317 |
# We re-interpret this block according to the freestyle block rules.
|
|
318 |
pattern = reconstruct(pattern, u'| ', self.FREESTYLE_MAP)
|
315 | 319 |
pattern_prefixes = [p[0] for p in pattern]
|
316 | 320 |
|
317 | 321 |
if '' in pattern_prefixes:
|
12 | 12 |
test-bad-indentation
|
13 | 13 |
test-input-sections test-shared-body
|
14 | 14 |
test-stdout-stderr test-err-no-stderr
|
15 | |
test-new-format
|
|
15 |
test-freestyle-format
|
16 | 16 |
"
|
17 | 17 |
for TEST in ${FIRST_TESTS}; do
|
18 | 18 |
echo ${TEST}...
|
|
0 |
FAILED :
|
|
1 |
|
|
2 |
Demonstrate error expectation (Intentional fail.)
|
|
3 |
|
|
4 |
Location: test-freestyle-format.markdown, line 62
|
|
5 |
Function: Cat
|
|
6 |
Impl : shell command "python cat.py"
|
|
7 |
Body : meow
|
|
8 |
Expected: error:
|
|
9 |
woof
|
|
10 |
Actual : output:
|
|
11 |
meow
|
|
12 |
|
|
13 |
FAILED :
|
|
14 |
|
|
15 |
Demonstrate error expectation (Intentional fail.)
|
|
16 |
|
|
17 |
Location: test-freestyle-format.markdown, line 65
|
|
18 |
Function: Cat
|
|
19 |
Impl : shell command "python cat.py"
|
|
20 |
Body : meow
|
|
21 |
Expected: error:
|
|
22 |
woof
|
|
23 |
Actual : output:
|
|
24 |
meow
|
|
25 |
|
|
26 |
FAILED :
|
|
27 |
|
|
28 |
Demonstrate error expectation (Intentional fail.)
|
|
29 |
|
|
30 |
Location: test-freestyle-format.markdown, line 68
|
|
31 |
Function: Cat
|
|
32 |
Impl : shell command "python cat.py"
|
|
33 |
Body : meow
|
|
34 |
Expected: error:
|
|
35 |
bow
|
|
36 |
wow
|
|
37 |
Actual : output:
|
|
38 |
meow
|
|
39 |
|
|
40 |
--------------------------------
|
|
41 |
Total test runs: 10, failures: 3
|
|
42 |
--------------------------------
|
|
0 |
Falderal Test: "new" format for tests
|
|
1 |
-------------------------------------
|
|
2 |
|
|
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 `???> `.
|
|
9 |
|
|
10 |
-> Functionality "Cat" is implemented by shell command "python cat.py"
|
|
11 |
|
|
12 |
-> Tests for functionality "Cat"
|
|
13 |
|
|
14 |
Cat cats.
|
|
15 |
|
|
16 |
meow
|
|
17 |
=> meow
|
|
18 |
|
|
19 |
meow
|
|
20 |
==> meow
|
|
21 |
|
|
22 |
meow
|
|
23 |
===> meow
|
|
24 |
|
|
25 |
There may be multiple final lines.
|
|
26 |
|
|
27 |
purr
|
|
28 |
prrr
|
|
29 |
prreow
|
|
30 |
==> purr
|
|
31 |
==> prrr
|
|
32 |
==> prreow
|
|
33 |
|
|
34 |
The use of `==>` means that any text in the preceding lines that would,
|
|
35 |
in the previous format, be recognized as prefixes, are no longer recognized
|
|
36 |
as prefixes.
|
|
37 |
|
|
38 |
| purr
|
|
39 |
| prrr
|
|
40 |
| prreow
|
|
41 |
==> | purr
|
|
42 |
==> | prrr
|
|
43 |
==> | prreow
|
|
44 |
|
|
45 |
| purr
|
|
46 |
+ prrr
|
|
47 |
+ prreow
|
|
48 |
=> | purr
|
|
49 |
=> + prrr
|
|
50 |
=> + prreow
|
|
51 |
|
|
52 |
purr
|
|
53 |
-> prrr
|
|
54 |
prreow
|
|
55 |
===> purr
|
|
56 |
===> -> prrr
|
|
57 |
===> prreow
|
|
58 |
|
|
59 |
Demonstrate error expectation (Intentional fail.)
|
|
60 |
|
|
61 |
meow
|
|
62 |
?> woof
|
|
63 |
|
|
64 |
meow
|
|
65 |
??> woof
|
|
66 |
|
|
67 |
meow
|
|
68 |
???> bow
|
|
69 |
???> wow
|
tests/test-new-format.expected
less
more
0 | |
FAILED :
|
1 | |
|
2 | |
Demonstrate error expectation (Intentional fail.)
|
3 | |
|
4 | |
Location: test-new-format.markdown, line 55
|
5 | |
Function: Cat
|
6 | |
Impl : shell command "python cat.py"
|
7 | |
Body : meow
|
8 | |
Expected: error:
|
9 | |
woof
|
10 | |
Actual : output:
|
11 | |
meow
|
12 | |
|
13 | |
--------------------------------
|
14 | |
Total test runs: 6, failures: 1
|
15 | |
--------------------------------
|
tests/test-new-format.markdown
less
more
0 | |
Falderal Test: "new" format for tests
|
1 | |
-------------------------------------
|
2 | |
|
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 the prefix `==>` or `??> `
|
8 | |
|
9 | |
-> Functionality "Cat" is implemented by shell command "python cat.py"
|
10 | |
|
11 | |
-> Tests for functionality "Cat"
|
12 | |
|
13 | |
Cat cats.
|
14 | |
|
15 | |
meow
|
16 | |
==> meow
|
17 | |
|
18 | |
There may be multiple final lines.
|
19 | |
|
20 | |
purr
|
21 | |
prrr
|
22 | |
prreow
|
23 | |
==> purr
|
24 | |
==> prrr
|
25 | |
==> prreow
|
26 | |
|
27 | |
The use of `==>` means that any text in the preceding lines that would,
|
28 | |
in the previous format, be recognized as prefixes, are no longer recognized
|
29 | |
as prefixes.
|
30 | |
|
31 | |
| purr
|
32 | |
| prrr
|
33 | |
| prreow
|
34 | |
==> | purr
|
35 | |
==> | prrr
|
36 | |
==> | prreow
|
37 | |
|
38 | |
| purr
|
39 | |
+ prrr
|
40 | |
+ prreow
|
41 | |
==> | purr
|
42 | |
==> + prrr
|
43 | |
==> + prreow
|
44 | |
|
45 | |
purr
|
46 | |
-> prrr
|
47 | |
prreow
|
48 | |
==> purr
|
49 | |
==> -> prrr
|
50 | |
==> prreow
|
51 | |
|
52 | |
Demonstrate error expectation (Intentional fail.)
|
53 | |
|
54 | |
meow
|
55 | |
??> woof
|