git @ Cat's Eye Technologies Pail / 21d90c1
Modernize test suite. --HG-- rename : tests/Pail.falderal => tests/Pail.markdown Cat's Eye Technologies 12 years ago
3 changed file(s) with 190 addition(s) and 188 deletion(s). Raw diff Collapse all Expand all
00 #!/bin/sh
1 cd src && falderal test ../tests/Pail.falderal
1 cd src && falderal test ../tests/Pail.markdown
+0
-187
tests/Pail.falderal less more
0 -> encoding: UTF-8
1
2 Test Suite for Pail
3 ===================
4
5 This test suite is written in the format of Falderal 0.5. It is far from
6 exhaustive, but provides a basic sanity check that the language I've designed
7 here comes close to what I had in mind.
8
9 Pail Tests
10 ----------
11
12 -> Tests for Haskell function Pail:runPail
13
14 A symbol reduces to that symbol.
15
16 | fst
17 = fst
18
19 | plains-of-leng?
20 = plains-of-leng?
21
22 A symbol must begin with a letter and contain only letters, digits,
23 hyphens, and question marks.
24
25 | ^hey
26 = %(line 1, column 1):
27 = unexpected "^"
28 = expecting white space, "*", "#", "[" or letter
29
30 A pair reduces to that pair.
31
32 | [a b]
33 = [a b]
34
35 | [fst [a b]]
36 = [fst [a b]]
37
38 | [*fst [a b]]
39 = [*fst [a b]]
40
41 Square brackets must be properly matched.
42
43 | [a b
44 = %(line 1, column 5):
45 = unexpected end of input
46 = expecting letter or digit, "-", "?", "_", white space or "]"
47
48 Evaluation of a symbol reduces to that to which it is bound.
49
50 | *fst
51 = <fst>
52
53 Evaluation of a pair recursively reduces its contents.
54
55 | *[*fst [a b]]
56 = [<fst> [a b]]
57
58 | *[*fst *snd]
59 = [<fst> <snd>]
60
61 | *[*fst *[*snd *fst]]
62 = [<fst> [<snd> <fst>]]
63
64 Evaluation of a pair w/a fun on the lhs applies the fun.
65
66 | **[*fst [a b]]
67 = a
68
69 | **[*snd [a b]]
70 = b
71
72 Reducing an evaluation of a pair can accomplish a cons.
73
74 | *[**[*fst [a b]] **[*snd [c d]]]
75 = [a d]
76
77 Reducing on the lhs of a pair can obtain a fun to apply.
78
79 | **[**[*fst [*snd *fst]] [a b]]
80 = b
81
82 Applying uneval reduces to an evaluation.
83
84 | **[*uneval hello]
85 = *hello
86
87 The form `#x` is syntactic sugar for `**[*uneval x]`.
88
89 | #hello
90 = *hello
91
92 Syntactic sugar is expanded at parse time.
93
94 | [#fst [a b]]
95 = [**[*uneval fst] [a b]]
96
97 It is possible to uneval a fun.
98
99 | #*fst
100 = *<fst>
101
102 Reduction of an uneval'ed symbol can be used to obtain an eval'ed symbol.
103
104 | *[#fst [a b]]
105 = [*fst [a b]]
106
107 Reduction of uneval'ed symbol can be used to obtain a fun.
108
109 | **[#fst [a b]]
110 = [<fst> [a b]]
111
112 Reduction of uneval'ed symbol can be used to apply the obtained fun.
113
114 | ***[#fst [a b]]
115 = a
116
117 Positive test of `if-equal?` on symbols.
118
119 | **[*if-equal? [[a a] [one two]]]
120 = one
121
122 Negative test of `if-equal?` on symbols.
123
124 | **[*if-equal? [[a b] [one two]]]
125 = two
126
127 Negative test of `if-equal?` on evals.
128
129 | ***[*if-equal? [[*a *b] [fst snd]]]
130 = <snd>
131
132 Let can bind a symbol to a symbol.
133
134 | **[*let [[a b] *a]]
135 = b
136
137 Let can bind a symbol to a pair.
138
139 | **[*let [[g [x y]] **[*snd *g]]]
140 = y
141
142 Let can bind a symbol to an expression containing an uneval,
143 which can at a later point be eval'ed and reduced.
144
145 | **[*let [
146 | [sndg *[**[*uneval snd] **[*uneval g]]]
147 | **[*let [
148 | [g [x y]]
149 | ***sndg
150 | ]]
151 | ]]
152 = y
153
154 | **[*let [
155 | [cadrg *[#fst ##*[#snd #g]]]
156 | **[*let [
157 | [g [x [y z]]]
158 | ***cadrg
159 | ]]
160 | ]]
161 = y
162
163 Let can bind uneval'ed expression; prior bindings are honoured.
164
165 | **[*let [
166 | [g moo]
167 | **[*let [
168 | [consnull *[#g null]]
169 | ***consnull
170 | ]]
171 | ]]
172 = [moo null]
173
174 Let can bind uneval'ed expression; prior bindings are shadowed.
175
176 | **[*let [
177 | [g moo]
178 | **[*let [
179 | [consnull *[#g null]]
180 | **[*let [
181 | [g k]
182 | ***consnull
183 | ]]
184 | ]]
185 | ]]
186 = [k null]
0 Test Suite for Pail
1 ===================
2
3 This test suite is written in the format of Falderal 0.7. It is far from
4 exhaustive, but provides a basic sanity check that the language I've designed
5 here comes close to what I had in mind.
6
7 Pail Tests
8 ----------
9
10 -> Tests for functionality "Evaluate Pail Expression"
11
12 -> Functionality "Evaluate Pail Expression" is implemented by
13 -> shell command
14 -> "ghc -e "do c <- readFile \"%(test-file)\"; putStrLn $ Pail.runPail c" Pail.lhs"
15
16 A symbol reduces to that symbol.
17
18 | fst
19 = fst
20
21 | plains-of-leng?
22 = plains-of-leng?
23
24 A symbol must begin with a letter and contain only letters, digits,
25 hyphens, and question marks.
26
27 | ^hey
28 = %(line 1, column 1):
29 = unexpected "^"
30 = expecting white space, "*", "#", "[" or letter
31
32 A pair reduces to that pair.
33
34 | [a b]
35 = [a b]
36
37 | [fst [a b]]
38 = [fst [a b]]
39
40 | [*fst [a b]]
41 = [*fst [a b]]
42
43 Square brackets must be properly matched.
44
45 | [a b
46 = %(line 1, column 5):
47 = unexpected end of input
48 = expecting letter or digit, "-", "?", "_", white space or "]"
49
50 Evaluation of a symbol reduces to that to which it is bound.
51
52 | *fst
53 = <fst>
54
55 Evaluation of a pair recursively reduces its contents.
56
57 | *[*fst [a b]]
58 = [<fst> [a b]]
59
60 | *[*fst *snd]
61 = [<fst> <snd>]
62
63 | *[*fst *[*snd *fst]]
64 = [<fst> [<snd> <fst>]]
65
66 Evaluation of a pair w/a fun on the lhs applies the fun.
67
68 | **[*fst [a b]]
69 = a
70
71 | **[*snd [a b]]
72 = b
73
74 Reducing an evaluation of a pair can accomplish a cons.
75
76 | *[**[*fst [a b]] **[*snd [c d]]]
77 = [a d]
78
79 Reducing on the lhs of a pair can obtain a fun to apply.
80
81 | **[**[*fst [*snd *fst]] [a b]]
82 = b
83
84 Applying uneval reduces to an evaluation.
85
86 | **[*uneval hello]
87 = *hello
88
89 The form `#x` is syntactic sugar for `**[*uneval x]`.
90
91 | #hello
92 = *hello
93
94 Syntactic sugar is expanded at parse time.
95
96 | [#fst [a b]]
97 = [**[*uneval fst] [a b]]
98
99 It is possible to uneval a fun.
100
101 | #*fst
102 = *<fst>
103
104 Reduction of an uneval'ed symbol can be used to obtain an eval'ed symbol.
105
106 | *[#fst [a b]]
107 = [*fst [a b]]
108
109 Reduction of uneval'ed symbol can be used to obtain a fun.
110
111 | **[#fst [a b]]
112 = [<fst> [a b]]
113
114 Reduction of uneval'ed symbol can be used to apply the obtained fun.
115
116 | ***[#fst [a b]]
117 = a
118
119 Positive test of `if-equal?` on symbols.
120
121 | **[*if-equal? [[a a] [one two]]]
122 = one
123
124 Negative test of `if-equal?` on symbols.
125
126 | **[*if-equal? [[a b] [one two]]]
127 = two
128
129 Negative test of `if-equal?` on evals.
130
131 | ***[*if-equal? [[*a *b] [fst snd]]]
132 = <snd>
133
134 Let can bind a symbol to a symbol.
135
136 | **[*let [[a b] *a]]
137 = b
138
139 Let can bind a symbol to a pair.
140
141 | **[*let [[g [x y]] **[*snd *g]]]
142 = y
143
144 Let can bind a symbol to an expression containing an uneval,
145 which can at a later point be eval'ed and reduced.
146
147 | **[*let [
148 | [sndg *[**[*uneval snd] **[*uneval g]]]
149 | **[*let [
150 | [g [x y]]
151 | ***sndg
152 | ]]
153 | ]]
154 = y
155
156 | **[*let [
157 | [cadrg *[#fst ##*[#snd #g]]]
158 | **[*let [
159 | [g [x [y z]]]
160 | ***cadrg
161 | ]]
162 | ]]
163 = y
164
165 Let can bind uneval'ed expression; prior bindings are honoured.
166
167 | **[*let [
168 | [g moo]
169 | **[*let [
170 | [consnull *[#g null]]
171 | ***consnull
172 | ]]
173 | ]]
174 = [moo null]
175
176 Let can bind uneval'ed expression; prior bindings are shadowed.
177
178 | **[*let [
179 | [g moo]
180 | **[*let [
181 | [consnull *[#g null]]
182 | **[*let [
183 | [g k]
184 | ***consnull
185 | ]]
186 | ]]
187 | ]]
188 = [k null]