19def.t 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. use strict;
  2. use File::Spec;
  3. BEGIN { if (defined($ENV{'top_srcdir'})) {unshift @INC, File::Spec->catdir($ENV{'top_srcdir'}, 'tp');} }
  4. require 't/test_utils.pl';
  5. my @test_cases = (
  6. ['all_commands',
  7. '@defvr c--ategory d--efvr_name
  8. d--efvr
  9. @end defvr
  10. @deftypefn c--ategory t--ype d--eftypefn_name a--rguments...
  11. d--eftypefn
  12. @end deftypefn
  13. @deftypeop c--ategory c--lass t--ype d--eftypeop_name a--rguments...
  14. d--eftypeop
  15. @end deftypeop
  16. @deftypevr c--ategory t--ype d--eftypevr_name
  17. d--eftypevr
  18. @end deftypevr
  19. @defcv c--ategory c--lass d--efcv_name
  20. d--efcv
  21. @end defcv
  22. @defop c--ategory c--lass d--efop_name a--rguments...
  23. d--efop
  24. @end defop
  25. @deftp c--ategory d--eftp_name a--ttributes...
  26. d--eftp
  27. @end deftp
  28. @defun d--efun_name a--rguments...
  29. d--efun
  30. @end defun
  31. @defmac d--efmac_name a--rguments...
  32. d--efmac
  33. @end defmac
  34. @defspec d--efspec_name a--rguments...
  35. d--efspec
  36. @end defspec
  37. @defvar d--efvar_name
  38. d--efvar
  39. @end defvar
  40. @defopt d--efopt_name
  41. d--efopt
  42. @end defopt
  43. @deftypefun t--ype d--eftypefun_name a--rguments...
  44. d--eftypefun
  45. @end deftypefun
  46. @deftypevar t--ype d--eftypevar_name
  47. d--eftypevar
  48. @end deftypevar
  49. @defivar c--lass d--efivar_name
  50. d--efivar
  51. @end defivar
  52. @deftypeivar c--lass t--ype d--eftypeivar_name
  53. d--eftypeivar
  54. @end deftypeivar
  55. @defmethod c--lass d--efmethod_name a--rguments...
  56. d--efmethod
  57. @end defmethod
  58. @deftypemethod c--lass t--ype d--eftypemethod_name a--rguments...
  59. d--eftypemethod
  60. @end deftypemethod
  61. '],
  62. ['end_of_lines_protected',
  63. '@deffn category deffn_name arguments @
  64. more {args @
  65. with end of line within} with 3 @@ @@@
  66. {one last arg}
  67. deffn
  68. @end deffn
  69. '],
  70. ['empty_def_command',
  71. '@deffn empty deffn
  72. @end deffn
  73. @deffn empty deffn with deffnx
  74. @deffnx empty deffnx
  75. @end deffn
  76. '],
  77. ['leading_space_in_def_arg',
  78. '@deffn category { name} arg
  79. @end deffn
  80. '],
  81. ['defx_after_comment',
  82. '@deffn fset @var{i} a g
  83. @c comment
  84. @deffnx {truc} bidulr machin...
  85. @end deffn'],
  86. ['inter_item_commands_in_def',
  87. '@deffn fset @var{i} a g
  88. @c comment before first deffnx
  89. @deffnx Command { log trap1} {}
  90. @cindex between deffnx
  91. @deffnx cmde2 @b{id @samp{i} ule} truc
  92. @cindex cindex in deff item
  93. In deff item.
  94. @end deffn
  95. '],
  96. ['inter_item_commands_in_def_in_example',
  97. '@example
  98. @deffn fset @var{i} a g
  99. @c comment before first deffnx
  100. @deffnx Command { log trap1} {}
  101. @cindex between deffnx
  102. @deffnx cmde2 @b{id @samp{i} ule} truc
  103. @cindex cindex in deff item
  104. In deff item.
  105. @end deffn
  106. @end example
  107. '],
  108. ['defx_after_empty_line',
  109. '@deffn fset @var{i} a g
  110. @deffnx {truc} bidulr machin...
  111. @end deffn'],
  112. ['defx_in_example',
  113. '@example
  114. @deffn fset @var{i} a g
  115. @deffnx {truc} bidulr machin...
  116. @end deffn
  117. @end example
  118. '],
  119. ['defx_after_comment_in_example',
  120. '@example
  121. @deffn fset @var{i} a g
  122. @c comment
  123. @deffnx {truc} bidulr machin...
  124. @end deffn
  125. @end example
  126. '],
  127. ['defx_after_empty_line_in_example',
  128. '@example
  129. @deffn fset @var{i} a g
  130. @c c
  131. @comment comment
  132. @deffnx {truc} bidulr machin...
  133. @end deffn
  134. @end example
  135. '],
  136. ['end_of_lines_protected_in_footnote',
  137. '@footnote{
  138. @deffn category deffn_name arguments arg2 @
  139. more {args @
  140. with end of line within} with 3 @@ @@@
  141. {one last arg}
  142. deffn
  143. @end deffn
  144. }
  145. '],
  146. ['all_commands_delimiters',
  147. '@deffn Command @var{forward--char} @var{nchars} {argument2} {argument3} @
  148. (arg in brace, [something @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) last
  149. @end deffn
  150. @defvr Variable fill-column {argument1} {argument2} @
  151. (arg in brace, [something @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) last
  152. @end defvr
  153. @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  154. @end deftypefn
  155. @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) @
  156. (arg in brace, {[something} @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) ct@*@* last
  157. @end deftypefn
  158. @deftypefn {Library Function} int foobug {[something}
  159. @end deftypefn
  160. @deftypefn stacks private push (@var{s}:in out stack; @
  161. @var{n}:in integer) ; ;barg aarg; ; end
  162. @end deftypefn
  163. @deftypevr {Global Flag} int enable @
  164. (arg in brace, [something @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) last
  165. @end deftypevr
  166. @deftp {Data type} pair car cdr @
  167. (arg in brace, [something @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) last
  168. @end deftp
  169. @defcv {Class Option} Window border-pattern @
  170. (arg in brace, [something @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) last
  171. @end defcv
  172. @deftypecv {Class Option2} Window @code{int} border-pattern @
  173. (arg in brace, [something @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) last
  174. @end deftypecv
  175. @defop Operation windows expose @
  176. (arg in brace, [something @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) last
  177. @end defop
  178. @deftypeop Operation2 W,indow @code{int} expose @
  179. (arg in brace, [something @var{in v--ar}, @b{in, b} {, comma} a@var{pref} p]) last
  180. @end deftypeop
  181. @deftypeop Operation5 Window @code{int} expose type arg
  182. @end deftypeop
  183. @deftypeop Operation3 {W,indow} @code{int} {e,xpose} type arg
  184. @end deftypeop
  185. @deftypeop Operation4 {,Window} @code{int} {,expose} type arg
  186. @end deftypeop
  187. @deftypeop Operation6 W,indow @code{int} e,xpose type arg
  188. @end deftypeop
  189. @deftypeop Operation7 ,Window @code{int} ,expose type arg
  190. @end deftypeop
  191. @deftypeop Operation13 {W)indow} @code{int} {e)xpose} type arg
  192. @end deftypeop
  193. @deftypeop Operation14 {)Window} @code{int} {)expose} type arg
  194. @end deftypeop
  195. @deftypeop Operation16 W)indow @code{int} e)xpose type arg
  196. @end deftypeop
  197. @deftypeop Operation17 )Window @code{int} )expose type arg
  198. @end deftypeop
  199. @deftypeop Operation18 {W;indow} @code{int} {e;xpose} type arg
  200. @end deftypeop
  201. @deftypeop Operation19 {;Window} @code{int} {;expose} type arg
  202. @end deftypeop
  203. @deftypeop Operation20 W;indow @code{int} e;xpose type arg
  204. @end deftypeop
  205. @deftypeop Operation21 ;Window @code{int} ;expose type arg
  206. @end deftypeop
  207. @deftypeop Command@code{com} {Window@code{int}} expose@var{exp} name
  208. @end deftypeop
  209. @defun apply function &rest arguments
  210. @end defun
  211. @deffn @var{A1} @var{A2} @var{A3} @var{A4}
  212. @end deffn
  213. @deffn @code{A1} @code{A2} @code{A3} @code{A4}
  214. @end deffn
  215. @defvr @var{A1} @var{A2} @var{A3} @var{A4}
  216. @end defvr
  217. @defvr @code{A1} @code{A2} @code{A3} @code{A4}
  218. @end defvr
  219. @deftypefn @var{A1} @var{A2} @var{A3} @var{A4} @var{A5}
  220. @end deftypefn
  221. @deftypefn @code{A1} @code{A2} @code{A3} @code{A4} @code{A5}
  222. @end deftypefn
  223. @deftypevr @var{A1} @var{A2} @var{A3} @var{A4} @var{A5}
  224. @end deftypevr
  225. @deftypevr @code{A1} @t{A2} @code{A3} @code{A4} @code{A5}
  226. @end deftypevr
  227. @deftp @var{A1} @var{A2} @var{A3} @var{A4}
  228. @end deftp
  229. @deftp @code{A1} @code{A2} @code{A3} @code{A4}
  230. @end deftp
  231. @defcv @var{A1} @var{A2} @var{A3} @var{A4} @var{A5}
  232. @end defcv
  233. @deftp @code{A1} @code{A2} @code{A3} @code{A4} @code{A5}
  234. @end deftp
  235. @deftypecv @var{A1} @var{A2} @var{A3} @var{A4} @var{A5} @var{A6}
  236. @end deftypecv
  237. @deftypecv @code{A1} @code{A2} @option{A3} @code{A4} @code{A5} @code{A6}
  238. @end deftypecv
  239. @defop @var{A1} @var{A2} @var{A3} @var{A4} @var{A5}
  240. @end defop
  241. @defop @code{A1} @code{A2} @code{A3} @code{A4} @code{A5}
  242. @end defop
  243. @deftypeop @var{A1} @var{A2} @var{A3} @var{A4} @var{A5} @var{A6}
  244. @end deftypeop
  245. @deftypeop @code{A1} @code{A2} @code{A3} @code{A4} @code{A5} @code{A6}
  246. @end deftypeop
  247. @deftypefn {code then var} {ret_type} {fun_name} @code{A1} @var{A2} @code{A3} @var{A4}
  248. @end deftypefn
  249. @deftypefn {var then code} {ret_type1} {fun_name1} @var{A1} @code{A2} @var{A3} @code{A4}
  250. @end deftypefn
  251. '],
  252. ['protected_brace',
  253. '@deffn c @{
  254. @end deffn
  255. '],
  256. ['ref_in_def',
  257. '
  258. @node Top
  259. @deffn @ref{myanchor} @ref{myanchor} {@pxref{myanchor}} @pxref{myanchor} @pxref{myanchor}
  260. @deffnx @ref{myanchor} @ref{myanchor} {@pxref{myanchor}} @pxref{myanchor} @pxref{myanchor}
  261. T
  262. @end deffn
  263. @anchor{myanchor}
  264. '],
  265. );
  266. my @test_info = (
  267. ['space_in_def_for_index',
  268. '@node Top
  269. @deffn { Category } { name } { argument } argument2...
  270. @deffnx {AAA1} {AAA2} arg3
  271. @end deffn
  272. @printindex fn
  273. '],
  274. );
  275. my @test_invalid = (
  276. ['no_category_or_no_name',
  277. '@deffn
  278. no category no name
  279. @end deffn
  280. @deffn {only category}
  281. no name
  282. @end deffn
  283. @deffn a b c d
  284. @deffnx deffnx_category
  285. @deffnx
  286. with deffnx missing category or name
  287. @end deffn
  288. '],
  289. ['def_defx_mismatch',
  290. '@defun {my def} args @var{arg} @dots{}
  291. @deffnx {type} {name} and now the args
  292. In defun.
  293. @end defun
  294. '],
  295. ['defx_after_text',
  296. '@deffn fset @var{i} a g
  297. Text in deffn
  298. @deffnx {truc} bidulr machin...
  299. @end deffn'],
  300. ['defx_after_paragraph_end',
  301. '@deffn fset @var{i} a g
  302. Text in paragraph.
  303. @deffnx {truc} bidulr machin...
  304. @end deffn'],
  305. ['defx_after_preformatted_with_text',
  306. '@example
  307. @deffn fset @var{i} a g
  308. Text in preformatted.
  309. @deffnx {truc} bidulr machin...
  310. @end deffn
  311. @end example
  312. '],
  313. ['end_of_line_protect_at_end',
  314. '
  315. @deffn category2 deffn_name2 arguments2 @'],
  316. ['end_of_line_end_file',
  317. '@deffn category deffn_name arguments @
  318. '],
  319. # the command with type is compared with the corresponding command without type
  320. ['empty_deftype',
  321. '@deftypefun {} f (const type& x)
  322. Deftypefun.
  323. @end deftypefun
  324. @defun f (const type& x)
  325. Defun.
  326. @end defun
  327. @deftypemethod c {} f (const type& x)
  328. Deftypemethod.
  329. @end deftypemethod
  330. @defmethod c f (const type& x)
  331. Defmethod.
  332. @end defmethod
  333. '],
  334. ['wrong_braces_simple',
  335. '@deffn truc machin bidule chose and }
  336. @end deffn
  337. @deffn truc machin bidule chose and } after
  338. @end deffn
  339. @deffn truc machin bidule chose and {
  340. @end deffn
  341. @deffn truc machin bidule chose and { and after
  342. @end deffn
  343. @deffn a b c d e
  344. @deffnx truc machin bidule chose and }
  345. @deffnx truc machin bidule chose and } after
  346. @deffnx truc machin bidule chose and {
  347. @deffnx truc machin bidule chose and { and after
  348. @end deffn
  349. '],
  350. ['wrong_braces_with_end_of_lines',
  351. '@deffn category name args { @
  352. more args
  353. deffn with @{
  354. @end deffn
  355. @deffn category name args } @
  356. more args
  357. deffn with @}
  358. @end deffn
  359. '],
  360. ['empty_def_arguments',
  361. '@deffn fset @var{i} a g
  362. @deffnx @b{id @samp{i} ule}
  363. @deffnx
  364. @deffnx aaa
  365. @deffnx {} {}
  366. @deffnx{}
  367. @deffnx{truc} { }
  368. @deffnx{truc}
  369. @deffnx{} {}
  370. @end deffn
  371. '],
  372. ['all_empty_def',
  373. '@deffn
  374. @end deffn
  375. @defvr
  376. @end defvr
  377. @deftypefn
  378. @end deftypefn
  379. @deftypeop
  380. @end deftypeop
  381. @deftypevr
  382. @end deftypevr
  383. @defcv
  384. @end defcv
  385. @deftypecv
  386. @end deftypecv
  387. @defop
  388. @end defop
  389. @deftp
  390. @end deftp
  391. '],
  392. ['empty_deftypeop_name',
  393. '@deftypeop Command@code{com} {Window@code{int}} expose@var{exp}
  394. @end deftypeop
  395. '],
  396. ['double_command',
  397. '@deffn func plot (a, b, c, ...) @deffnx func plot2 (a, b, c, ..., d)
  398. aaa
  399. @end deffn
  400. @deffn func aaaa args @defvr c--ategory d--efvr_name
  401. bbb
  402. @end deffn
  403. '],
  404. ['not_closed',
  405. '@deffn truc bidule machin
  406. @deffnx truc chose args
  407. @defvar type1 var bidule
  408. ']
  409. );
  410. my @test_printindex = ();
  411. my %html_tests = (
  412. );
  413. foreach my $test (@test_cases) {
  414. $test->[2]->{'test_formats'} = ['plaintext'];
  415. if ($html_tests{$test->[0]}) {
  416. push @{$test->[2]->{'test_formats'}}, 'html_text';
  417. }
  418. if ($test->[0] eq 'all_commands' or $test->[0] eq 'all_commands_delimiters') {
  419. push @test_printindex, [$test->[0] . '_printindex',
  420. '@node Top
  421. '. $test->[1] . '
  422. @heading Functions
  423. @printindex fn
  424. @heading Types
  425. @printindex tp
  426. @heading Variables
  427. @printindex vr
  428. ', {'test_formats' => ['info', 'html']}];
  429. }
  430. }
  431. foreach my $test (@test_info) {
  432. $test->[2]->{'test_formats'} = ['info', 'html'];
  433. }
  434. our ($arg_test_case, $arg_generate, $arg_debug);
  435. run_all ('def', [@test_cases, @test_info, @test_invalid, @test_printindex], $arg_test_case,
  436. $arg_generate, $arg_debug);