|
| 1 | +{ |
| 2 | + "exercise": "dot-dsl", |
| 3 | + "comments": [ |
| 4 | + "The inputs and outputs are represented as arrays of strings to", |
| 5 | + "improve readability in this JSON file.", |
| 6 | + "Your track may choose whether to present the input as a single", |
| 7 | + "string (concatenating all the lines) or as the list." |
| 8 | + ], |
| 9 | + "cases": [ |
| 10 | + { |
| 11 | + "uuid": "3a50c618-2571-466b-9ee9-346d9943912e", |
| 12 | + "description": "empty graph", |
| 13 | + "property": "parse", |
| 14 | + "input": { |
| 15 | + "text": [ |
| 16 | + "graph {", |
| 17 | + "}" |
| 18 | + ] |
| 19 | + }, |
| 20 | + "expected": { |
| 21 | + "nodes": {}, |
| 22 | + "edges": {}, |
| 23 | + "attrs": {} |
| 24 | + } |
| 25 | + }, |
| 26 | + { |
| 27 | + "uuid": "5067feea-e49b-4a9d-865e-4502d6b0540c", |
| 28 | + "description": "graph with one node", |
| 29 | + "property": "parse", |
| 30 | + "input": { |
| 31 | + "text": [ |
| 32 | + "graph {", |
| 33 | + " a;", |
| 34 | + "}" |
| 35 | + ] |
| 36 | + }, |
| 37 | + "expected": { |
| 38 | + "nodes": { |
| 39 | + "a": {} |
| 40 | + }, |
| 41 | + "edges": {}, |
| 42 | + "attrs": {} |
| 43 | + } |
| 44 | + }, |
| 45 | + { |
| 46 | + "uuid": "b66cf871-88c6-489a-b0b9-7c79b6819c45", |
| 47 | + "description": "graph with one node with attribute", |
| 48 | + "property": "parse", |
| 49 | + "input": { |
| 50 | + "text": [ |
| 51 | + "graph {", |
| 52 | + " a [color=green];", |
| 53 | + "}" |
| 54 | + ] |
| 55 | + }, |
| 56 | + "expected": { |
| 57 | + "nodes": { |
| 58 | + "a": { |
| 59 | + "color": "green" |
| 60 | + } |
| 61 | + }, |
| 62 | + "edges": {}, |
| 63 | + "attrs": {} |
| 64 | + } |
| 65 | + }, |
| 66 | + { |
| 67 | + "uuid": "f7841da3-c0f8-4541-b594-21b626a764d2", |
| 68 | + "description": "graph with one edge", |
| 69 | + "property": "parse", |
| 70 | + "input": { |
| 71 | + "text": [ |
| 72 | + "graph {", |
| 73 | + " a -- b;", |
| 74 | + "}" |
| 75 | + ] |
| 76 | + }, |
| 77 | + "expected": { |
| 78 | + "nodes": { |
| 79 | + "a": {}, |
| 80 | + "b": {} |
| 81 | + }, |
| 82 | + "edges": { |
| 83 | + "{a b}": {} |
| 84 | + }, |
| 85 | + "attrs": {} |
| 86 | + } |
| 87 | + }, |
| 88 | + { |
| 89 | + "uuid": "bbee70e1-6b0d-4f3a-bd4e-41cd2cfc0e39", |
| 90 | + "description": "graph with one attribute", |
| 91 | + "property": "parse", |
| 92 | + "input": { |
| 93 | + "text": [ |
| 94 | + "graph {", |
| 95 | + " [foo=1];", |
| 96 | + "}" |
| 97 | + ] |
| 98 | + }, |
| 99 | + "expected": { |
| 100 | + "nodes": {}, |
| 101 | + "edges": {}, |
| 102 | + "attrs": { |
| 103 | + "foo": 1 |
| 104 | + } |
| 105 | + } |
| 106 | + }, |
| 107 | + { |
| 108 | + "uuid": "ac736158-6684-418d-93d5-7b284e43294e", |
| 109 | + "description": "graph with comments", |
| 110 | + "property": "parse", |
| 111 | + "input": { |
| 112 | + "text": [ |
| 113 | + "graph {", |
| 114 | + " // a C-like comment", |
| 115 | + " # a shell-like comment", |
| 116 | + " [foo=1];", |
| 117 | + "}" |
| 118 | + ] |
| 119 | + }, |
| 120 | + "expected": { |
| 121 | + "nodes": {}, |
| 122 | + "edges": {}, |
| 123 | + "attrs": { |
| 124 | + "foo": 1 |
| 125 | + } |
| 126 | + } |
| 127 | + }, |
| 128 | + { |
| 129 | + "uuid": "69068da9-7690-4d4d-a728-f5c2bf132a33", |
| 130 | + "description": "graph with nodes, edges, and attributes", |
| 131 | + "property": "parse", |
| 132 | + "input": { |
| 133 | + "text": [ |
| 134 | + "graph {", |
| 135 | + " [foo=1];", |
| 136 | + " [title=\"Testing Attrs\"];", |
| 137 | + " a [color=green];", |
| 138 | + " b [label=\"Beta!\"];", |
| 139 | + " b -- c;", |
| 140 | + " a -- b [color=blue];", |
| 141 | + " [bar=true];", |
| 142 | + "}" |
| 143 | + ] |
| 144 | + }, |
| 145 | + "expected": { |
| 146 | + "nodes": { |
| 147 | + "a": { |
| 148 | + "color": "green" |
| 149 | + }, |
| 150 | + "b": { |
| 151 | + "label": "Beta!" |
| 152 | + }, |
| 153 | + "c": {} |
| 154 | + }, |
| 155 | + "edges": { |
| 156 | + "{a b}": { |
| 157 | + "color": "blue" |
| 158 | + }, |
| 159 | + "{b c}": {} |
| 160 | + }, |
| 161 | + "attrs": { |
| 162 | + "foo": 1, |
| 163 | + "title": "Testing Attrs", |
| 164 | + "bar": true |
| 165 | + } |
| 166 | + } |
| 167 | + }, |
| 168 | + { |
| 169 | + "uuid": "f6c53993-3937-4959-bcde-dc16411113ae", |
| 170 | + "description": "multiple edges on one line", |
| 171 | + "property": "parse", |
| 172 | + "input": { |
| 173 | + "text": [ |
| 174 | + "graph {", |
| 175 | + " a -- b -- c -- d [style=dotted];", |
| 176 | + "}" |
| 177 | + ] |
| 178 | + }, |
| 179 | + "expected": { |
| 180 | + "nodes": { |
| 181 | + "a": {}, |
| 182 | + "b": {}, |
| 183 | + "c": {}, |
| 184 | + "d": {} |
| 185 | + }, |
| 186 | + "edges": { |
| 187 | + "{a b}": { |
| 188 | + "style": "dotted" |
| 189 | + }, |
| 190 | + "{b c}": { |
| 191 | + "style": "dotted" |
| 192 | + }, |
| 193 | + "{c d}": { |
| 194 | + "style": "dotted" |
| 195 | + } |
| 196 | + }, |
| 197 | + "attrs": {} |
| 198 | + } |
| 199 | + }, |
| 200 | + { |
| 201 | + "uuid": "b853dfc1-1f05-45aa-bc98-b0fc6b57529b", |
| 202 | + "description": "only 1 edge between nodes", |
| 203 | + "property": "parse", |
| 204 | + "input": { |
| 205 | + "text": [ |
| 206 | + "graph {", |
| 207 | + " a -- b;", |
| 208 | + " a -- b;", |
| 209 | + " b -- a [color=blue];", |
| 210 | + "}" |
| 211 | + ] |
| 212 | + }, |
| 213 | + "expected": { |
| 214 | + "nodes": { |
| 215 | + "a": {}, |
| 216 | + "b": {} |
| 217 | + }, |
| 218 | + "edges": { |
| 219 | + "{a b}": { |
| 220 | + "color": "blue" |
| 221 | + } |
| 222 | + }, |
| 223 | + "attrs": {} |
| 224 | + } |
| 225 | + }, |
| 226 | + { |
| 227 | + "uuid": "bdc0fdac-aa46-457f-8385-65736ccdc1c7", |
| 228 | + "description": "malformed input", |
| 229 | + "property": "parse", |
| 230 | + "input": { |
| 231 | + "text": [ |
| 232 | + "graphical {", |
| 233 | + "}" |
| 234 | + ] |
| 235 | + }, |
| 236 | + "expected": { |
| 237 | + "error": "invalid graph" |
| 238 | + } |
| 239 | + }, |
| 240 | + { |
| 241 | + "uuid": "0192b408-828d-4052-b951-73a9c448a487ca", |
| 242 | + "description": "malformed edge", |
| 243 | + "property": "parse", |
| 244 | + "input": { |
| 245 | + "text": [ |
| 246 | + "graph {", |
| 247 | + " a --;", |
| 248 | + "}" |
| 249 | + ] |
| 250 | + }, |
| 251 | + "expected": { |
| 252 | + "error": "invalid edge" |
| 253 | + } |
| 254 | + }, |
| 255 | + { |
| 256 | + "uuid": "2238f6b8-20bb-489f-8ca0-084d1771d758", |
| 257 | + "description": "malformed edge 2", |
| 258 | + "property": "parse", |
| 259 | + "input": { |
| 260 | + "text": [ |
| 261 | + "graph {", |
| 262 | + " a b;", |
| 263 | + "}" |
| 264 | + ] |
| 265 | + }, |
| 266 | + "expected": { |
| 267 | + "error": "invalid edge" |
| 268 | + } |
| 269 | + }, |
| 270 | + { |
| 271 | + "uuid": "4e3a4386-9e80-4315-b70f-253a06a2234e", |
| 272 | + "description": "invalid edge type", |
| 273 | + "property": "parse", |
| 274 | + "input": { |
| 275 | + "text": [ |
| 276 | + "graph {", |
| 277 | + " a == b;", |
| 278 | + "} " |
| 279 | + ] |
| 280 | + }, |
| 281 | + "expected": { |
| 282 | + "error": "invalid edge" |
| 283 | + } |
| 284 | + }, |
| 285 | + { |
| 286 | + "uuid": "793adce3-bd19-4458-ac41-c989f7f8d9db", |
| 287 | + "description": "malformed multiple edges", |
| 288 | + "property": "parse", |
| 289 | + "input": { |
| 290 | + "text": [ |
| 291 | + "graph {", |
| 292 | + " a -- b --;", |
| 293 | + "}" |
| 294 | + ] |
| 295 | + }, |
| 296 | + "expected": { |
| 297 | + "error": "invalid edge" |
| 298 | + } |
| 299 | + }, |
| 300 | + { |
| 301 | + "uuid": "e2930b2c-3a03-4d8f-abe9-78a125a915a7", |
| 302 | + "description": "malformed multiple edges", |
| 303 | + "property": "parse", |
| 304 | + "input": { |
| 305 | + "text": [ |
| 306 | + "graph {", |
| 307 | + " a -- b c;", |
| 308 | + "}" |
| 309 | + ] |
| 310 | + }, |
| 311 | + "expected": { |
| 312 | + "error": "invalid edge" |
| 313 | + } |
| 314 | + }, |
| 315 | + { |
| 316 | + "uuid": "55d3f722-f9f1-46e1-b308-da61607952ab", |
| 317 | + "description": "empty attribute", |
| 318 | + "property": "parse", |
| 319 | + "input": { |
| 320 | + "text": [ |
| 321 | + "graph {", |
| 322 | + " a [];", |
| 323 | + "}" |
| 324 | + ] |
| 325 | + }, |
| 326 | + "expected": { |
| 327 | + "error": "invalid attribute" |
| 328 | + } |
| 329 | + }, |
| 330 | + { |
| 331 | + "uuid": "4ee2a9c3-54b1-4825-bd58-2b78c2c53953", |
| 332 | + "description": "malformed attribute", |
| 333 | + "property": "parse", |
| 334 | + "input": { |
| 335 | + "text": [ |
| 336 | + "graph {", |
| 337 | + " a [name];", |
| 338 | + "}" |
| 339 | + ] |
| 340 | + }, |
| 341 | + "expected": { |
| 342 | + "error": "invalid attribute" |
| 343 | + } |
| 344 | + }, |
| 345 | + { |
| 346 | + "uuid": "382a13c8-6419-4286-8dd2-eac708f3e2a8", |
| 347 | + "description": "empty attribute name", |
| 348 | + "property": "parse", |
| 349 | + "input": { |
| 350 | + "text": [ |
| 351 | + "graph {", |
| 352 | + " a [=value];", |
| 353 | + "}" |
| 354 | + ] |
| 355 | + }, |
| 356 | + "expected": { |
| 357 | + "error": "invalid attribute" |
| 358 | + } |
| 359 | + }, |
| 360 | + { |
| 361 | + "uuid": "a6f9e6ab-8c3e-4475-a9fe-5dd061cadec6", |
| 362 | + "description": "non-alphanumeric node name", |
| 363 | + "property": "parse", |
| 364 | + "input": { |
| 365 | + "text": [ |
| 366 | + "graph {", |
| 367 | + " ? [key=value];", |
| 368 | + "}" |
| 369 | + ] |
| 370 | + }, |
| 371 | + "expected": { |
| 372 | + "error": "node name must be alphanumeric" |
| 373 | + } |
| 374 | + } |
| 375 | + ] |
| 376 | +} |
0 commit comments