1 module Test_xendconfsxp =
3 (* Empty file and comments *)
5 test Xendconfsxp.lns get "\n" = { }
7 test Xendconfsxp.lns get "# my comment\n" =
8 { "#scomment" = " my comment" }
10 test Xendconfsxp.lns get " \n# my comment\n" =
12 { "#scomment" = " my comment" }
14 test Xendconfsxp.lns get "# my comment\n\n" =
15 { "#scomment" = " my comment" }
18 test Xendconfsxp.lns get "# my comment\n \n" =
19 { "#scomment" = " my comment" }
22 test Xendconfsxp.lns get "# my comment\n#com2\n" =
23 { "#scomment" = " my comment" }
24 { "#scomment" = "com2" }
26 test Xendconfsxp.lns get "# my comment\n\n" =
27 { "#scomment" = " my comment" }
30 test Xendconfsxp.lns get "\n# my comment\n" =
32 { "#scomment" = " my comment" }
34 test Xendconfsxp.lns get "(key value)" =
35 { "key" { "item" = "value" } }
37 test Xendconfsxp.lns get "(key value)\n# com\n" =
38 { "key" { "item" = "value" } }
40 { "#scomment" = " com" }
42 test Xendconfsxp.lns get "(k2ey value)" =
43 { "k2ey" { "item" = "value" } }
45 test Xendconfsxp.lns get "(- value)" =
46 { "-" { "item" = "value" } }
48 test Xendconfsxp.lns get "(-bar value)" =
49 { "-bar" { "item" = "value" } }
51 test Xendconfsxp.lns get "(k-ey v-alue)\n# com\n" =
52 { "k-ey" { "item" = "v-alue" } }
54 { "#scomment" = " com" }
56 test Xendconfsxp.lns get "(key value)" =
57 { "key" { "item" = "value" } }
59 test Xendconfsxp.lns get "(key value)(key2 value2)" =
67 test Xendconfsxp.lns get "( key value )( key2 value2 )" =
75 let source_7 = "(key value)(key2 value2)"
76 test Xendconfsxp.lns get source_7 =
84 (* 2 items? it is a key/item *)
86 test Xendconfsxp.lns get "(key value)" =
91 test Xendconfsxp.lns get "( key value )" =
96 (* 3 items? Not allowed. 2nd item must be in ()'s *)
97 test Xendconfsxp.lns get "(key value value2)" = *
101 (* 0 item -- TODO: implement this. *)
103 test Xendconfsxp.lns get "( key ())" = *
107 test Xendconfsxp.lns get "(key (listitem1) )" =
110 { "item" = "listitem1" }
114 test Xendconfsxp.lns get "(key ( (foo bar bar bat ) ) )" =
126 test Xendconfsxp.lns get "(key ((foo foo foo (bar bar bar))))" =
144 test Xendconfsxp.lns get "(xen-api-server (foo bar))" =
152 test Xendconfsxp.lns get "( key ( value value2 ))" =
156 { "item" = "value2" }
162 test Xendconfsxp.lns get "( key ( value value2 value3 ))" =
166 { "item" = "value2" }
167 { "item" = "value3" }
172 test Xendconfsxp.lns get "(key \"foo\")" = { "key" { "item" = "\"foo\"" } }
173 test Xendconfsxp.lns get "(key \"\")" = { "key" { "item" = "\"\"" } }
174 test Xendconfsxp.lns get "( key \"foo\" )" = { "key" { "item" = "\"foo\"" } }
175 test Xendconfsxp.lns get "( key \"f oo\" )" = { "key" { "item" = "\"f oo\"" } }
176 test Xendconfsxp.lns get "( key \"f oo\" )" = { "key" { "item" = "\"f oo\"" } }
177 test Xendconfsxp.lns get "(foo \"this is \\\"quoted\\\" in quotes\")" =
178 { "foo" { "item" = "\"this is \\\"quoted\\\" in quotes\"" } }
180 test Xendconfsxp.lns get "( key \"fo\\'\" )" = { "key" { "item" = "\"fo\\'\""} }
181 test Xendconfsxp.lns get "( key \"fo\\'\" )" = { "key" { "item" = "\"fo\\'\""} }
182 test Xendconfsxp.lns get "( key \"\")" = { "key" { "item" = "\"\"" } }
184 (* Newlines in strange places *)
185 test Xendconfsxp.lns get "(\nkey\nbar\n)" = { "key" { "item" = "bar" } }
186 test Xendconfsxp.lns get "(\n\n\nkey\n\n\nbar\n\n\n)" = { "key" { "item" = "bar" } }
187 test Xendconfsxp.lns get "(\nkey\nbar\n)" = { "key" { "item" = "bar" } }
189 (* Comments in strange places *)
190 test Xendconfsxp.lns get "(\nkey #aa\nbar)" =
192 { "#comment" = "aa" }
196 test Xendconfsxp.lns get "(\nkey\n#aa\nbar)" =
198 { "#comment" = "aa" }
202 test Xendconfsxp.lns get "(\nkey\n #aa\nbar)" =
204 { "#comment" = "aa" }
208 (* Comments must have 1 space before the # *)
209 test Xendconfsxp.lns get "(\nkey# com\nbar\n)" = *
210 test Xendconfsxp.lns get "(\nkey#aa\nbar)" = *
212 (* Comments may start a line *)
213 test Xendconfsxp.lns get "(\nkey\n# com\nbar)" =
215 { "#comment" = "com" }
218 test Xendconfsxp.lns get "(\nkey\n#aa\nbar)" =
220 { "#comment" = "aa" }
225 test Xendconfsxp.lns get "(key ((foo foo) (bar bar)))" =
240 test Xendconfsxp.lns get "(aaa ((bbb ccc ddd) (eee fff)))" =
255 (* Comments in strange places *)
256 test Xendconfsxp.lns get "(\nkey\nbar # bb\n)" =
259 { "#comment" = "bb" }
261 test Xendconfsxp.lns get "(\nkey\nbar \n#cc\n)" =
262 { "key" { "item" = "bar" }
263 { "#comment" = "cc" } }
264 test Xendconfsxp.lns get "(\nkey\nbar \n #cc\n)" =
265 { "key" { "item" = "bar" }
266 { "#comment" = "cc" } }
267 test Xendconfsxp.lns get "(\nkey\nbar \n #cc\n )" =
268 { "key" { "item" = "bar" }
269 { "#comment" = "cc" } }
270 test Xendconfsxp.lns get "(foo ((foo foo foo) (unix none)))" =
285 test Xendconfsxp.lns get "(foo ((foo foo 'foo') (unix none)))" =
300 test Xendconfsxp.lns get "(xen-api-server ((9363 pam '^localhost$ example\\.com$') (unix none)))" =
306 { "item" = "'^localhost$ example\.com$'" }
315 test Xendconfsxp.lns get "# -*- sh -*-\n#foo\n#bar\n\n\n(foo bar)" =
316 { "#scomment" = " -*- sh -*-" }
317 { "#scomment" = "foo" }
318 { "#scomment" = "bar" }
325 (* Test whitespace before lparen *)
326 test Xendconfsxp.lns get " (network-script network-bridge)\n#\n" =
327 { "network-script" { "item" = "network-bridge" } }
333 (* Note: It works if you change the last \n to \t *)
334 test Xendconfsxp.lns get "(\nkey\n# com\nbar\n)" = *