Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1267 lines
47 KiB

  1. ;;
  2. ;; %CopyrightBegin%
  3. ;;
  4. ;; Copyright Ericsson AB 2010. All Rights Reserved.
  5. ;;
  6. ;; The contents of this file are subject to the Erlang Public License,
  7. ;; Version 1.1, (the "License"); you may not use this file except in
  8. ;; compliance with the License. You should have received a copy of the
  9. ;; Erlang Public License along with this software. If not, it can be
  10. ;; retrieved online at http://www.erlang.org/.
  11. ;;
  12. ;; Software distributed under the License is distributed on an "AS IS"
  13. ;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  14. ;; the License for the specific language governing rights and limitations
  15. ;; under the License.
  16. ;;
  17. ;; %CopyrightEnd%
  18. ;;;
  19. ;;; Purpose: Provide Erlang code skeletons.
  20. ;;; See 'erlang-skel-file' variable.
  21. (defvar erlang-tempo-tags nil
  22. "Tempo tags for erlang mode")
  23. (defvar erlang-skel
  24. '(("If" "if" erlang-skel-if)
  25. ("Case" "case" erlang-skel-case)
  26. ("Receive" "receive" erlang-skel-receive)
  27. ("Receive After" "after" erlang-skel-receive-after)
  28. ("Receive Loop" "loop" erlang-skel-receive-loop)
  29. ("Module" "module" erlang-skel-module)
  30. ("Author" "author" erlang-skel-author)
  31. ()
  32. ("Small Header" "small-header"
  33. erlang-skel-small-header erlang-skel-header)
  34. ("Normal Header" "normal-header"
  35. erlang-skel-normal-header erlang-skel-header)
  36. ("Large Header" "large-header"
  37. erlang-skel-large-header erlang-skel-header)
  38. ()
  39. ("Small Server" "small-server"
  40. erlang-skel-small-server erlang-skel-header)
  41. ()
  42. ("Application" "application"
  43. erlang-skel-application erlang-skel-header)
  44. ("Supervisor" "supervisor"
  45. erlang-skel-supervisor erlang-skel-header)
  46. ("supervisor_bridge" "supervisor-bridge"
  47. erlang-skel-supervisor-bridge erlang-skel-header)
  48. ("gen_server" "generic-server"
  49. erlang-skel-generic-server erlang-skel-header)
  50. ("gen_event" "gen-event"
  51. erlang-skel-gen-event erlang-skel-header)
  52. ("gen_fsm" "gen-fsm"
  53. erlang-skel-gen-fsm erlang-skel-header)
  54. ("Library module" "gen-lib"
  55. erlang-skel-lib erlang-skel-header)
  56. ("Corba callback" "gen-corba-cb"
  57. erlang-skel-corba-callback erlang-skel-header)
  58. ("Small Common Test suite" "ct-test-suite-s"
  59. erlang-skel-ct-test-suite-s erlang-skel-header)
  60. ("Large Common Test suite" "ct-test-suite-l"
  61. erlang-skel-ct-test-suite-l erlang-skel-header)
  62. ("Erlang TS test suite" "ts-test-suite"
  63. erlang-skel-ts-test-suite erlang-skel-header)
  64. )
  65. "*Description of all skeleton templates.
  66. Both functions and menu entries will be created.
  67. Each entry in `erlang-skel' should be a list with three or four
  68. elements, or the empty list.
  69. The first element is the name which shows up in the menu. The second
  70. is the `tempo' identifier (The string \"erlang-\" will be added in
  71. front of it). The third is the skeleton descriptor, a variable
  72. containing `tempo' attributes as described in the function
  73. `tempo-define-template'. The optional fourth elements denotes a
  74. function which should be called when the menu is selected.
  75. Functions corresponding to every template will be created. The name
  76. of the function will be `tempo-template-erlang-X' where `X' is the
  77. tempo identifier as specified in the second argument of the elements
  78. in this list.
  79. A list with zero elements means that the a horizontal line should
  80. be placed in the menu.")
  81. ;; In XEmacs `user-mail-address' returns "x@y.z (Foo Bar)" ARGH!
  82. ;; What's wrong with that? RFC 822 says it's legal. [sverkerw]
  83. ;; This needs to use the customized value. If that's not sane, things like
  84. ;; add-log will lose anyhow. Avoid it if there _is_ a paren.
  85. (defvar erlang-skel-mail-address
  86. (if (or (not user-mail-address) (string-match "(" user-mail-address))
  87. (concat (user-login-name) "@"
  88. (or (and (boundp 'mail-host-address)
  89. mail-host-address)
  90. (system-name)))
  91. user-mail-address)
  92. "Mail address of the user.")
  93. ;; Expression templates:
  94. (defvar erlang-skel-case
  95. '((erlang-skel-skip-blank) o >
  96. "case " p " of" n> p "_ ->" n> p "ok" n> "end" p)
  97. "*The skeleton of a `case' expression.
  98. Please see the function `tempo-define-template'.")
  99. (defvar erlang-skel-if
  100. '((erlang-skel-skip-blank) o >
  101. "if" n> p " ->" n> p "ok" n> "end" p)
  102. "The skeleton of an `if' expression.
  103. Please see the function `tempo-define-template'.")
  104. (defvar erlang-skel-receive
  105. '((erlang-skel-skip-blank) o >
  106. "receive" n> p "_ ->" n> p "ok" n> "end" p)
  107. "*The skeleton of a `receive' expression.
  108. Please see the function `tempo-define-template'.")
  109. (defvar erlang-skel-receive-after
  110. '((erlang-skel-skip-blank) o >
  111. "receive" n> p "_ ->" n> p "ok" n> "after " p "T ->" n>
  112. p "ok" n> "end" p)
  113. "*The skeleton of a `receive' expression with an `after' clause.
  114. Please see the function `tempo-define-template'.")
  115. (defvar erlang-skel-receive-loop
  116. '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n>
  117. "loop(" p ")" n> "end.")
  118. "*The skeleton of a simple `receive' loop.
  119. Please see the function `tempo-define-template'.")
  120. ;; Attribute templates
  121. (defvar erlang-skel-module
  122. '(& "-module("
  123. (erlang-add-quotes-if-needed (erlang-get-module-from-file-name))
  124. ")." n)
  125. "*The skeleton of a `module' attribute.
  126. Please see the function `tempo-define-template'.")
  127. (defvar erlang-skel-author
  128. '(& "-author('" erlang-skel-mail-address "')." n)
  129. "*The skeleton of a `author' attribute.
  130. Please see the function `tempo-define-template'.")
  131. (defvar erlang-skel-vc nil
  132. "*The skeleton template to generate a version control attribute.
  133. The default is to insert nothing. Example of usage:
  134. (setq erlang-skel-vc '(& \"-rcs(\\\"$\Id: $ \\\").\") n)
  135. Please see the function `tempo-define-template'.")
  136. (defvar erlang-skel-export
  137. '(& "-export([" n> "])." n)
  138. "*The skeleton of an `export' attribute.
  139. Please see the function `tempo-define-template'.")
  140. (defvar erlang-skel-import
  141. '(& "%%-import(Module, [Function/Arity, ...])." n)
  142. "*The skeleton of an `import' attribute.
  143. Please see the function `tempo-define-template'.")
  144. (defvar erlang-skel-compile nil
  145. ;; '(& "%%-compile(export_all)." n)
  146. "*The skeleton of a `compile' attribute.
  147. Please see the function `tempo-define-template'.")
  148. ;; Comment templates.
  149. (defvar erlang-skel-date-function 'erlang-skel-dd-mmm-yyyy
  150. "*Function which returns date string.
  151. Look in the module `time-stamp' for a battery of functions.")
  152. (defvar erlang-skel-copyright-comment '()
  153. "*The template for a copyright line in the header, normally empty.
  154. This variable should be bound to a `tempo' template, for example:
  155. '(& \"%%% Copyright (C) 2000, Yoyodyne, Inc.\" n)
  156. Please see the function `tempo-define-template'.")
  157. (defvar erlang-skel-created-comment
  158. '(& "%%% Created : " (funcall erlang-skel-date-function) " by "
  159. (user-full-name) " <" erlang-skel-mail-address ">" n)
  160. "*The template for the \"Created:\" comment line.")
  161. (defvar erlang-skel-author-comment
  162. '(& "%%% Author : " (user-full-name) " <" erlang-skel-mail-address ">" n)
  163. "*The template for creating the \"Author:\" line in the header.
  164. Please see the function `tempo-define-template'.")
  165. (defvar erlang-skel-file-comment
  166. '(& "%%% File : " (file-name-nondirectory buffer-file-name) n)
  167. "*The template for creating the \"Module:\" line in the header.
  168. Please see the function `tempo-define-template'.")
  169. (defvar erlang-skel-small-header
  170. '(o (erlang-skel-include erlang-skel-module)
  171. ;; erlang-skel-author)
  172. n
  173. (erlang-skel-include erlang-skel-compile
  174. ;; erlang-skel-export
  175. erlang-skel-vc))
  176. "*The template of a small header without any comments.
  177. Please see the function `tempo-define-template'.")
  178. (defvar erlang-skel-normal-header
  179. '(o (erlang-skel-include erlang-skel-copyright-comment
  180. erlang-skel-file-comment
  181. erlang-skel-author-comment)
  182. "%%% Description : " p n
  183. (erlang-skel-include erlang-skel-created-comment) n
  184. (erlang-skel-include erlang-skel-small-header) n)
  185. "*The template of a normal header.
  186. Please see the function `tempo-define-template'.")
  187. (defvar erlang-skel-large-header
  188. '(o (erlang-skel-separator)
  189. (erlang-skel-include erlang-skel-copyright-comment
  190. erlang-skel-file-comment
  191. erlang-skel-author-comment)
  192. "%%% Description : " p n
  193. "%%%" n
  194. (erlang-skel-include erlang-skel-created-comment)
  195. (erlang-skel-separator)
  196. (erlang-skel-include erlang-skel-small-header) )
  197. "*The template of a large header.
  198. Please see the function `tempo-define-template'.")
  199. ;; Server templates.
  200. (defvar erlang-skel-small-server
  201. '((erlang-skel-include erlang-skel-large-header)
  202. "-export([start/0,init/1])." n n n
  203. "start() ->" n> "spawn(" (erlang-get-module-from-file-name)
  204. ", init, [self()])." n n
  205. "init(From) ->" n>
  206. "loop(From)." n n
  207. "loop(From) ->" n>
  208. "receive" n>
  209. p "_ ->" n>
  210. "loop(From)" n>
  211. "end."
  212. )
  213. "*Template of a small server.
  214. Please see the function `tempo-define-template'.")
  215. ;; Behaviour templates.
  216. (defvar erlang-skel-application
  217. '((erlang-skel-include erlang-skel-large-header)
  218. "-behaviour(application)." n n
  219. "%% Application callbacks" n
  220. "-export([start/2, stop/1])." n n
  221. (erlang-skel-double-separator 2)
  222. "%% Application callbacks" n
  223. (erlang-skel-double-separator 2)
  224. (erlang-skel-separator 2)
  225. "%% Function: start(Type, StartArgs) -> {ok, Pid} |" n
  226. "%% {ok, Pid, State} |" n
  227. "%% {error, Reason}" n
  228. "%% Description: This function is called whenever an application " n
  229. "%% is started using application:start/1,2, and should start the processes" n
  230. "%% of the application. If the application is structured according to the" n
  231. "%% OTP design principles as a supervision tree, this means starting the" n
  232. "%% top supervisor of the tree." n
  233. (erlang-skel-separator 2)
  234. "start(_Type, StartArgs) ->" n>
  235. "case 'TopSupervisor':start_link(StartArgs) of" n>
  236. "{ok, Pid} -> " n>
  237. "{ok, Pid};" n>
  238. "Error ->" n>
  239. "Error" n>
  240. "end." n
  241. n
  242. (erlang-skel-separator 2)
  243. "%% Function: stop(State) -> void()" n
  244. "%% Description: This function is called whenever an application" n
  245. "%% has stopped. It is intended to be the opposite of Module:start/2 and" n
  246. "%% should do any necessary cleaning up. The return value is ignored. "n
  247. (erlang-skel-separator 2)
  248. "stop(_State) ->" n>
  249. "ok." n
  250. n
  251. (erlang-skel-double-separator 2)
  252. "%% Internal functions" n
  253. (erlang-skel-double-separator 2)
  254. )
  255. "*The template of an application behaviour.
  256. Please see the function `tempo-define-template'.")
  257. (defvar erlang-skel-supervisor
  258. '((erlang-skel-include erlang-skel-large-header)
  259. "-behaviour(supervisor)." n n
  260. "%% API" n
  261. "-export([start_link/0])." n n
  262. "%% Supervisor callbacks" n
  263. "-export([init/1])." n n
  264. "-define(SERVER, ?MODULE)." n n
  265. (erlang-skel-double-separator 2)
  266. "%% API functions" n
  267. (erlang-skel-double-separator 2)
  268. (erlang-skel-separator 2)
  269. "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n
  270. "%% Description: Starts the supervisor" n
  271. (erlang-skel-separator 2)
  272. "start_link() ->" n>
  273. "supervisor:start_link({local, ?SERVER}, ?MODULE, [])." n
  274. n
  275. (erlang-skel-double-separator 2)
  276. "%% Supervisor callbacks" n
  277. (erlang-skel-double-separator 2)
  278. (erlang-skel-separator 2)
  279. "%% Func: init(Args) -> {ok, {SupFlags, [ChildSpec]}} |" n
  280. "%% ignore |" n
  281. "%% {error, Reason}" n
  282. "%% Description: Whenever a supervisor is started using "n
  283. "%% supervisor:start_link/[2,3], this function is called by the new process "n
  284. "%% to find out about restart strategy, maximum restart frequency and child "n
  285. "%% specifications." n
  286. (erlang-skel-separator 2)
  287. "init([]) ->" n>
  288. "AChild = {'AName',{'AModule',start_link,[]}," n>
  289. "permanent,2000,worker,['AModule']}," n>
  290. "{ok,{{one_for_all,0,1}, [AChild]}}." n
  291. n
  292. (erlang-skel-double-separator 2)
  293. "%% Internal functions" n
  294. (erlang-skel-double-separator 2)
  295. )
  296. "*The template of an supervisor behaviour.
  297. Please see the function `tempo-define-template'.")
  298. (defvar erlang-skel-supervisor-bridge
  299. '((erlang-skel-include erlang-skel-large-header)
  300. "-behaviour(supervisor_bridge)." n n
  301. "%% API" n
  302. "-export([start_link/0])." n n
  303. "%% supervisor_bridge callbacks" n
  304. "-export([init/1, terminate/2])." n n
  305. "-define(SERVER, ?MODULE)." n n
  306. "-record(state, {})." n n
  307. (erlang-skel-double-separator 2)
  308. "%% API" n
  309. (erlang-skel-double-separator 2)
  310. (erlang-skel-separator 2)
  311. "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n
  312. "%% Description: Starts the supervisor bridge" n
  313. (erlang-skel-separator 2)
  314. "start_link() ->" n>
  315. "supervisor_bridge:start_link({local, ?SERVER}, ?MODULE, [])." n
  316. n
  317. (erlang-skel-double-separator 2)
  318. "%% supervisor_bridge callbacks" n
  319. (erlang-skel-double-separator 2)
  320. (erlang-skel-separator 2)
  321. "%% Funcion: init(Args) -> {ok, Pid, State} |" n
  322. "%% ignore |" n
  323. "%% {error, Reason} " n
  324. "%% Description:Creates a supervisor_bridge process, linked to the calling" n
  325. "%% process, which calls Module:init/1 to start the subsystem. To ensure a" n
  326. "%% synchronized start-up procedure, this function does not return until" n
  327. "%% Module:init/1 has returned. " n
  328. (erlang-skel-separator 2)
  329. "init([]) ->" n>
  330. "case 'AModule':start_link() of" n>
  331. "{ok, Pid} ->" n>
  332. "{ok, Pid, #state{}};" n>
  333. "Error ->" n>
  334. "Error" n>
  335. "end." n
  336. n
  337. (erlang-skel-separator 2)
  338. "%% Func: terminate(Reason, State) -> void()" n
  339. "%% Description:This function is called by the supervisor_bridge when it is"n
  340. "%% about to terminate. It should be the opposite of Module:init/1 and stop"n
  341. "%% the subsystem and do any necessary cleaning up.The return value is ignored."
  342. (erlang-skel-separator 2)
  343. "terminate(Reason, State) ->" n>
  344. "'AModule':stop()," n>
  345. "ok." n
  346. n
  347. (erlang-skel-double-separator 2)
  348. "%% Internal functions" n
  349. (erlang-skel-double-separator 2)
  350. )
  351. "*The template of an supervisor_bridge behaviour.
  352. Please see the function `tempo-define-template'.")
  353. (defvar erlang-skel-generic-server
  354. '((erlang-skel-include erlang-skel-large-header)
  355. "-behaviour(gen_server)." n n
  356. "%% API" n
  357. "-export([start_link/0])." n n
  358. "%% gen_server callbacks" n
  359. "-export([init/1, handle_call/3, handle_cast/2, "
  360. "handle_info/2," n>
  361. "terminate/2, code_change/3])." n n
  362. "-record(state, {})." n n
  363. (erlang-skel-double-separator 2)
  364. "%% API" n
  365. (erlang-skel-double-separator 2)
  366. (erlang-skel-separator 2)
  367. "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n
  368. "%% Description: Starts the server" n
  369. (erlang-skel-separator 2)
  370. "start_link() ->" n>
  371. "gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n
  372. n
  373. (erlang-skel-double-separator 2)
  374. "%% gen_server callbacks" n
  375. (erlang-skel-double-separator 2)
  376. n
  377. (erlang-skel-separator 2)
  378. "%% Function: init(Args) -> {ok, State} |" n
  379. "%% {ok, State, Timeout} |" n
  380. "%% ignore |" n
  381. "%% {stop, Reason}" n
  382. "%% Description: Initializes the server" n
  383. (erlang-skel-separator 2)
  384. "init([]) ->" n>
  385. "{ok, #state{}}." n
  386. n
  387. (erlang-skel-separator 2)
  388. "%% Function: "
  389. "%% handle_call(Request, From, State) -> {reply, Reply, State} |" n
  390. "%% {reply, Reply, State, Timeout} |" n
  391. "%% {noreply, State} |" n
  392. "%% {noreply, State, Timeout} |" n
  393. "%% {stop, Reason, Reply, State} |" n
  394. "%% {stop, Reason, State}" n
  395. "%% Description: Handling call messages" n
  396. (erlang-skel-separator 2)
  397. "handle_call(_Request, _From, State) ->" n>
  398. "Reply = ok," n>
  399. "{reply, Reply, State}." n
  400. n
  401. (erlang-skel-separator 2)
  402. "%% Function: handle_cast(Msg, State) -> {noreply, State} |" n
  403. "%% {noreply, State, Timeout} |" n
  404. "%% {stop, Reason, State}" n
  405. "%% Description: Handling cast messages" n
  406. (erlang-skel-separator 2)
  407. "handle_cast(_Msg, State) ->" n>
  408. "{noreply, State}." n
  409. n
  410. (erlang-skel-separator 2)
  411. "%% Function: handle_info(Info, State) -> {noreply, State} |" n
  412. "%% {noreply, State, Timeout} |" n
  413. "%% {stop, Reason, State}" n
  414. "%% Description: Handling all non call/cast messages" n
  415. (erlang-skel-separator 2)
  416. "handle_info(_Info, State) ->" n>
  417. "{noreply, State}." n
  418. n
  419. (erlang-skel-separator 2)
  420. "%% Function: terminate(Reason, State) -> void()" n
  421. "%% Description: This function is called by a gen_server when it is about to"n
  422. "%% terminate. It should be the opposite of Module:init/1 and do any necessary"n
  423. "%% cleaning up. When it returns, the gen_server terminates with Reason." n
  424. "%% The return value is ignored." n
  425. (erlang-skel-separator 2)
  426. "terminate(_Reason, _State) ->" n>
  427. "ok." n
  428. n
  429. (erlang-skel-separator 2)
  430. "%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}" n
  431. "%% Description: Convert process state when code is changed" n
  432. (erlang-skel-separator 2)
  433. "code_change(_OldVsn, State, _Extra) ->" n>
  434. "{ok, State}." n
  435. n
  436. (erlang-skel-separator 2)
  437. "%%% Internal functions" n
  438. (erlang-skel-separator 2)
  439. )
  440. "*The template of a generic server.
  441. Please see the function `tempo-define-template'.")
  442. (defvar erlang-skel-gen-event
  443. '((erlang-skel-include erlang-skel-large-header)
  444. "-behaviour(gen_event)." n
  445. "%% API" n
  446. "-export([start_link/0, add_handler/0])." n n
  447. "%% gen_event callbacks" n
  448. "-export([init/1, handle_event/2, handle_call/2, " n>
  449. "handle_info/2, terminate/2, code_change/3])." n n
  450. "-record(state, {})." n n
  451. (erlang-skel-double-separator 2)
  452. "%% gen_event callbacks" n
  453. (erlang-skel-double-separator 2)
  454. (erlang-skel-separator 2)
  455. "%% Function: start_link() -> {ok,Pid} | {error,Error} " n
  456. "%% Description: Creates an event manager." n
  457. (erlang-skel-separator 2)
  458. "start_link() ->" n>
  459. "gen_event:start_link({local, ?SERVER}). " n
  460. n
  461. (erlang-skel-separator 2)
  462. "%% Function: add_handler() -> ok | {'EXIT',Reason} | term()" n
  463. "%% Description: Adds an event handler" n
  464. (erlang-skel-separator 2)
  465. "add_handler() ->" n>
  466. "gen_event:add_handler(?SERVER, ?MODULE, [])." n
  467. n
  468. (erlang-skel-double-separator 2)
  469. "%% gen_event callbacks" n
  470. (erlang-skel-double-separator 2)
  471. (erlang-skel-separator 2)
  472. "%% Function: init(Args) -> {ok, State}" n
  473. "%% Description: Whenever a new event handler is added to an event manager,"n
  474. "%% this function is called to initialize the event handler." n
  475. (erlang-skel-separator 2)
  476. "init([]) ->" n>
  477. "{ok, #state{}}." n
  478. n
  479. (erlang-skel-separator 2)
  480. "%% Function: "n
  481. "%% handle_event(Event, State) -> {ok, State} |" n
  482. "%% {swap_handler, Args1, State1, Mod2, Args2} |"n
  483. "%% remove_handler" n
  484. "%% Description:Whenever an event manager receives an event sent using"n
  485. "%% gen_event:notify/2 or gen_event:sync_notify/2, this function is called for"n
  486. "%% each installed event handler to handle the event. "n
  487. (erlang-skel-separator 2)
  488. "handle_event(_Event, State) ->" n>
  489. "{ok, State}." n
  490. n
  491. (erlang-skel-separator 2)
  492. "%% Function: " n
  493. "%% handle_call(Request, State) -> {ok, Reply, State} |" n
  494. "%% {swap_handler, Reply, Args1, State1, "n
  495. "%% Mod2, Args2} |" n
  496. "%% {remove_handler, Reply}" n
  497. "%% Description: Whenever an event manager receives a request sent using"n
  498. "%% gen_event:call/3,4, this function is called for the specified event "n
  499. "%% handler to handle the request."n
  500. (erlang-skel-separator 2)
  501. "handle_call(_Request, State) ->" n>
  502. "Reply = ok," n>
  503. "{ok, Reply, State}." n
  504. n
  505. (erlang-skel-separator 2)
  506. "%% Function: " n
  507. "%% handle_info(Info, State) -> {ok, State} |" n
  508. "%% {swap_handler, Args1, State1, Mod2, Args2} |" n
  509. "%% remove_handler" n
  510. "%% Description: This function is called for each installed event handler when"n
  511. "%% an event manager receives any other message than an event or a synchronous"n
  512. "%% request (or a system message)."n
  513. (erlang-skel-separator 2)
  514. "handle_info(_Info, State) ->" n>
  515. "{ok, State}." n
  516. n
  517. (erlang-skel-separator 2)
  518. "%% Function: terminate(Reason, State) -> void()" n
  519. "%% Description:Whenever an event handler is deleted from an event manager,"n
  520. "%% this function is called. It should be the opposite of Module:init/1 and "n
  521. "%% do any necessary cleaning up. " n
  522. (erlang-skel-separator 2)
  523. "terminate(_Reason, _State) ->" n>
  524. "ok." n
  525. n
  526. (erlang-skel-separator 2)
  527. "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n
  528. "%% Description: Convert process state when code is changed" n
  529. (erlang-skel-separator 2)
  530. "code_change(_OldVsn, State, _Extra) ->" n>
  531. "{ok, State}." n
  532. n
  533. (erlang-skel-separator 2)
  534. "%%% Internal functions" n
  535. (erlang-skel-separator 2)
  536. )
  537. "*The template of a gen_event.
  538. Please see the function `tempo-define-template'.")
  539. (defvar erlang-skel-gen-fsm
  540. '((erlang-skel-include erlang-skel-large-header)
  541. "-behaviour(gen_fsm)." n n
  542. "%% API" n
  543. "-export([start_link/0])." n n
  544. "%% gen_fsm callbacks" n
  545. "-export([init/1, state_name/2, state_name/3, handle_event/3," n>
  546. "handle_sync_event/4, handle_info/3, terminate/3, code_change/4])." n n
  547. "-record(state, {})." n n
  548. (erlang-skel-double-separator 2)
  549. "%% API" n
  550. (erlang-skel-double-separator 2)
  551. (erlang-skel-separator 2)
  552. "%% Function: start_link() -> ok,Pid} | ignore | {error,Error}" n
  553. "%% Description:Creates a gen_fsm process which calls Module:init/1 to"n
  554. "%% initialize. To ensure a synchronized start-up procedure, this function" n
  555. "%% does not return until Module:init/1 has returned. " n
  556. (erlang-skel-separator 2)
  557. "start_link() ->" n>
  558. "gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], [])." n
  559. n
  560. (erlang-skel-double-separator 2)
  561. "%% gen_fsm callbacks" n
  562. (erlang-skel-double-separator 2)
  563. (erlang-skel-separator 2)
  564. "%% Function: init(Args) -> {ok, StateName, State} |" n
  565. "%% {ok, StateName, State, Timeout} |" n
  566. "%% ignore |" n
  567. "%% {stop, StopReason} " n
  568. "%% Description:Whenever a gen_fsm is started using gen_fsm:start/[3,4] or"n
  569. "%% gen_fsm:start_link/3,4, this function is called by the new process to "n
  570. "%% initialize. " n
  571. (erlang-skel-separator 2)
  572. "init([]) ->" n>
  573. "{ok, state_name, #state{}}." n
  574. n
  575. (erlang-skel-separator 2)
  576. "%% Function: "n
  577. "%% state_name(Event, State) -> {next_state, NextStateName, NextState}|" n
  578. "%% {next_state, NextStateName, " n
  579. "%% NextState, Timeout} |" n
  580. "%% {stop, Reason, NewState}" n
  581. "%% Description:There should be one instance of this function for each possible"n
  582. "%% state name. Whenever a gen_fsm receives an event sent using" n
  583. "%% gen_fsm:send_event/2, the instance of this function with the same name as"n
  584. "%% the current state name StateName is called to handle the event. It is also "n
  585. "%% called if a timeout occurs. " n
  586. (erlang-skel-separator 2)
  587. "state_name(_Event, State) ->" n>
  588. "{next_state, state_name, State}." n
  589. n
  590. (erlang-skel-separator 2)
  591. "%% Function:" n
  592. "%% state_name(Event, From, State) -> {next_state, NextStateName, NextState} |"n
  593. "%% {next_state, NextStateName, " n
  594. "%% NextState, Timeout} |" n
  595. "%% {reply, Reply, NextStateName, NextState}|"n
  596. "%% {reply, Reply, NextStateName, " n
  597. "%% NextState, Timeout} |" n
  598. "%% {stop, Reason, NewState}|" n
  599. "%% {stop, Reason, Reply, NewState}" n
  600. "%% Description: There should be one instance of this function for each" n
  601. "%% possible state name. Whenever a gen_fsm receives an event sent using" n
  602. "%% gen_fsm:sync_send_event/2,3, the instance of this function with the same"n
  603. "%% name as the current state name StateName is called to handle the event." n
  604. (erlang-skel-separator 2)
  605. "state_name(_Event, _From, State) ->" n>
  606. "Reply = ok," n>
  607. "{reply, Reply, state_name, State}." n
  608. n
  609. (erlang-skel-separator 2)
  610. "%% Function: " n
  611. "%% handle_event(Event, StateName, State) -> {next_state, NextStateName, "n
  612. "%% NextState} |" n
  613. "%% {next_state, NextStateName, "n
  614. "%% NextState, Timeout} |" n
  615. "%% {stop, Reason, NewState}" n
  616. "%% Description: Whenever a gen_fsm receives an event sent using"n
  617. "%% gen_fsm:send_all_state_event/2, this function is called to handle"n
  618. "%% the event." n
  619. (erlang-skel-separator 2)
  620. "handle_event(_Event, StateName, State) ->" n>
  621. "{next_state, StateName, State}." n
  622. n
  623. (erlang-skel-separator 2)
  624. "%% Function: " n
  625. "%% handle_sync_event(Event, From, StateName, "n
  626. "%% State) -> {next_state, NextStateName, NextState} |" n
  627. "%% {next_state, NextStateName, NextState, " n
  628. "%% Timeout} |" n
  629. "%% {reply, Reply, NextStateName, NextState}|" n
  630. "%% {reply, Reply, NextStateName, NextState, " n
  631. "%% Timeout} |" n
  632. "%% {stop, Reason, NewState} |" n
  633. "%% {stop, Reason, Reply, NewState}" n
  634. "%% Description: Whenever a gen_fsm receives an event sent using"n
  635. "%% gen_fsm:sync_send_all_state_event/2,3, this function is called to handle"n
  636. "%% the event."n
  637. (erlang-skel-separator 2)
  638. "handle_sync_event(Event, From, StateName, State) ->" n>
  639. "Reply = ok," n>
  640. "{reply, Reply, StateName, State}." n
  641. n
  642. (erlang-skel-separator 2)
  643. "%% Function: " n
  644. "%% handle_info(Info,StateName,State)-> {next_state, NextStateName, NextState}|" n
  645. "%% {next_state, NextStateName, NextState, "n
  646. "%% Timeout} |" n
  647. "%% {stop, Reason, NewState}" n
  648. "%% Description: This function is called by a gen_fsm when it receives any"n
  649. "%% other message than a synchronous or asynchronous event"n
  650. "%% (or a system message)." n
  651. (erlang-skel-separator 2)
  652. "handle_info(_Info, StateName, State) ->" n>
  653. "{next_state, StateName, State}." n
  654. n
  655. (erlang-skel-separator 2)
  656. "%% Function: terminate(Reason, StateName, State) -> void()" n
  657. "%% Description:This function is called by a gen_fsm when it is about"n
  658. "%% to terminate. It should be the opposite of Module:init/1 and do any"n
  659. "%% necessary cleaning up. When it returns, the gen_fsm terminates with"n
  660. "%% Reason. The return value is ignored." n
  661. (erlang-skel-separator 2)
  662. "terminate(_Reason, _StateName, _State) ->" n>
  663. "ok." n
  664. n
  665. (erlang-skel-separator 2)
  666. "%% Function:" n
  667. "%% code_change(OldVsn, StateName, State, Extra) -> {ok, StateName, NewState}" n
  668. "%% Description: Convert process state when code is changed" n
  669. (erlang-skel-separator 2)
  670. "code_change(_OldVsn, StateName, State, _Extra) ->" n>
  671. "{ok, StateName, State}." n
  672. n
  673. (erlang-skel-separator 2)
  674. "%%% Internal functions" n
  675. (erlang-skel-separator 2)
  676. )
  677. "*The template of a gen_fsm.
  678. Please see the function `tempo-define-template'.")
  679. (defvar erlang-skel-lib
  680. '((erlang-skel-include erlang-skel-large-header)
  681. "%% API" n
  682. "-export([])." n n
  683. (erlang-skel-double-separator 2)
  684. "%% API" n
  685. (erlang-skel-double-separator 2)
  686. (erlang-skel-separator 2)
  687. "%% Function: " n
  688. "%% Description:" n
  689. (erlang-skel-separator 2)
  690. n
  691. (erlang-skel-double-separator 2)
  692. "%% Internal functions" n
  693. (erlang-skel-double-separator 2)
  694. )
  695. "*The template of a library module.
  696. Please see the function `tempo-define-template'.")
  697. (defvar erlang-skel-corba-callback
  698. '((erlang-skel-include erlang-skel-large-header)
  699. "%% Include files" n n
  700. "%% API" n
  701. "-export([])." n n
  702. "%% Corba callbacks" n
  703. "-export([init/1, terminate/2, code_change/3])." n n
  704. "-record(state, {})." n n
  705. (erlang-skel-double-separator 2)
  706. "%% Corba callbacks" n
  707. (erlang-skel-double-separator 2)
  708. (erlang-skel-separator 2)
  709. "%% Function: init(Args) -> {ok, State} |" n
  710. "%% {ok, State, Timeout} |" n
  711. "%% ignore |" n
  712. "%% {stop, Reason}" n
  713. "%% Description: Initializes the server" n
  714. (erlang-skel-separator 2)
  715. "init([]) ->" n>
  716. "{ok, #state{}}." n
  717. n
  718. (erlang-skel-separator 2)
  719. "%% Function: terminate(Reason, State) -> void()" n
  720. "%% Description: Shutdown the server" n
  721. (erlang-skel-separator 2)
  722. "terminate(_Reason, _State) ->" n>
  723. "ok." n
  724. n
  725. (erlang-skel-separator 2)
  726. "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n
  727. "%% Description: Convert process state when code is changed" n
  728. (erlang-skel-separator 2)
  729. "code_change(_OldVsn, State, _Extra) ->" n>
  730. "{ok, State}." n
  731. n
  732. (erlang-skel-double-separator 2)
  733. "%% Internal functions" n
  734. (erlang-skel-double-separator 2)
  735. )
  736. "*The template of a library module.
  737. Please see the function `tempo-define-template'.")
  738. (defvar erlang-skel-ts-test-suite
  739. '((erlang-skel-include erlang-skel-large-header)
  740. "%% Note: This directive should only be used in test suites." n
  741. "-compile(export_all)." n n
  742. "-include_lib(\"test_server/include/test_server.hrl\")." n n
  743. (erlang-skel-separator 2)
  744. "%% TEST SERVER CALLBACK FUNCTIONS" n
  745. (erlang-skel-separator 2)
  746. n
  747. (erlang-skel-separator 2)
  748. "%% Function: init_per_suite(Config0) -> Config1 | {skip,Reason}" n
  749. "%%" n
  750. "%% Config0 = Config1 = [tuple()]" n
  751. "%% A list of key/value pairs, holding the test case configuration." n
  752. "%% Reason = term()" n
  753. "%% The reason for skipping the suite." n
  754. "%%" n
  755. "%% Description: Initialization before the suite." n
  756. "%%" n
  757. "%% Note: This function is free to add any key/value pairs to the Config" n
  758. "%% variable, but should NOT alter/remove any existing entries." n
  759. (erlang-skel-separator 2)
  760. "init_per_suite(Config) ->" n >
  761. "Config." n n
  762. (erlang-skel-separator 2)
  763. "%% Function: end_per_suite(Config) -> void()" n
  764. "%%" n
  765. "%% Config = [tuple()]" n
  766. "%% A list of key/value pairs, holding the test case configuration." n
  767. "%%" n
  768. "%% Description: Cleanup after the suite." n
  769. (erlang-skel-separator 2)
  770. "end_per_suite(_Config) ->" n >
  771. "ok." n n
  772. (erlang-skel-separator 2)
  773. "%% Function: init_per_testcase(TestCase, Config0) -> Config1 |" n
  774. "%% {skip,Reason}" n
  775. "%% TestCase = atom()" n
  776. "%% Name of the test case that is about to run." n
  777. "%% Config0 = Config1 = [tuple()]" n
  778. "%% A list of key/value pairs, holding the test case configuration." n
  779. "%% Reason = term()" n
  780. "%% The reason for skipping the test case." n
  781. "%%" n
  782. "%% Description: Initialization before each test case." n
  783. "%%" n
  784. "%% Note: This function is free to add any key/value pairs to the Config" n
  785. "%% variable, but should NOT alter/remove any existing entries." n
  786. (erlang-skel-separator 2)
  787. "init_per_testcase(_TestCase, Config) ->" n >
  788. "Config." n n
  789. (erlang-skel-separator 2)
  790. "%% Function: end_per_testcase(TestCase, Config) -> void()" n
  791. "%%" n
  792. "%% TestCase = atom()" n
  793. "%% Name of the test case that is finished." n
  794. "%% Config = [tuple()]" n
  795. "%% A list of key/value pairs, holding the test case configuration." n
  796. "%%" n
  797. "%% Description: Cleanup after each test case." n
  798. (erlang-skel-separator 2)
  799. "end_per_testcase(_TestCase, _Config) ->" n >
  800. "ok."n n
  801. (erlang-skel-separator 2)
  802. "%% Function: all(Clause) -> Descr | Spec | {skip,Reason}" n
  803. "%%" n
  804. "%% Clause = doc | suite" n
  805. "%% Indicates expected return value." n
  806. "%% Descr = [string()] | []" n
  807. "%% String that describes the test suite." n
  808. "%% Spec = [TestCase]" n
  809. "%% A test specification." n
  810. "%% TestCase = ConfCase | atom()" n
  811. "%% Configuration case, or the name of a test case function." n
  812. "%% ConfCase = {conf,Init,Spec,End} |" n
  813. "%% {conf,Properties,Init,Spec,End}" n
  814. "%% Init = End = {Mod,Func} | Func" n
  815. "%% Initialization and cleanup function." n
  816. "%% Mod = Func = atom()" n
  817. "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n
  818. "%% Execution properties of the test cases (may be combined)." n
  819. "%% Shuffle = shuffle | {shuffle,Seed}" n
  820. "%% To get cases executed in random order." n
  821. "%% Seed = {integer(),integer(),integer()}" n
  822. "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n
  823. "%% repeat_until_any_ok | repeat_until_any_fail" n
  824. "%% To get execution of cases repeated." n
  825. "%% N = integer() | forever" n
  826. "%% Reason = term()" n
  827. "%% The reason for skipping the test suite." n
  828. "%%" n
  829. "%% Description: Returns a description of the test suite when" n
  830. "%% Clause == doc, and a test specification (list" n
  831. "%% of the conf and test cases in the suite) when" n
  832. "%% Clause == suite." n
  833. (erlang-skel-separator 2)
  834. "all(doc) -> " n >
  835. "[\"Describe the main purpose of this suite\"];" n n
  836. "all(suite) -> " n >
  837. "[a_test_case]." n n
  838. n
  839. (erlang-skel-separator 2)
  840. "%% TEST CASES" n
  841. (erlang-skel-separator 2)
  842. n
  843. (erlang-skel-separator 2)
  844. "%% Function: TestCase(Arg) -> Descr | Spec | ok | exit() | {skip,Reason}" n
  845. "%%" n
  846. "%% Arg = doc | suite | Config" n
  847. "%% Indicates expected behaviour and return value." n
  848. "%% Config = [tuple()]" n
  849. "%% A list of key/value pairs, holding the test case configuration." n
  850. "%% Descr = [string()] | []" n
  851. "%% String that describes the test case." n
  852. "%% Spec = [tuple()] | []" n
  853. "%% A test specification, see all/1." n
  854. "%% Reason = term()" n
  855. "%% The reason for skipping the test case." n
  856. "%%" n
  857. "%% Description: Test case function. Returns a description of the test" n
  858. "%% case (doc), then returns a test specification (suite)," n
  859. "%% or performs the actual test (Config)." n
  860. (erlang-skel-separator 2)
  861. "a_test_case(doc) -> " n >
  862. "[\"Describe the main purpose of this test case\"];" n n
  863. "a_test_case(suite) -> " n >
  864. "[];" n n
  865. "a_test_case(Config) when is_list(Config) -> " n >
  866. "ok." n
  867. )
  868. "*The template of a library module.
  869. Please see the function `tempo-define-template'.")
  870. (defvar erlang-skel-ct-test-suite-l
  871. '((erlang-skel-include erlang-skel-large-header)
  872. "%% Note: This directive should only be used in test suites." n
  873. "-compile(export_all)." n n
  874. "-include_lib(\"common_test/include/ct.hrl\")." n n
  875. (erlang-skel-separator 2)
  876. "%% COMMON TEST CALLBACK FUNCTIONS" n
  877. (erlang-skel-separator 2)
  878. n
  879. (erlang-skel-separator 2)
  880. "%% Function: suite() -> Info" n
  881. "%%" n
  882. "%% Info = [tuple()]" n
  883. "%% List of key/value pairs." n
  884. "%%" n
  885. "%% Description: Returns list of tuples to set default properties" n
  886. "%% for the suite." n
  887. "%%" n
  888. "%% Note: The suite/0 function is only meant to be used to return" n
  889. "%% default data values, not perform any other operations." n
  890. (erlang-skel-separator 2)
  891. "suite() ->" n >
  892. "[{timetrap,{minutes,10}}]." n n
  893. (erlang-skel-separator 2)
  894. "%% Function: init_per_suite(Config0) ->" n
  895. "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
  896. "%%" n
  897. "%% Config0 = Config1 = [tuple()]" n
  898. "%% A list of key/value pairs, holding the test case configuration." n
  899. "%% Reason = term()" n
  900. "%% The reason for skipping the suite." n
  901. "%%" n
  902. "%% Description: Initialization before the suite." n
  903. "%%" n
  904. "%% Note: This function is free to add any key/value pairs to the Config" n
  905. "%% variable, but should NOT alter/remove any existing entries." n
  906. (erlang-skel-separator 2)
  907. "init_per_suite(Config) ->" n >
  908. "Config." n n
  909. (erlang-skel-separator 2)
  910. "%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}" n
  911. "%%" n
  912. "%% Config0 = Config1 = [tuple()]" n
  913. "%% A list of key/value pairs, holding the test case configuration." n
  914. "%%" n
  915. "%% Description: Cleanup after the suite." n
  916. (erlang-skel-separator 2)
  917. "end_per_suite(_Config) ->" n >
  918. "ok." n n
  919. (erlang-skel-separator 2)
  920. "%% Function: init_per_group(GroupName, Config0) ->" n
  921. "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
  922. "%%" n
  923. "%% GroupName = atom()" n
  924. "%% Name of the test case group that is about to run." n
  925. "%% Config0 = Config1 = [tuple()]" n
  926. "%% A list of key/value pairs, holding configuration data for the group." n
  927. "%% Reason = term()" n
  928. "%% The reason for skipping all test cases and subgroups in the group." n
  929. "%%" n
  930. "%% Description: Initialization before each test case group." n
  931. (erlang-skel-separator 2)
  932. "init_per_group(_GroupName, Config) ->" n >
  933. "Config." n n
  934. (erlang-skel-separator 2)
  935. "%% Function: end_per_group(GroupName, Config0) ->" n
  936. "%% void() | {save_config,Config1}" n
  937. "%%" n
  938. "%% GroupName = atom()" n
  939. "%% Name of the test case group that is finished." n
  940. "%% Config0 = Config1 = [tuple()]" n
  941. "%% A list of key/value pairs, holding configuration data for the group." n
  942. "%%" n
  943. "%% Description: Cleanup after each test case group." n
  944. (erlang-skel-separator 2)
  945. "end_per_group(_GroupName, _Config) ->" n >
  946. "ok." n n
  947. (erlang-skel-separator 2)
  948. "%% Function: init_per_testcase(TestCase, Config0) ->" n
  949. "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
  950. "%%" n
  951. "%% TestCase = atom()" n
  952. "%% Name of the test case that is about to run." n
  953. "%% Config0 = Config1 = [tuple()]" n
  954. "%% A list of key/value pairs, holding the test case configuration." n
  955. "%% Reason = term()" n
  956. "%% The reason for skipping the test case." n
  957. "%%" n
  958. "%% Description: Initialization before each test case." n
  959. "%%" n
  960. "%% Note: This function is free to add any key/value pairs to the Config" n
  961. "%% variable, but should NOT alter/remove any existing entries." n
  962. (erlang-skel-separator 2)
  963. "init_per_testcase(_TestCase, Config) ->" n >
  964. "Config." n n
  965. (erlang-skel-separator 2)
  966. "%% Function: end_per_testcase(TestCase, Config0) ->" n
  967. "%% void() | {save_config,Config1} | {fail,Reason}" n
  968. "%%" n
  969. "%% TestCase = atom()" n
  970. "%% Name of the test case that is finished." n
  971. "%% Config0 = Config1 = [tuple()]" n
  972. "%% A list of key/value pairs, holding the test case configuration." n
  973. "%% Reason = term()" n
  974. "%% The reason for failing the test case." n
  975. "%%" n
  976. "%% Description: Cleanup after each test case." n
  977. (erlang-skel-separator 2)
  978. "end_per_testcase(_TestCase, _Config) ->" n >
  979. "ok." n n
  980. (erlang-skel-separator 2)
  981. "%% Function: groups() -> [Group]" n
  982. "%%" n
  983. "%% Group = {GroupName,Properties,GroupsAndTestCases}" n
  984. "%% GroupName = atom()" n
  985. "%% The name of the group." n
  986. "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n
  987. "%% Group properties that may be combined." n
  988. "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n
  989. "%% TestCase = atom()" n
  990. "%% The name of a test case." n
  991. "%% Shuffle = shuffle | {shuffle,Seed}" n
  992. "%% To get cases executed in random order." n
  993. "%% Seed = {integer(),integer(),integer()}" n
  994. "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n
  995. "%% repeat_until_any_ok | repeat_until_any_fail" n
  996. "%% To get execution of cases repeated." n
  997. "%% N = integer() | forever" n
  998. "%%" n
  999. "%% Description: Returns a list of test case group definitions." n
  1000. (erlang-skel-separator 2)
  1001. "groups() ->" n >
  1002. "[]." n n
  1003. (erlang-skel-separator 2)
  1004. "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n
  1005. "%%" n
  1006. "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n
  1007. "%% GroupName = atom()" n
  1008. "%% Name of a test case group." n
  1009. "%% TestCase = atom()" n
  1010. "%% Name of a test case." n
  1011. "%% Reason = term()" n
  1012. "%% The reason for skipping all groups and test cases." n
  1013. "%%" n
  1014. "%% Description: Returns the list of groups and test cases that" n
  1015. "%% are to be executed." n
  1016. (erlang-skel-separator 2)
  1017. "all() -> " n >
  1018. "[my_test_case]." n n
  1019. n
  1020. (erlang-skel-separator 2)
  1021. "%% TEST CASES" n
  1022. (erlang-skel-separator 2)
  1023. n
  1024. (erlang-skel-separator 2)
  1025. "%% Function: TestCase() -> Info" n
  1026. "%%" n
  1027. "%% Info = [tuple()]" n
  1028. "%% List of key/value pairs." n
  1029. "%%" n
  1030. "%% Description: Test case info function - returns list of tuples to set" n
  1031. "%% properties for the test case." n
  1032. "%%" n
  1033. "%% Note: This function is only meant to be used to return a list of" n
  1034. "%% values, not perform any other operations." n
  1035. (erlang-skel-separator 2)
  1036. "my_test_case() -> " n >
  1037. "[]." n n
  1038. (erlang-skel-separator 2)
  1039. "%% Function: TestCase(Config0) ->" n
  1040. "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n
  1041. "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n
  1042. "%%" n
  1043. "%% Config0 = Config1 = [tuple()]" n
  1044. "%% A list of key/value pairs, holding the test case configuration." n
  1045. "%% Reason = term()" n
  1046. "%% The reason for skipping the test case." n
  1047. "%% Comment = term()" n
  1048. "%% A comment about the test case that will be printed in the html log." n
  1049. "%%" n
  1050. "%% Description: Test case function. (The name of it must be specified in" n
  1051. "%% the all/0 list or in a test case group for the test case" n
  1052. "%% to be executed)." n
  1053. (erlang-skel-separator 2)
  1054. "my_test_case(_Config) -> " n >
  1055. "ok." n
  1056. )
  1057. "*The template of a library module.
  1058. Please see the function `tempo-define-template'.")
  1059. (defvar erlang-skel-ct-test-suite-s
  1060. '((erlang-skel-include erlang-skel-large-header)
  1061. "-compile(export_all)." n n
  1062. "-include_lib(\"common_test/include/ct.hrl\")." n n
  1063. (erlang-skel-separator 2)
  1064. "%% Function: suite() -> Info" n
  1065. "%% Info = [tuple()]" n
  1066. (erlang-skel-separator 2)
  1067. "suite() ->" n >
  1068. "[{timetrap,{seconds,30}}]." n n
  1069. (erlang-skel-separator 2)
  1070. "%% Function: init_per_suite(Config0) ->" n
  1071. "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
  1072. "%% Config0 = Config1 = [tuple()]" n
  1073. "%% Reason = term()" n
  1074. (erlang-skel-separator 2)
  1075. "init_per_suite(Config) ->" n >
  1076. "Config." n n
  1077. (erlang-skel-separator 2)
  1078. "%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}" n
  1079. "%% Config0 = Config1 = [tuple()]" n
  1080. (erlang-skel-separator 2)
  1081. "end_per_suite(_Config) ->" n >
  1082. "ok." n n
  1083. (erlang-skel-separator 2)
  1084. "%% Function: init_per_group(GroupName, Config0) ->" n
  1085. "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
  1086. "%% GroupName = atom()" n
  1087. "%% Config0 = Config1 = [tuple()]" n
  1088. "%% Reason = term()" n
  1089. (erlang-skel-separator 2)
  1090. "init_per_group(_GroupName, Config) ->" n >
  1091. "Config." n n
  1092. (erlang-skel-separator 2)
  1093. "%% Function: end_per_group(GroupName, Config0) ->" n
  1094. "%% void() | {save_config,Config1}" n
  1095. "%% GroupName = atom()" n
  1096. "%% Config0 = Config1 = [tuple()]" n
  1097. (erlang-skel-separator 2)
  1098. "end_per_group(_GroupName, _Config) ->" n >
  1099. "ok." n n
  1100. (erlang-skel-separator 2)
  1101. "%% Function: init_per_testcase(TestCase, Config0) ->" n
  1102. "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
  1103. "%% TestCase = atom()" n
  1104. "%% Config0 = Config1 = [tuple()]" n
  1105. "%% Reason = term()" n
  1106. (erlang-skel-separator 2)
  1107. "init_per_testcase(_TestCase, Config) ->" n >
  1108. "Config." n n
  1109. (erlang-skel-separator 2)
  1110. "%% Function: end_per_testcase(TestCase, Config0) ->" n
  1111. "%% void() | {save_config,Config1} | {fail,Reason}" n
  1112. "%% TestCase = atom()" n
  1113. "%% Config0 = Config1 = [tuple()]" n
  1114. "%% Reason = term()" n
  1115. (erlang-skel-separator 2)
  1116. "end_per_testcase(_TestCase, _Config) ->" n >
  1117. "ok." n n
  1118. (erlang-skel-separator 2)
  1119. "%% Function: groups() -> [Group]" n
  1120. "%% Group = {GroupName,Properties,GroupsAndTestCases}" n
  1121. "%% GroupName = atom()" n
  1122. "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n
  1123. "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n
  1124. "%% TestCase = atom()" n
  1125. "%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}" n
  1126. "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n
  1127. "%% repeat_until_any_ok | repeat_until_any_fail" n
  1128. "%% N = integer() | forever" n
  1129. (erlang-skel-separator 2)
  1130. "groups() ->" n >
  1131. "[]." n n
  1132. (erlang-skel-separator 2)
  1133. "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n
  1134. "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n
  1135. "%% GroupName = atom()" n
  1136. "%% TestCase = atom()" n
  1137. "%% Reason = term()" n
  1138. (erlang-skel-separator 2)
  1139. "all() -> " n >
  1140. "[my_test_case]." n n
  1141. (erlang-skel-separator 2)
  1142. "%% Function: TestCase() -> Info" n
  1143. "%% Info = [tuple()]" n
  1144. (erlang-skel-separator 2)
  1145. "my_test_case() -> " n >
  1146. "[]." n n
  1147. (erlang-skel-separator 2)
  1148. "%% Function: TestCase(Config0) ->" n
  1149. "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n
  1150. "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n
  1151. "%% Config0 = Config1 = [tuple()]" n
  1152. "%% Reason = term()" n
  1153. "%% Comment = term()" n
  1154. (erlang-skel-separator 2)
  1155. "my_test_case(_Config) -> " n >
  1156. "ok." n
  1157. )
  1158. "*The template of a library module.
  1159. Please see the function `tempo-define-template'.")