Refactor test driver a bit to accomodate Pifxley.
catseye
13 years ago
21 | 21 | # of the function will be output. |
22 | 22 | |
23 | 23 | # This script requires a Scheme implementation which can run |
24 | # Scheme programs from the command line. plt-r5rs does the trick. | |
24 | # Scheme programs from the command line. plt-r5rs, from the Racket | |
25 | # distribution (sudo apt-get install racket), does the trick. | |
25 | 26 | # If you want to use a different Scheme implementation, you can set |
26 | 27 | # the environment variable R5RS before running this. |
28 | ||
29 | # The environment variable PIXLEY can also be set to point to a different | |
30 | # implementation of Pixley (written in (some subset of) R5RS). As a | |
31 | # special, setting it to the value R5RS will run source.pix directly in | |
32 | # Scheme (just as scheme.sh does.) | |
27 | 33 | |
28 | 34 | if [ "${R5RS}x" = "x" ]; then |
29 | 35 | R5RS=plt-r5rs |
37 | 43 | PIXLEY=pixley.pix |
38 | 44 | fi |
39 | 45 | |
40 | cat >driver.scm <<EOF | |
46 | if [ "${PIXLEY}x" = "R5RSx" ]; then | |
47 | cat >driver.scm <<EOF | |
48 | (define program | |
49 | EOF | |
50 | cat >>driver.scm <$1 | |
51 | cat >>driver.scm <<EOF | |
52 | ) | |
53 | EOF | |
54 | if [ "${2}x" = "x" ]; then | |
55 | cat >>driver.scm <<EOF | |
56 | program | |
57 | EOF | |
58 | else | |
59 | cat >>driver.scm <<EOF | |
60 | (program (quote | |
61 | EOF | |
62 | cat >>driver.scm <$2 | |
63 | cat >>driver.scm <<EOF | |
64 | )) | |
65 | EOF | |
66 | fi | |
67 | else | |
68 | cat >driver.scm <<EOF | |
41 | 69 | (define pixley |
42 | 70 | EOF |
43 | cat ${PIXLEYDIR}/${PIXLEY} >>driver.scm | |
44 | cat >>driver.scm <<EOF | |
71 | cat ${PIXLEYDIR}/${PIXLEY} >>driver.scm | |
72 | cat >>driver.scm <<EOF | |
45 | 73 | ) |
74 | EOF | |
75 | cat >>driver.scm <<EOF | |
46 | 76 | (define program (quote |
47 | 77 | EOF |
48 | cat >>driver.scm <$1 | |
49 | cat >>driver.scm <<EOF | |
78 | cat >>driver.scm <$1 | |
79 | cat >>driver.scm <<EOF | |
50 | 80 | )) |
51 | 81 | EOF |
52 | if [ "${2}x" = "x" ]; then | |
53 | cat >>driver.scm <<EOF | |
82 | if [ "${2}x" = "x" ]; then | |
83 | cat >>driver.scm <<EOF | |
54 | 84 | (pixley pixley program '()) |
55 | 85 | EOF |
56 | else | |
57 | cat >>driver.scm <<EOF | |
86 | else | |
87 | cat >>driver.scm <<EOF | |
58 | 88 | (define foonction (pixley pixley program '())) |
59 | 89 | (foonction (list (quote |
60 | 90 | EOF |
61 | cat >>driver.scm <$2 | |
62 | cat >>driver.scm <<EOF | |
91 | cat >>driver.scm <$2 | |
92 | cat >>driver.scm <<EOF | |
63 | 93 | ))) |
64 | 94 | EOF |
95 | fi | |
65 | 96 | fi |
66 | 97 | |
67 | 98 | $R5RS driver.scm |
3 | 3 | -> Tests for functionality "Interpret Pixley Program" |
4 | 4 | |
5 | 5 | -> Functionality "Interpret Pixley Program" is implemented by |
6 | -> shell command "(cat >foo.pix && ../script/scheme.sh foo.pix)" | |
7 | ||
8 | -> Functionality "Interpret Pixley Program" is implemented by | |
9 | 6 | -> shell command "(cat >foo.pix && ../script/pixley.sh foo.pix)" |
10 | ||
11 | -> Functionality "Interpret Pixley Program" is implemented by | |
12 | -> shell command "(PIXLEY=../dialect/pixley.pifx cat >foo.pix && ../script/pixley.sh foo.pix)" | |
13 | 7 | |
14 | 8 | Constructing and Manipulating Data |
15 | 9 | ---------------------------------- |
0 | 0 | #!/bin/sh |
1 | ||
2 | echo "Running Falderal tests for Pixley..." | |
3 | ||
4 | cd src && falderal test tests.falderal | |
5 | rm -f foo.pix | |
6 | cd .. | |
7 | 1 | |
8 | 2 | echo "Sanity-testing scheme.sh and pixley.sh..." |
9 | 3 | |
25 | 19 | diff -u expected.sexp out.sexp |
26 | 20 | rm -f expected.sexp out.sexp |
27 | 21 | |
22 | echo "Testing Pixley programs as Scheme programs..." | |
23 | ||
24 | cd src && PIXLEY=R5RS falderal test tests.falderal | |
25 | rm -f foo.pix | |
26 | cd .. | |
27 | ||
28 | echo "Testing Pixley programs on reference interpreter..." | |
29 | ||
30 | cd src && falderal test tests.falderal | |
31 | rm -f foo.pix | |
32 | cd .. | |
33 | ||
34 | echo "Running Falderal tests for P-Normalizer..." | |
35 | ||
36 | cd dialect && falderal test p-normal.falderal | |
37 | rm -f foo.pix | |
38 | cd .. | |
39 | ||
40 | echo "P-Normalizing Pixley interpreter..." | |
41 | ||
42 | script/pixley.sh dialect/p-normal.pix src/pixley.pix > src/p-normal-pixley.pix | |
43 | ||
44 | echo "Testing Pixley programs on P-Normalized interpreter..." | |
45 | ||
46 | cd src && PIXLEY=p-normal-pixley.pix falderal test tests.falderal | |
47 | rm -f foo.pix p-normal-pixley.pix | |
48 | cd .. | |
49 | ||
50 | echo "Testing Pixley programs on Pixley interpreter in Pifxley..." | |
51 | ||
52 | cd src && PIXLEY=../dialect/pixley.pifx falderal test tests.falderal | |
53 | rm -f foo.pix p-normal-pixley.pix | |
54 | cd .. | |
55 | ||
56 | # Optional Mini-Scheme tests | |
57 | ||
28 | 58 | echo 'quit' | miniscm >/dev/null 2>&1 |
29 | 59 | if [ $? = 0 ] |
30 | 60 | then |
41 | 71 | else |
42 | 72 | echo "miniscm not installed, skipping. Your loss I guess." |
43 | 73 | fi |
44 | ||
45 | echo "Running Falderal tests for P-Normalizer..." | |
46 | ||
47 | cd dialect && falderal test p-normal.falderal | |
48 | rm -f foo.pix | |
49 | cd .. | |
50 | ||
51 | echo "P-Normalizing Pixley interpreter..." | |
52 | ||
53 | script/pixley.sh dialect/p-normal.pix src/pixley.pix > src/p-normal-pixley.pix | |
54 | ||
55 | echo "Testing Pixley programs on P-Normalized interpreter..." | |
56 | ||
57 | cd src && PIXLEY=p-normal-pixley.pix falderal test tests.falderal | |
58 | rm -f foo.pix p-normal-pixley.pix | |
59 | cd .. |