|
Lines 196-201
Link Here
|
| 196 |
} |
196 |
} |
| 197 |
}); |
197 |
}); |
| 198 |
}; |
198 |
}; |
|
|
199 |
|
| 200 |
/** |
| 201 |
* Tests an object property that is a literal wwhose value is a function |
| 202 |
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424149 |
| 203 |
*/ |
| 204 |
Tests.test_objproperty_literal1 = function() { |
| 205 |
context.text = "var obj = {\n"+ |
| 206 |
"\t\"item\": function(p1, p2) {}\n"+ |
| 207 |
"};"; |
| 208 |
return outliner.computeOutline(context).then(function(outline) { |
| 209 |
try { |
| 210 |
if(!outline || outline.length < 1) { |
| 211 |
Assert.fail("There should be one outline element"); |
| 212 |
} |
| 213 |
if(!outline[0].children || outline[0].children.length < 1) { |
| 214 |
Assert.fail("There should be one child outline element"); |
| 215 |
} |
| 216 |
assertElement(outline[0].children[0], "item(p1, p2)", 13, 19); |
| 217 |
} |
| 218 |
finally { |
| 219 |
tearDown(); |
| 220 |
} |
| 221 |
}); |
| 222 |
}; |
| 223 |
|
| 224 |
/** |
| 225 |
* Tests an object property that is a literal whose value has not been set |
| 226 |
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424149 |
| 227 |
*/ |
| 228 |
Tests.test_objproperty_literal2 = function() { |
| 229 |
context.text = "var obj = {\n"+ |
| 230 |
"\t\"item\": null\n"+ |
| 231 |
"};"; |
| 232 |
return outliner.computeOutline(context).then(function(outline) { |
| 233 |
try { |
| 234 |
if(!outline || outline.length < 1) { |
| 235 |
Assert.fail("There should be one outline element"); |
| 236 |
} |
| 237 |
if(!outline[0].children || outline[0].children.length < 1) { |
| 238 |
Assert.fail("There should be one child outline element"); |
| 239 |
} |
| 240 |
assertElement(outline[0].children[0], "item", 13, 19); |
| 241 |
} |
| 242 |
finally { |
| 243 |
tearDown(); |
| 244 |
} |
| 245 |
}); |
| 246 |
}; |
| 247 |
|
| 248 |
/** |
| 249 |
* Tests an object property that is a literal whose value is another object expression |
| 250 |
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424149 |
| 251 |
*/ |
| 252 |
Tests.test_objproperty_literal3 = function() { |
| 253 |
context.text = "var obj = {\n"+ |
| 254 |
"\t\"item\": {}\n"+ |
| 255 |
"};"; |
| 256 |
return outliner.computeOutline(context).then(function(outline) { |
| 257 |
try { |
| 258 |
if(!outline || outline.length < 1) { |
| 259 |
Assert.fail("There should be one outline element"); |
| 260 |
} |
| 261 |
if(!outline[0].children || outline[0].children.length < 1) { |
| 262 |
Assert.fail("There should be one child outline element"); |
| 263 |
} |
| 264 |
assertElement(outline[0].children[0], "item {...}", 13, 19); |
| 265 |
} |
| 266 |
finally { |
| 267 |
tearDown(); |
| 268 |
} |
| 269 |
}); |
| 270 |
}; |
| 271 |
|
| 272 |
/** |
| 273 |
* Tests a return statement that is an object expression |
| 274 |
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424202 |
| 275 |
*/ |
| 276 |
Tests.test_returnobj1 = function() { |
| 277 |
context.text = "function f1() {\n"+ |
| 278 |
"\t return {};\n"+ |
| 279 |
"};"; |
| 280 |
return outliner.computeOutline(context).then(function(outline) { |
| 281 |
try { |
| 282 |
if(!outline || outline.length < 1) { |
| 283 |
Assert.fail("There should be one outline element"); |
| 284 |
} |
| 285 |
if(!outline[0].children || outline[0].children.length < 1) { |
| 286 |
Assert.fail("There should be one child outline element"); |
| 287 |
} |
| 288 |
assertElement(outline[0].children[0], "return {...}", 18, 24); |
| 289 |
} |
| 290 |
finally { |
| 291 |
tearDown(); |
| 292 |
} |
| 293 |
}); |
| 294 |
}; |
| 295 |
|
| 296 |
/** |
| 297 |
* Tests a return statement that is an function expression |
| 298 |
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424202 |
| 299 |
*/ |
| 300 |
Tests.test_returnobj2 = function() { |
| 301 |
context.text = "function f1() {\n"+ |
| 302 |
"\t return function() {};\n"+ |
| 303 |
"};"; |
| 304 |
return outliner.computeOutline(context).then(function(outline) { |
| 305 |
try { |
| 306 |
if(!outline || outline.length < 1) { |
| 307 |
Assert.fail("There should be one outline element"); |
| 308 |
} |
| 309 |
if(!outline[0].children || outline[0].children.length < 1) { |
| 310 |
Assert.fail("There should be one child outline element"); |
| 311 |
} |
| 312 |
assertElement(outline[0].children[0], "return {...}", 18, 24); |
| 313 |
} |
| 314 |
finally { |
| 315 |
tearDown(); |
| 316 |
} |
| 317 |
}); |
| 318 |
}; |
| 319 |
|
| 320 |
/** |
| 321 |
* Tests a return statement that is an object expression |
| 322 |
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424202 |
| 323 |
*/ |
| 324 |
Tests.test_returnobj3 = function() { |
| 325 |
context.text = "function f1() {\n"+ |
| 326 |
"\t return {\n"+ |
| 327 |
"\t\tf1: function() {return {};}"+ |
| 328 |
"\t};"+ |
| 329 |
"};"; |
| 330 |
return outliner.computeOutline(context).then(function(outline) { |
| 331 |
try { |
| 332 |
if(!outline || outline.length < 1) { |
| 333 |
Assert.fail("There should be one outline element"); |
| 334 |
} |
| 335 |
if(!outline[0].children || outline[0].children.length < 1) { |
| 336 |
Assert.fail("There should be one level one child outline element"); |
| 337 |
} |
| 338 |
if(!outline[0].children[0].children || outline[0].children[0].children.length < 1) { |
| 339 |
Assert.fail("There should be one level two child outline element"); |
| 340 |
} |
| 341 |
if(!outline[0].children[0].children[0].children || outline[0].children[0].children[0].children.length < 1) { |
| 342 |
Assert.fail("There should be one level three child outline element"); |
| 343 |
} |
| 344 |
assertElement(outline[0].children[0].children[0].children[0], "return {...}", 45, 51); |
| 345 |
} |
| 346 |
finally { |
| 347 |
tearDown(); |
| 348 |
} |
| 349 |
}); |
| 350 |
}; |
| 351 |
|
| 352 |
/** |
| 353 |
* Tests a return statement that is an object expression |
| 354 |
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424202 |
| 355 |
*/ |
| 356 |
Tests.test_returnobj4 = function() { |
| 357 |
context.text = "function f1() {\n"+ |
| 358 |
"\t return {\n"+ |
| 359 |
"\t\tf1: function() {return function() {};}"+ |
| 360 |
"\t};"+ |
| 361 |
"};"; |
| 362 |
return outliner.computeOutline(context).then(function(outline) { |
| 363 |
try { |
| 364 |
if(!outline || outline.length < 1) { |
| 365 |
Assert.fail("There should be one outline element"); |
| 366 |
} |
| 367 |
if(!outline[0].children || outline[0].children.length < 1) { |
| 368 |
Assert.fail("There should be one level one child outline element"); |
| 369 |
} |
| 370 |
if(!outline[0].children[0].children || outline[0].children[0].children.length < 1) { |
| 371 |
Assert.fail("There should be one level two child outline element"); |
| 372 |
} |
| 373 |
if(!outline[0].children[0].children[0].children || outline[0].children[0].children[0].children.length < 1) { |
| 374 |
Assert.fail("There should be one level three child outline element"); |
| 375 |
} |
| 376 |
assertElement(outline[0].children[0].children[0].children[0], "return {...}", 45, 51); |
| 377 |
} |
| 378 |
finally { |
| 379 |
tearDown(); |
| 380 |
} |
| 381 |
}); |
| 382 |
}; |
| 199 |
|
383 |
|
| 200 |
return Tests; |
384 |
return Tests; |
| 201 |
}); |
385 |
}); |