3 Provides unit tests and examples for the <Quote> lens.
9 let double = [ label "double" . Quote.double ]
12 test double get "\" this is a test\"" =
13 { "double" = " this is a test" }
15 (* View: double_opt *)
16 let double_opt = [ label "double_opt" . Quote.double_opt ]
18 (* Test: double_opt *)
19 test double_opt get "\"this is a test\"" =
20 { "double_opt" = "this is a test" }
22 (* Test: double_opt *)
23 test double_opt get "this is a test" =
24 { "double_opt" = "this is a test" }
27 Value cannot start with a space *)
28 test double_opt get " this is a test" = *
31 let single = [ label "single" . Quote.single ]
34 test single get "' this is a test'" =
35 { "single" = " this is a test" }
37 (* View: single_opt *)
38 let single_opt = [ label "single_opt" . Quote.single_opt ]
40 (* Test: single_opt *)
41 test single_opt get "'this is a test'" =
42 { "single_opt" = "this is a test" }
44 (* Test: single_opt *)
45 test single_opt get "this is a test" =
46 { "single_opt" = "this is a test" }
49 Value cannot start with a space *)
50 test single_opt get " this is a test" = *
53 let any = [ label "any" . Quote.any ]
56 test any get "\" this is a test\"" =
57 { "any" = " this is a test" }
60 test any get "' this is a test'" =
61 { "any" = " this is a test" }
64 let any_opt = [ label "any_opt" . Quote.any_opt ]
67 test any_opt get "\"this is a test\"" =
68 { "any_opt" = "this is a test" }
71 test any_opt get "'this is a test'" =
72 { "any_opt" = "this is a test" }
75 test any_opt get "this is a test" =
76 { "any_opt" = "this is a test" }
79 Value cannot start with a space *)
80 test any_opt get " this is a test" = *
82 (* View: double_opt_allow_spc *)
83 let double_opt_allow_spc =
84 let body = store /[^\n"]+/ in
85 [ label "double" . Quote.do_dquote_opt body ]
87 (* Test: double_opt_allow_spc *)
88 test double_opt_allow_spc get " test with spaces " =
89 { "double" = " test with spaces " }
91 (* Group: quote_spaces *)
93 (* View: quote_spaces *)
95 Quote.quote_spaces (label "spc")
99 test quote_spaces get "this" =
102 (* Test: quote_spaces
103 double quoted value *)
104 test quote_spaces get "\"this\"" =
107 (* Test: quote_spaces
108 single quoted value *)
109 test quote_spaces get "'this'" =
112 (* Test: quote_spaces
113 unquoted value with spaces *)
114 test quote_spaces get "this that those" = *
116 (* Test: quote_spaces
117 double quoted value with spaces *)
118 test quote_spaces get "\"this that those\"" =
119 { "spc" = "this that those" }
121 (* Test: quote_spaces
122 single quoted value with spaces *)
123 test quote_spaces get "'this that those'" =
124 { "spc" = "this that those" }
126 (* Test: quote_spaces
127 remove spaces from double-quoted value *)
128 test quote_spaces put "\"this that those\""
129 after set "spc" "thisthat" =
132 (* Test: quote_spaces
133 remove spaces from single-quoted value *)
134 test quote_spaces put "'this that those'"
135 after set "spc" "thisthat" =
138 (* Test: quote_spaces
139 add spaces to unquoted value *)
140 test quote_spaces put "this"
141 after set "spc" "this that those" =
142 "\"this that those\""
144 (* Test: quote_spaces
145 add spaces to double-quoted value *)
146 test quote_spaces put "\"this\""
147 after set "spc" "this that those" =
148 "\"this that those\""
150 (* Test: quote_spaces
151 add spaces to single-quoted value *)
152 test quote_spaces put "'this'"
153 after set "spc" "this that those" =
156 (* Group: dquote_spaces *)
158 (* View: dquote_spaces *)
160 Quote.dquote_spaces (label "spc")
162 (* Test: dquote_spaces
164 test dquote_spaces get "this" =
167 (* Test: dquote_spaces
168 double quoted value *)
169 test dquote_spaces get "\"this\"" =
172 (* Test: dquote_spaces
173 single quoted value *)
174 test dquote_spaces get "'this'" =
177 (* Test: dquote_spaces
178 unquoted value with spaces *)
179 test dquote_spaces get "this that those" = *
181 (* Test: dquote_spaces
182 double quoted value with spaces *)
183 test dquote_spaces get "\"this that those\"" =
184 { "spc" = "this that those" }
186 (* Test: dquote_spaces
187 single quoted value with spaces *)
188 test dquote_spaces get "'this that those'" = *
190 (* Test: dquote_spaces
191 remove spaces from double-quoted value *)
192 test dquote_spaces put "\"this that those\""
193 after set "spc" "thisthat" =
196 (* Test: dquote_spaces
197 add spaces to unquoted value *)
198 test dquote_spaces put "this"
199 after set "spc" "this that those" =
200 "\"this that those\""
202 (* Test: dquote_spaces
203 add spaces to double-quoted value *)
204 test dquote_spaces put "\"this\""
205 after set "spc" "this that those" =
206 "\"this that those\""
208 (* Test: dquote_spaces
209 add spaces to single-quoted value *)
210 test dquote_spaces put "'this'"
211 after set "spc" "this that those" =
212 "\"this that those\""
214 (* Group: squote_spaces *)
216 (* View: squote_spaces *)
218 Quote.squote_spaces (label "spc")
220 (* Test: squote_spaces
222 test squote_spaces get "this" =
225 (* Test: squote_spaces
226 double quoted value *)
227 test squote_spaces get "\"this\"" =
228 { "spc" = "\"this\"" }
230 (* Test: squote_spaces
231 single quoted value *)
232 test squote_spaces get "'this'" =
235 (* Test: squote_spaces
236 unquoted value with spaces *)
237 test squote_spaces get "this that those" = *
239 (* Test: squote_spaces
240 double quoted value with spaces *)
241 test squote_spaces get "\"this that those\"" = *
243 (* Test: squote_spaces
244 single quoted value with spaces *)
245 test squote_spaces get "'this that those'" =
246 { "spc" = "this that those" }
248 (* Test: squote_spaces
249 remove spaces from single-quoted value *)
250 test squote_spaces put "'this that those'"
251 after set "spc" "thisthat" =
254 (* Test: squote_spaces
255 add spaces to unquoted value *)
256 test squote_spaces put "this"
257 after set "spc" "this that those" =
260 (* Test: squote_spaces
261 add spaces to double-quoted value *)
262 test squote_spaces put "\"this\""
263 after set "spc" "this that those" =
266 (* Test: squote_spaces
267 add spaces to single-quoted value *)
268 test squote_spaces put "'this'"
269 after set "spc" "this that those" =
272 (* Group: nil cases *)
274 (* View: dquote_opt_nil *)
276 let body = store Quote.double_opt_re
277 in [ label "dquote_opt_nil" . Quote.do_dquote_opt_nil body ]?
279 (* Test: dquote_opt_nil *)
280 test dquote_opt_nil get "this" =
281 { "dquote_opt_nil" = "this" }
283 (* Test: dquote_opt_nil *)
284 test dquote_opt_nil get "'this'" =
285 { "dquote_opt_nil" = "'this'" }
287 (* Test: dquote_opt_nil *)
288 test dquote_opt_nil get "\"this\"" =
289 { "dquote_opt_nil" = "this" }
291 (* Test: dquote_opt_nil *)
292 test dquote_opt_nil put ""
293 after set "dquote_opt_nil" "this" =
296 (* Test: dquote_opt_nil *)
297 test dquote_opt_nil put "\"this\""
298 after set "dquote_opt_nil" "this" =
301 (* Test: dquote_opt_nil *)
302 test dquote_opt_nil put "'this'"
303 after set "dquote_opt_nil" "this" =
306 (* View: squote_opt_nil *)
308 let body = store Quote.single_opt_re
309 in [ label "squote_opt_nil" . Quote.do_squote_opt_nil body ]?
311 (* Test: squote_opt_nil *)
312 test squote_opt_nil get "this" =
313 { "squote_opt_nil" = "this" }
315 (* Test: squote_opt_nil *)
316 test squote_opt_nil get "'this'" =
317 { "squote_opt_nil" = "this" }
319 (* Test: squote_opt_nil *)
320 test squote_opt_nil get "\"this\"" =
321 { "squote_opt_nil" = "\"this\"" }
323 (* Test: squote_opt_nil *)
324 test squote_opt_nil put ""
325 after set "squote_opt_nil" "this" =
328 (* Test: squote_opt_nil *)
329 test squote_opt_nil put "\"this\""
330 after set "squote_opt_nil" "this" =
333 (* Test: squote_opt_nil *)
334 test squote_opt_nil put "\"this\""
335 after set "squote_opt_nil" "this" =
338 (* View: quote_opt_nil *)
340 let body = store Quote.any_opt_re
341 in [ label "quote_opt_nil" . Quote.do_quote_opt_nil body ]?
343 (* Test: quote_opt_nil *)
344 test quote_opt_nil get "this" =
345 { "quote_opt_nil" = "this" }
347 (* Test: quote_opt_nil *)
348 test quote_opt_nil get "'this'" =
349 { "quote_opt_nil" = "this" }
351 (* Test: quote_opt_nil *)
352 test quote_opt_nil get "\"this\"" =
353 { "quote_opt_nil" = "this" }
355 (* Test: quote_opt_nil *)
356 test quote_opt_nil put ""
357 after set "quote_opt_nil" "this" =
360 (* Test: quote_opt_nil *)
361 test quote_opt_nil put "\"this\""
362 after set "quote_opt_nil" "this" =
365 (* Test: quote_opt_nil *)
366 test quote_opt_nil put "'this'"
367 after set "quote_opt_nil" "this" =