git @ Cat's Eye Technologies Robin / 05b3e2a
I don't like fixtures, but this lets us ditch unbundle-modules.py. --HG-- branch : no_improper_lists catseye 13 years ago
8 changed file(s) with 15 addition(s) and 78 deletion(s). Raw diff Collapse all Expand all
294294 * Informally test tail-recursive behavior (does an infinite loop
295295 leak memory?)
296296
297 * Find another way (one that works on Windows) to do what
298 `unbundle-modules.py` currently does.
299
300297 * Improve Falderal to let tests take some text as input; use this for the
301298 tests for `crude-input`.
302299
+0
-44
bin/unbundle_modules.py less more
0 #!/usr/bin/env python
1
2 import os
3 import sys
4 import re
5
6 module = None
7 major = None
8 minor = None
9 filename = None
10
11 stuff = {}
12
13 if __name__ == '__main__':
14 f = open(sys.argv[1], 'r')
15 for line in f:
16 match = re.match(r'^\-*\s*module\s*(\w+)\s*(\d+)\s*\.?\s*(\d+)\s*$', line)
17 if match:
18 module = match.group(1)
19 major = match.group(2)
20 minor = match.group(3)
21 filename = "module/%s_%s_%s.robin" % (module, major, minor)
22 stuff[filename] = []
23 continue
24 match = re.match(r'^\-*\s*main\s*$', line)
25 if match:
26 filename = "unbundled.robin"
27 stuff[filename] = []
28 continue
29 stuff[filename].append(line)
30 f.close()
31
32 for filename in stuff.keys():
33 f = open(filename, 'w')
34 for line in stuff[filename]:
35 f.write(line)
36 f.close()
37
38 exitcode = (os.system("bin/robin unbundled.robin") / 256)
39
40 for filename in stuff.keys():
41 os.unlink(filename)
42
43 sys.exit(exitcode)
22 Miscellanous Module Tests
33 =========================
44
5 -> Functionality "Interpret Bundled Robin Program" is implemented by
6 -> shell command "bin/unbundle_modules.py %(test-file)"
7
8 -> Tests for functionality "Interpret Bundled Robin Program"
5 -> Tests for functionality "Interpret Robin Program"
96
107 This document contains miscellaneous tests for module functionality;
118 tests that require multiple modules be loaded, and so forth.
1310 Modules are cached, so that a module referenced by two other modules
1411 is not loaded twice.
1512
16 | ----- module a 0.1
17 | (robin (0 1) ((small (0 1) *) (random (0 1) *))
18 | (pair (pair (literal random-a) random) ()))
19 | ----- module b 0.1
20 | (robin (0 1) ((small (0 1) *) (random (0 1) *))
21 | (pair (pair (literal random-b) random) ()))
22 | ----- main
23 | (robin (0 1) ((core (0 1) *) (a (0 1) *) (b (0 1) *))
13 | (robin (0 1) ((core (0 1) *) (random-a (0 1) *) (random-b (0 1) *))
2414 | (equal? random-a random-b))
2515 = #t
2616
2717 Circular module imports produce an error rather than going into an infinite
2818 loop.
2919
30 | ----- module a 0.1
31 | (robin (0 1) ((small (0 1) *) (b (0 1) *))
32 | (pair (pair (literal literal-a) literal-b) ()))
33 | ----- module b 0.1
34 | (robin (0 1) ((small (0 1) *) (a (0 1) *))
35 | (pair (pair (literal literal-b) literal-a) ()))
36 | ----- main
37 | (robin (0 1) ((core (0 1) *) (a (0 1) *))
20 | (robin (0 1) ((core (0 1) *) (circular-a (0 1) *))
3821 | (equal? literal-a literal-b))
39 ? robin: circular reference in module a
40
41 -> Functionality "Interpret Robin Program" is implemented by
42 -> shell command "bin/robin %(test-file)"
43
44 -> Tests for functionality "Interpret Robin Program"
22 ? robin: circular reference in module circular-a
4523
4624 `and` is short-circuiting.
4725
0 (robin (0 1) ((small (0 1) *) (circular-b (0 1) *))
1 (pair (pair (literal literal-a) (pair literal-b ())) ()))
0 (robin (0 1) ((small (0 1) *) (circular-a (0 1) *))
1 (pair (pair (literal literal-b) (pair literal-a ())) ()))
0 (robin (0 1) ((small (0 1) *) (random (0 1) *))
1 (pair (pair (literal random-a) (pair random ())) ()))
0 (robin (0 1) ((small (0 1) *) (random (0 1) *))
1 (pair (pair (literal random-b) (pair random ())) ()))
2424 if [ -e bin/robin.exe ]; then
2525 falderal test -b \
2626 -c "Interpret Robin Program" \
27 -c "Interpret Bundled Robin Program" \
2827 -c "Interpret Robin Program without output" \
29 -f 'Interpret Robin Program:shell command "bin\\robin.exe -m module %(test-file)"' \
30 -f 'Interpret Bundled Robin Program:shell command "c:\\Python27\\python.exe bin\\unbundle_modules.py %(test-file)"' \
28 -f 'Interpret Robin Program:shell command "bin\\robin.exe -m module -m fixture\\module %(test-file)"' \
3129 -f 'Interpret Robin Program without output:shell command "bin\\robin.exe -m module -n %(test-file)"' \
3230 ${FILES}
3331 rm -f results*
3432 else
3533 falderal test -b \
36 -f 'Interpret Robin Program:shell command "bin/robin %(test-file)"' \
34 -c "Interpret Robin Program" \
35 -f 'Interpret Robin Program:shell command "bin/robin -m module -m fixture/module %(test-file)"' \
3736 ${FILES}
3837 fi
39