test.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. load("app/frame/Dumper.js");
  2. function symbolize(opt) {
  3. symbols = null;
  4. JSDOC.JsDoc(opt);
  5. symbols = JSDOC.JsDoc.symbolSet;
  6. }
  7. var testCases = [
  8. function() {
  9. symbolize({a:true, p:true, _: [SYS.pwd+"test/overview.js"]});
  10. //print(Dumper.dump(symbols));
  11. is('symbols.getSymbolByName("My Cool Library").name', 'My Cool Library', 'File overview can be found by alias.');
  12. }
  13. ,
  14. function() {
  15. symbolize({_: [SYS.pwd+"test/name.js"]});
  16. is('symbols.getSymbol("Response").name', "Response", 'Virtual class name is found.');
  17. is('symbols.getSymbol("Response#text").alias', "Response#text", 'Virtual method name is found.');
  18. is('symbols.getSymbol("Response#text").memberOf', "Response", 'Virtual method parent name is found.');
  19. }
  20. ,
  21. function() {
  22. symbolize({a:true, p:true, _: [SYS.pwd+"test/prototype.js"]});
  23. is('symbols.getSymbol("Article").name', "Article", 'Function set to constructor prototype with inner constructor name is found.');
  24. is('symbols.getSymbol("Article").hasMethod("init")', true, 'The initializer method name of prototype function is correct.');
  25. is('symbols.getSymbol("Article").hasMember("counter")', true, 'A static property set in the prototype definition is found.');
  26. is('symbols.getSymbol("Article").hasMember("title")', true, 'An instance property set in the prototype is found.');
  27. is('symbols.getSymbol("Article#title").isStatic', false, 'An instance property has isStatic set to false.');
  28. is('symbols.getSymbol("Article.counter").name', "counter", 'A static property set in the initializer has the name set correctly.');
  29. is('symbols.getSymbol("Article.counter").memberOf', "Article", 'A static property set in the initializer has the memberOf set correctly.');
  30. is('symbols.getSymbol("Article.counter").isStatic', true, 'A static property set in the initializer has isStatic set to true.');
  31. }
  32. ,
  33. function() {
  34. symbolize({a:true, _: [SYS.pwd+"test/prototype_oblit.js"]});
  35. is('symbols.getSymbol("Article").name', "Article", 'Oblit set to constructor prototype name is found.');
  36. is('typeof symbols.getSymbol("Article.prototype")', "undefined", 'The prototype oblit is not a symbol.');
  37. is('symbols.getSymbol("Article#getTitle").name', "getTitle", 'The nonstatic method name of prototype oblit is correct.');
  38. is('symbols.getSymbol("Article#getTitle").alias', "Article#getTitle", 'The alias of non-static method of prototype oblit is correct.');
  39. is('symbols.getSymbol("Article#getTitle").isStatic', false, 'The isStatic of a nonstatic method of prototype oblit is correct.');
  40. is('symbols.getSymbol("Article.getTitle").name', "getTitle", 'The static method name of prototype oblit is correct.');
  41. is('symbols.getSymbol("Article.getTitle").isStatic', true, 'The isStatic of a static method of prototype oblit is correct.');
  42. is('symbols.getSymbol("Article#getTitle").isa', "FUNCTION", 'The isa of non-static method of prototype oblit is correct.');
  43. is('symbols.getSymbol("Article.getTitle").alias', "Article.getTitle", 'The alias of a static method of prototype oblit is correct.');
  44. is('symbols.getSymbol("Article.getTitle").isa', "FUNCTION", 'The isa of static method of prototype oblit is correct.');
  45. }
  46. ,
  47. function() {
  48. symbolize({a:true, p:true, _: [SYS.pwd+"test/prototype_oblit_constructor.js"]});
  49. is('symbols.getSymbol("Article").name', "Article", 'Oblit set to constructor prototype with inner constructor name is found.');
  50. is('symbols.getSymbol("Article#init").name', "init", 'The initializer method name of prototype oblit is correct.');
  51. is('symbols.getSymbol("Article").hasMember("pages")', true, 'Property set by initializer method "this" is on the outer constructor.');
  52. is('symbols.getSymbol("Article#Title").name', "Title", 'Name of the inner constructor name is found.');
  53. is('symbols.getSymbol("Article#Title").memberOf', "Article", 'The memberOf of the inner constructor name is found.');
  54. is('symbols.getSymbol("Article#Title").isa', "CONSTRUCTOR", 'The isa of the inner constructor name is constructor.');
  55. is('symbols.getSymbol("Article#Title").hasMember("title")', true, 'A property set on the inner constructor "this" is on the inner constructor.');
  56. }
  57. ,
  58. function() {
  59. symbolize({a:true, p:true, _: [SYS.pwd+"test/inner.js"]});
  60. is('symbols.getSymbol("Outer").name', "Outer", 'Outer constructor prototype name is found.');
  61. is('symbols.getSymbol("Outer").methods.length', 1, 'Inner function doesnt appear as a method of the outer.');
  62. is('symbols.getSymbol("Outer").hasMethod("open")', true, 'Outer constructors methods arent affected by inner function.');
  63. is('symbols.getSymbol("Outer-Inner").alias', "Outer-Inner", 'Alias of inner function is found.');
  64. is('symbols.getSymbol("Outer-Inner").isa', "CONSTRUCTOR", 'isa of inner function constructor is found.');
  65. is('symbols.getSymbol("Outer-Inner").memberOf', "Outer", 'The memberOf of inner function is found.');
  66. is('symbols.getSymbol("Outer-Inner").name', "Inner", 'The name of inner function is found.');
  67. is('symbols.getSymbol("Outer-Inner#name").name', "name", 'A member of the inner function constructor, attached to "this" is found on inner.');
  68. is('symbols.getSymbol("Outer-Inner#name").memberOf', "Outer-Inner", 'The memberOf of an inner function member is found.');
  69. }
  70. ,
  71. function() {
  72. symbolize({a:true, _: [SYS.pwd+"test/prototype_nested.js"]});
  73. is('symbols.getSymbol("Word").name', "Word", 'Base constructor name is found.');
  74. is('symbols.getSymbol("Word").hasMethod("reverse")', true, 'Base constructor method is found.');
  75. is('symbols.getSymbol("Word").methods.length', 1, 'Base constructor has only one method.');
  76. is('symbols.getSymbol("Word").memberOf', "", 'Base constructor memberOf is empty.');
  77. is('symbols.getSymbol("Word#reverse").name', "reverse", 'Member of constructor prototype name is found.');
  78. is('symbols.getSymbol("Word#reverse").memberOf', "Word", 'Member of constructor prototype memberOf is found.');
  79. is('symbols.getSymbol("Word#reverse.utf8").name', "utf8", 'Member of constructor prototype method name is found.');
  80. is('symbols.getSymbol("Word#reverse.utf8").memberOf', "Word#reverse", 'Static nested member memberOf is found.');
  81. }
  82. ,
  83. function() {
  84. symbolize({a:true, _: [SYS.pwd+"test/namespace_nested.js"]});
  85. is('symbols.getSymbol("ns1").name', "ns1", 'Base namespace name is found.');
  86. is('symbols.getSymbol("ns1").memberOf', "", 'Base namespace memberOf is empty (its a constructor).');
  87. is('symbols.getSymbol("ns1.ns2").name', "ns2", 'Nested namespace name is found.');
  88. is('symbols.getSymbol("ns1.ns2").alias', "ns1.ns2", 'Nested namespace alias is found.');
  89. is('symbols.getSymbol("ns1.ns2").memberOf', "ns1", 'Nested namespace memberOf is found.');
  90. is('symbols.getSymbol("ns1.ns2.Function1").name', "Function1", 'Method of nested namespace name is found.');
  91. is('symbols.getSymbol("ns1.ns2.Function1").memberOf', "ns1.ns2", 'Constructor of nested namespace memberOf is found.');
  92. }
  93. ,
  94. function() {
  95. symbolize({a:true, p:true, _: [SYS.pwd+"test/functions_nested.js"]});
  96. is('symbols.getSymbol("Zop").name', "Zop", 'Any constructor name is found.');
  97. is('symbols.getSymbol("Zop").isa', "CONSTRUCTOR", 'It isa constructor.');
  98. is('symbols.getSymbol("Zop").hasMethod("zap")', true, 'Its method name, set later, is in methods array.');
  99. is('symbols.getSymbol("Foo").name', "Foo", 'The containing constructor name is found.');
  100. is('symbols.getSymbol("Foo").hasMethod("methodOne")', true, 'Its method name is found.');
  101. is('symbols.getSymbol("Foo").hasMethod("methodTwo")', true, 'Its second method name is found.');
  102. is('symbols.getSymbol("Foo#methodOne").alias', "Foo#methodOne", 'A methods alias is found.');
  103. is('symbols.getSymbol("Foo#methodOne").isStatic', false, 'A methods is not static.');
  104. is('symbols.getSymbol("Bar").name', "Bar", 'A global function declared inside another function is found.');
  105. is('symbols.getSymbol("Bar").isa', "FUNCTION", 'It isa function.');
  106. is('symbols.getSymbol("Bar").memberOf', "_global_", 'It is global.');
  107. is('symbols.getSymbol("Foo-inner").name', "inner", 'An inner functions name is found.');
  108. is('symbols.getSymbol("Foo-inner").memberOf', "Foo", 'It is member of the outer function.');
  109. is('symbols.getSymbol("Foo-inner").isInner', true, 'It is an inner function.');
  110. }
  111. ,
  112. function() {
  113. symbolize({a:true, _: [SYS.pwd+"test/memberof_constructor.js"]});
  114. is('symbols.getSymbol("Circle#Tangent").name', "Tangent", 'Constructor set on prototype using @member has correct name.');
  115. is('symbols.getSymbol("Circle#Tangent").memberOf', "Circle", 'Constructor set on prototype using @member has correct memberOf.');
  116. is('symbols.getSymbol("Circle#Tangent").alias', "Circle#Tangent", 'Constructor set on prototype using @member has correct alias.');
  117. is('symbols.getSymbol("Circle#Tangent").isa', "CONSTRUCTOR", 'Constructor set on prototype using @member has correct isa.');
  118. is('symbols.getSymbol("Circle#Tangent").isStatic', false, 'Constructor set on prototype using @member is not static.');
  119. is('symbols.getSymbol("Circle#Tangent#getDiameter").name', "getDiameter", 'Method set on prototype using @member has correct name.');
  120. is('symbols.getSymbol("Circle#Tangent#getDiameter").memberOf', "Circle#Tangent", 'Method set on prototype using @member has correct memberOf.');
  121. is('symbols.getSymbol("Circle#Tangent#getDiameter").alias', "Circle#Tangent#getDiameter", 'Method set on prototype using @member has correct alias.');
  122. is('symbols.getSymbol("Circle#Tangent#getDiameter").isa', "FUNCTION", 'Method set on prototype using @member has correct isa.');
  123. is('symbols.getSymbol("Circle#Tangent#getDiameter").isStatic', false, 'Method set on prototype using @member is not static.');
  124. }
  125. ,
  126. function() {
  127. symbolize({a:true, p: true, _: [SYS.pwd+"test/memberof.js"]});
  128. is('symbols.getSymbol("pack.install").alias', "pack.install", 'Using @memberOf sets alias, when parent name is in memberOf tag.');
  129. is('symbols.getSymbol("pack.install.overwrite").name', "install.overwrite", 'Using @memberOf sets name, even if the name is dotted.');
  130. is('symbols.getSymbol("pack.install.overwrite").memberOf', "pack", 'Using @memberOf sets memberOf.');
  131. is('symbols.getSymbol("pack.install.overwrite").isStatic', true, 'Using @memberOf with value not ending in octothorp sets isStatic to true.');
  132. }
  133. ,
  134. function() {
  135. symbolize({a:true, p: true, _: [SYS.pwd+"test/memberof2.js"]});
  136. is('symbols.getSymbol("Foo#bar").alias', "Foo#bar", 'An inner function can be documented as an instance method.');
  137. is('symbols.getSymbol("Foo.zip").alias', "Foo.zip", 'An inner function can be documented as a static method.');
  138. is('symbols.getSymbol("Foo.Fiz").alias', "Foo.Fiz", 'An inner function can be documented as a static constructor.');
  139. is('symbols.getSymbol("Foo.Fiz#fipple").alias', "Foo.Fiz#fipple", 'An inner function can be documented as a static constructor with a method.');
  140. is('symbols.getSymbol("Foo#blat").alias', "Foo#blat", 'An global function can be documented as an instance method.');
  141. }
  142. ,
  143. function() {
  144. symbolize({a:true, p: true, _: [SYS.pwd+"test/memberof3.js"]});
  145. is('symbols.getSymbol("Foo#bar").alias', "Foo#bar", 'A virtual field can be documented as an instance method.');
  146. is('symbols.getSymbol("Foo2#bar").alias', "Foo2#bar", 'A virtual field with the same name can be documented as an instance method.');
  147. }
  148. ,
  149. function() {
  150. symbolize({a:true, p:true, _: [SYS.pwd+"test/borrows.js"]});
  151. is('symbols.getSymbol("Layout").name', "Layout", 'Constructor can be found.');
  152. is('symbols.getSymbol("Layout").hasMethod("init")', true, 'Constructor method name can be found.');
  153. is('symbols.getSymbol("Layout").hasMember("orientation")', true, 'Constructor property name can be found.');
  154. is('symbols.getSymbol("Page").hasMethod("reset")', true, 'Second constructor method name can be found.');
  155. is('symbols.getSymbol("Page").hasMember("orientation")', true, 'Second constructor borrowed property name can be found in properties.');
  156. is('symbols.getSymbol("Page#orientation").memberOf', "Page", 'Second constructor borrowed property memberOf can be found.');
  157. is('symbols.getSymbol("Page-getInnerElements").alias', "Page-getInnerElements", 'Can borrow an inner function and it is still inner.');
  158. is('symbols.getSymbol("Page.units").alias', "Page.units", 'Can borrow a static function and it is still static.');
  159. is('symbols.getSymbol("ThreeColumnPage#init").alias', "ThreeColumnPage#init", 'Third constructor method can be found even though method with same name is borrowed.');
  160. is('symbols.getSymbol("ThreeColumnPage#reset").alias', "ThreeColumnPage#reset", 'Borrowed method can be found.');
  161. is('symbols.getSymbol("ThreeColumnPage#orientation").alias', "ThreeColumnPage#orientation", 'Twice borrowed method can be found.');
  162. }
  163. ,
  164. function() {
  165. symbolize({a:true, p:true, _: [SYS.pwd+"test/borrows2.js"]});
  166. is('symbols.getSymbol("Foo").hasMethod("my_zop")', true, 'Borrowed method can be found.');
  167. is('symbols.getSymbol("Bar").hasMethod("my_zip")', true, 'Second borrowed method can be found.');
  168. }
  169. ,
  170. function() {
  171. symbolize({a:true, p:true, _: [SYS.pwd+"test/constructs.js"]});
  172. is('symbols.getSymbol("Person").hasMethod("say")', true, 'The constructs tag creates a class that lends can add a method to.');
  173. }
  174. ,
  175. function() {
  176. symbolize({a: true, _: [SYS.pwd+"test/augments.js", SYS.pwd+"test/augments2.js"]});
  177. is('symbols.getSymbol("Page").augments[0]', "Layout", 'An augmented class can be found.');
  178. is('symbols.getSymbol("Page#reset").alias', "Page#reset", 'Method of augmenter can be found.');
  179. is('symbols.getSymbol("Page").hasMethod("Layout#init")', true, 'Method from augmented can be found.');
  180. is('symbols.getSymbol("Page").hasMember("Layout#orientation")', true, 'Property from augmented can be found.');
  181. is('symbols.getSymbol("Page").methods.length', 3, 'Methods of augmented class are included in methods array.');
  182. is('symbols.getSymbol("ThreeColumnPage").augments[0]', "Page", 'The extends tag is a synonym for augments.');
  183. is('symbols.getSymbol("ThreeColumnPage").hasMethod("ThreeColumnPage#init")', true, 'Local method overrides augmented method of same name.');
  184. is('symbols.getSymbol("ThreeColumnPage").methods.length', 3, 'Local method count is right.');
  185. is('symbols.getSymbol("NewsletterPage").augments[0]', "ThreeColumnPage", 'Can augment across file boundaries.');
  186. is('symbols.getSymbol("NewsletterPage").augments.length', 2, 'Multiple augments are supported.');
  187. is('symbols.getSymbol("NewsletterPage").inherits[0].alias', "Junkmail#annoy", 'Inherited method with augments.');
  188. is('symbols.getSymbol("NewsletterPage").methods.length', 6, 'Methods of augmented class are included in methods array across files.');
  189. is('symbols.getSymbol("NewsletterPage").properties.length', 1, 'Properties of augmented class are included in properties array across files.');
  190. }
  191. ,
  192. function() {
  193. symbolize({a:true, _: [SYS.pwd+"test/static_this.js"]});
  194. is('symbols.getSymbol("box.holder").name', "holder", 'Static namespace name can be found.');
  195. is('symbols.getSymbol("box.holder.foo").name', "foo", 'Static namespace method name can be found.');
  196. is('symbols.getSymbol("box.holder").isStatic', true, 'Static namespace method is static.');
  197. is('symbols.getSymbol("box.holder.counter").name', "counter", 'Instance namespace property name set on "this" can be found.');
  198. is('symbols.getSymbol("box.holder.counter").alias', "box.holder.counter", 'Instance namespace property alias set on "this" can be found.');
  199. is('symbols.getSymbol("box.holder.counter").memberOf', "box.holder", 'Static namespace property memberOf set on "this" can be found.');
  200. }
  201. ,
  202. function() {
  203. symbolize({a:true, p: true, _: [SYS.pwd+"test/lend.js"]});
  204. is('symbols.getSymbol("Person").name', "Person", 'Class defined in lend comment is found.');
  205. is('symbols.getSymbol("Person").hasMethod("initialize")', true, 'Lent instance method name can be found.');
  206. is('symbols.getSymbol("Person").hasMethod("say")', true, 'Second instance method can be found.');
  207. is('symbols.getSymbol("Person#sing").isStatic', false, 'Instance method is known to be not static.');
  208. is('symbols.getSymbol("Person.getCount").name', "getCount", 'Static method name from second lend comment can be found.');
  209. is('symbols.getSymbol("Person.getCount").isStatic', true, 'Static method from second lend comment is known to be static.');
  210. is('LOG.warnings.filter(function($){if($.indexOf("notok") > -1) return $}).length', 1, 'A warning is emitted when lending to an undocumented parent.');
  211. }
  212. ,
  213. function() {
  214. symbolize({a:true, _: [SYS.pwd+"test/param_inline.js"]});
  215. is('symbols.getSymbol("Layout").params[0].type', "int", 'Inline param name is set.');
  216. is('symbols.getSymbol("Layout").params[0].desc', "The number of columns.", 'Inline param desc is set from comment.');
  217. is('symbols.getSymbol("Layout#getElement").params[0].name', "id", 'User defined param documentation takes precedence over parser defined.');
  218. is('symbols.getSymbol("Layout#getElement").params[0].isOptional', true, 'Default for param is to not be optional.');
  219. is('symbols.getSymbol("Layout#getElement").params[1].isOptional', false, 'Can mark a param as being optional.');
  220. is('symbols.getSymbol("Layout#getElement").params[1].type', "number|string", 'Type of inline param doc can have multiple values.');
  221. is('symbols.getSymbol("Layout#Canvas").params[0].type', "", 'Type can be not defined for some params.');
  222. is('symbols.getSymbol("Layout#Canvas").params[2].type', "int", 'Type can be defined inline for only some params.');
  223. is('symbols.getSymbol("Layout#rotate").params.length', 0, 'Docomments inside function sig is ignored without a param.');
  224. is('symbols.getSymbol("Layout#init").params[2].type', "zoppler", 'Doc comment type overrides inline type for param with same name.');
  225. }
  226. ,
  227. function() {
  228. symbolize({a: true, _: [SYS.pwd+"test/shared.js", SYS.pwd+"test/shared2.js"]});
  229. is('symbols.getSymbol("Array#some").name', 'some', 'The name of a symbol in a shared section is found.');
  230. is('symbols.getSymbol("Array#some").alias', 'Array#some', 'The alias of a symbol in a shared section is found.');
  231. is('symbols.getSymbol("Array#some").desc', "Extension to builtin array.", 'A description can be shared.');
  232. is('symbols.getSymbol("Array#filter").desc', "Extension to builtin array.\nChange every element of an array.", 'A shared description is appended.');
  233. is('symbols.getSymbol("Queue").desc', "A first in, first out data structure.", 'A description is not shared when outside a shared section.');
  234. is('symbols.getSymbol("Queue.rewind").alias', "Queue.rewind", 'Second shared tag can be started.');
  235. is('symbols.getSymbol("startOver").alias', "startOver", 'Shared tag doesnt cross over files.');
  236. }
  237. ,
  238. function() {
  239. symbolize({a: true, _: [SYS.pwd+"test/config.js"]});
  240. is('symbols.getSymbol("Contact").params[0].name', 'person', 'The name of a param is found.');
  241. is('symbols.getSymbol("Contact").params[1].name', 'person.name', 'The name of a param set with a dot name is found.');
  242. is('symbols.getSymbol("Contact").params[2].name', 'person.age', 'The name of a second param set with a dot name is found.');
  243. is('symbols.getSymbol("Contact").params[4].name', 'connection', 'The name of a param after config is found.');
  244. is('symbols.getSymbol("Family").params[0].name', 'persons', 'Another name of a param is found.');
  245. is('symbols.getSymbol("Family").params[1].name', 'persons.Father', 'The name of a param+config is found.');
  246. is('symbols.getSymbol("Family").params[2].name', 'persons.Mother', 'The name of a second param+config is found.');
  247. is('symbols.getSymbol("Family").params[3].name', 'persons.Children', 'The name of a third param+config is found.');
  248. }
  249. ,
  250. function() {
  251. symbolize({a:true, p:true, _: [SYS.pwd+"test/ignore.js"]});
  252. is('LOG.warnings.filter(function($){if($.indexOf("undocumented symbol Ignored") > -1) return $}).length', 1, 'A warning is emitted when documenting members of an ignored parent.');
  253. }
  254. ,
  255. function() {
  256. symbolize({a:true, p:true, _: [SYS.pwd+"test/functions_anon.js"]});
  257. is('symbols.getSymbol("a.b").alias', 'a.b', 'In anonymous constructor this is found to be the container object.');
  258. is('symbols.getSymbol("a.f").alias', 'a.f', 'In anonymous constructor this can have a method.');
  259. is('symbols.getSymbol("a.c").alias', 'a.c', 'In anonymous constructor method this is found to be the container object.');
  260. is('symbols.getSymbol("g").alias', 'g', 'In anonymous function executed inline this is the global.');
  261. is('symbols.getSymbol("bar2.p").alias', 'bar2.p', 'In named constructor executed inline this is the container object.');
  262. is('symbols.getSymbol("module.pub").alias', 'module.pub', 'In parenthesized anonymous function executed inline function scoped variables arent documented.');
  263. }
  264. ,
  265. function() {
  266. symbolize({a:true, p:true, _: [SYS.pwd+"test/oblit_anon.js"]});
  267. is('symbols.getSymbol("opt").name', 'opt', 'Anonymous object properties are created.');
  268. is('symbols.getSymbol("opt.conf.keep").alias', 'opt.conf.keep', 'Anonymous object first property is assigned to $anonymous.');
  269. is('symbols.getSymbol("opt.conf.base").alias', 'opt.conf.base', 'Anonymous object second property is assigned to $anonymous.');
  270. }
  271. ,
  272. function() {
  273. symbolize({a:true, p:true, _: [SYS.pwd+"test/params_optional.js"]});
  274. is('symbols.getSymbol("Document").params.length', 3, 'Correct number of params are found when optional param syntax is used.');
  275. is('symbols.getSymbol("Document").params[1].name', "id", 'Name of optional param is found.');
  276. is('symbols.getSymbol("Document").params[1].isOptional', true, 'Optional param is marked isOptional.');
  277. is('symbols.getSymbol("Document").params[2].name', "title", 'Name of optional param with default value is found.');
  278. is('symbols.getSymbol("Document").params[2].isOptional', true, 'Optional param with default value is marked isOptional.');
  279. is('symbols.getSymbol("Document").params[2].defaultValue', " This is untitled.", 'Optional param default value is found.');
  280. }
  281. ,
  282. function() {
  283. symbolize({a:true, p:true, _: [SYS.pwd+"test/synonyms.js"]});
  284. is('symbols.getSymbol("myObject.myFunc").type', 'function', 'Type can be set to function.');
  285. }
  286. ,
  287. function() {
  288. symbolize({a:true, p:true, _: [SYS.pwd+"test/event.js"]});
  289. is('symbols.getSymbol("Kitchen#event:cakeEaten").isEvent', true, 'Function with event prefix is an event.');
  290. is('symbols.getSymbol("Kitchen#cakeEaten").isa', "FUNCTION", 'Function with same name as event isa function.');
  291. }
  292. ,
  293. function() {
  294. symbolize({x:"js", a:true, _: [SYS.pwd+"test/scripts/"]});
  295. is('JSDOC.JsDoc.srcFiles.length', 1, 'Only js files are scanned when -x=js.');
  296. }
  297. ,
  298. function() {
  299. symbolize({x:"js", a:true, _: [SYS.pwd+"test/exports.js"]});
  300. is('symbols.getSymbol("mxn.Map#doThings").name', 'doThings', 'Exports creates a documentation alias that can have methods.');
  301. }
  302. ,
  303. function() {
  304. symbolize({p:true, a:true, _: [SYS.pwd+"test/module.js"]});
  305. is('symbols.getSymbol("myProject.myModule.myPublicMethod").name', 'myPublicMethod', 'A function wrapped in parens can be recognized.');
  306. is('symbols.getSymbol("myProject.myModule-myPrivateMethod").name', 'myPrivateMethod', 'A private method in the scope of a function wrapped in parens can be recognized.');
  307. is('symbols.getSymbol("myProject.myModule-myPrivateVar").name', 'myPrivateVar', 'A private member in the scope of a function wrapped in parens can be recognized.');
  308. }
  309. ,
  310. function() {
  311. symbolize({p:true, a:true, _: [SYS.pwd+"test/quoted_name.js"]});
  312. is('symbols.getSymbol("ns.name1").name', 'name1', 'A quoted name can be used.');
  313. is('symbols.getSymbol("ns.name2").name', 'name2', 'A non-quoted name can be used.');
  314. }
  315. ,
  316. function() {
  317. symbolize({p:true, a:true, _: [SYS.pwd+"test/params_dash.js"]});
  318. is('symbols.getSymbol("Document").params[0].name', "pages", 'Name of param with no dash is found.');
  319. is('symbols.getSymbol("Document").params[0].desc', "One or more pages.", 'Desc of param with no dash is found.');
  320. is('symbols.getSymbol("Document").params[1].name', "id", 'Name of param with spaced dash is found.');
  321. is('symbols.getSymbol("Document").params[1].desc', "Specifies the id.", 'Desc of param with spaced dash is found.');
  322. is('symbols.getSymbol("Document").params[2].name', "title", 'Name of param with nonspaced dash is found.');
  323. is('symbols.getSymbol("Document").params[2].desc', "Specifies the title.", 'Desc of param with non-spaced dash is found.');
  324. }
  325. ];
  326. //// run and print results
  327. print(testrun(testCases));