mirror of
https://github.com/amix/vimrc
synced 2024-12-13 21:52:38 +00:00
353 lines
10 KiB
Text
353 lines
10 KiB
Text
# module and export all
|
|
snippet mod
|
|
-module(${1:`vim_snippets#Filename('', 'my')`}).
|
|
|
|
-compile([export_all]).
|
|
|
|
start() ->
|
|
${0}
|
|
|
|
stop() ->
|
|
ok.
|
|
# define directive
|
|
snippet def
|
|
-define(${1:macro}, ${2:body}).
|
|
# export directive
|
|
snippet exp
|
|
-export([${1:function}/${0:arity}]).
|
|
# include directive
|
|
snippet inc
|
|
-include("${1:file}").
|
|
# include_lib directive
|
|
snippet incl
|
|
-include_lib("${1:lib}/include/${1}.hrl").${2}
|
|
# behavior directive
|
|
snippet beh
|
|
-behaviour(${1:behaviour}).
|
|
# if expression
|
|
snippet if
|
|
if
|
|
${1:guard} ->
|
|
${0:body}
|
|
end
|
|
# case expression
|
|
snippet case
|
|
case ${1:expression} of
|
|
${2:pattern} ->
|
|
${0:body};
|
|
end
|
|
# anonymous function
|
|
snippet fun
|
|
fun (${1:Parameters}) -> ${2:body} end
|
|
# try...catch
|
|
snippet try
|
|
try
|
|
${1}
|
|
catch
|
|
${2:_:_} -> ${0:got_some_exception}
|
|
end
|
|
# record directive
|
|
snippet rec
|
|
-record(${1:record}, {
|
|
${2:field}=${3:value}}).
|
|
# todo comment
|
|
snippet todo
|
|
%% TODO: ${0}
|
|
## Snippets below (starting with '%') are in EDoc format.
|
|
## See http://www.erlang.org/doc/apps/edoc/chapter.html#id56887 for more details
|
|
# doc comment
|
|
snippet %d
|
|
%% @doc ${0}
|
|
# end of doc comment
|
|
snippet %e
|
|
%% @end
|
|
# specification comment
|
|
snippet %s
|
|
%% @spec ${0}
|
|
# private function marker
|
|
snippet %p
|
|
%% @private
|
|
# OTP application
|
|
snippet application
|
|
-module(${1:`vim_snippets#Filename('', 'my')`}).
|
|
|
|
-behaviour(application).
|
|
|
|
-export([start/2, stop/1]).
|
|
|
|
start(_Type, _StartArgs) ->
|
|
case ${0:root_supervisor}:start_link() of
|
|
{ok, Pid} ->
|
|
{ok, Pid};
|
|
Other ->
|
|
{error, Other}
|
|
end.
|
|
|
|
stop(_State) ->
|
|
ok.
|
|
# OTP supervisor
|
|
snippet supervisor
|
|
-module(${1:`vim_snippets#Filename('', 'my')`}).
|
|
|
|
-behaviour(supervisor).
|
|
|
|
%% API
|
|
-export([start_link/0]).
|
|
|
|
%% Supervisor callbacks
|
|
-export([init/1]).
|
|
|
|
-define(SERVER, ?MODULE).
|
|
|
|
start_link() ->
|
|
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
|
|
|
|
init([]) ->
|
|
Server = {${0:my_server}, {$2, start_link, []},
|
|
permanent, 2000, worker, [$2]},
|
|
Children = [Server],
|
|
RestartStrategy = {one_for_one, 0, 1},
|
|
{ok, {RestartStrategy, Children}}.
|
|
# OTP gen_server
|
|
snippet gen_server
|
|
-module(${0:`vim_snippets#Filename('', 'my')`}).
|
|
|
|
-behaviour(gen_server).
|
|
|
|
%% API
|
|
-export([
|
|
start_link/0
|
|
]).
|
|
|
|
%% gen_server callbacks
|
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
|
terminate/2, code_change/3]).
|
|
|
|
-define(SERVER, ?MODULE).
|
|
|
|
-record(state, {}).
|
|
|
|
%%%===================================================================
|
|
%%% API
|
|
%%%===================================================================
|
|
|
|
start_link() ->
|
|
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
|
|
|
%%%===================================================================
|
|
%%% gen_server callbacks
|
|
%%%===================================================================
|
|
|
|
init([]) ->
|
|
{ok, #state{}}.
|
|
|
|
handle_call(_Request, _From, State) ->
|
|
Reply = ok,
|
|
{reply, Reply, State}.
|
|
|
|
handle_cast(_Msg, State) ->
|
|
{noreply, State}.
|
|
|
|
handle_info(_Info, State) ->
|
|
{noreply, State}.
|
|
|
|
terminate(_Reason, _State) ->
|
|
ok.
|
|
|
|
code_change(_OldVsn, State, _Extra) ->
|
|
{ok, State}.
|
|
|
|
%%%===================================================================
|
|
%%% Internal functions
|
|
%%%===================================================================
|
|
# common_test test_SUITE
|
|
snippet testsuite
|
|
-module(${0:`vim_snippets#Filename('', 'my')`}).
|
|
|
|
-include_lib("common_test/include/ct.hrl").
|
|
|
|
%% Test server callbacks
|
|
-export([suite/0, all/0, groups/0,
|
|
init_per_suite/1, end_per_suite/1,
|
|
init_per_group/2, end_per_group/2,
|
|
init_per_testcase/2, end_per_testcase/2]).
|
|
|
|
%% Test cases
|
|
-export([
|
|
]).
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% COMMON TEST CALLBACK FUNCTIONS
|
|
%%--------------------------------------------------------------------
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: suite() -> Info
|
|
%%
|
|
%% Info = [tuple()]
|
|
%% List of key/value pairs.
|
|
%%
|
|
%% Description: Returns list of tuples to set default properties
|
|
%% for the suite.
|
|
%%
|
|
%% Note: The suite/0 function is only meant to be used to return
|
|
%% default data values, not perform any other operations.
|
|
%%--------------------------------------------------------------------
|
|
suite() ->
|
|
[{timetrap,{minutes,10}}].
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: init_per_suite(Config0) ->
|
|
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
|
|
%%
|
|
%% Config0 = Config1 = [tuple()]
|
|
%% A list of key/value pairs, holding the test case configuration.
|
|
%% Reason = term()
|
|
%% The reason for skipping the suite.
|
|
%%
|
|
%% Description: Initialization before the suite.
|
|
%%
|
|
%% Note: This function is free to add any key/value pairs to the Config
|
|
%% variable, but should NOT alter/remove any existing entries.
|
|
%%--------------------------------------------------------------------
|
|
init_per_suite(Config) ->
|
|
Config.
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
|
|
%%
|
|
%% Config0 = Config1 = [tuple()]
|
|
%% A list of key/value pairs, holding the test case configuration.
|
|
%%
|
|
%% Description: Cleanup after the suite.
|
|
%%--------------------------------------------------------------------
|
|
end_per_suite(_Config) ->
|
|
ok.
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: init_per_group(GroupName, Config0) ->
|
|
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
|
|
%%
|
|
%% GroupName = atom()
|
|
%% Name of the test case group that is about to run.
|
|
%% Config0 = Config1 = [tuple()]
|
|
%% A list of key/value pairs, holding configuration data for the group.
|
|
%% Reason = term()
|
|
%% The reason for skipping all test cases and subgroups in the group.
|
|
%%
|
|
%% Description: Initialization before each test case group.
|
|
%%--------------------------------------------------------------------
|
|
init_per_group(_GroupName, Config) ->
|
|
Config.
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: end_per_group(GroupName, Config0) ->
|
|
%% void() | {save_config,Config1}
|
|
%%
|
|
%% GroupName = atom()
|
|
%% Name of the test case group that is finished.
|
|
%% Config0 = Config1 = [tuple()]
|
|
%% A list of key/value pairs, holding configuration data for the group.
|
|
%%
|
|
%% Description: Cleanup after each test case group.
|
|
%%--------------------------------------------------------------------
|
|
end_per_group(_GroupName, _Config) ->
|
|
ok.
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: init_per_testcase(TestCase, Config0) ->
|
|
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
|
|
%%
|
|
%% TestCase = atom()
|
|
%% Name of the test case that is about to run.
|
|
%% Config0 = Config1 = [tuple()]
|
|
%% A list of key/value pairs, holding the test case configuration.
|
|
%% Reason = term()
|
|
%% The reason for skipping the test case.
|
|
%%
|
|
%% Description: Initialization before each test case.
|
|
%%
|
|
%% Note: This function is free to add any key/value pairs to the Config
|
|
%% variable, but should NOT alter/remove any existing entries.
|
|
%%--------------------------------------------------------------------
|
|
init_per_testcase(_TestCase, Config) ->
|
|
Config.
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: end_per_testcase(TestCase, Config0) ->
|
|
%% void() | {save_config,Config1} | {fail,Reason}
|
|
%%
|
|
%% TestCase = atom()
|
|
%% Name of the test case that is finished.
|
|
%% Config0 = Config1 = [tuple()]
|
|
%% A list of key/value pairs, holding the test case configuration.
|
|
%% Reason = term()
|
|
%% The reason for failing the test case.
|
|
%%
|
|
%% Description: Cleanup after each test case.
|
|
%%--------------------------------------------------------------------
|
|
end_per_testcase(_TestCase, _Config) ->
|
|
ok.
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: groups() -> [Group]
|
|
%%
|
|
%% Group = {GroupName,Properties,GroupsAndTestCases}
|
|
%% GroupName = atom()
|
|
%% The name of the group.
|
|
%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
|
|
%% Group properties that may be combined.
|
|
%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
|
|
%% TestCase = atom()
|
|
%% The name of a test case.
|
|
%% Shuffle = shuffle | {shuffle,Seed}
|
|
%% To get cases executed in random order.
|
|
%% Seed = {integer(),integer(),integer()}
|
|
%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
|
|
%% repeat_until_any_ok | repeat_until_any_fail
|
|
%% To get execution of cases repeated.
|
|
%% N = integer() | forever
|
|
%%
|
|
%% Description: Returns a list of test case group definitions.
|
|
%%--------------------------------------------------------------------
|
|
groups() ->
|
|
[].
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: all() -> GroupsAndTestCases | {skip,Reason}
|
|
%%
|
|
%% GroupsAndTestCases = [{group,GroupName} | TestCase]
|
|
%% GroupName = atom()
|
|
%% Name of a test case group.
|
|
%% TestCase = atom()
|
|
%% Name of a test case.
|
|
%% Reason = term()
|
|
%% The reason for skipping all groups and test cases.
|
|
%%
|
|
%% Description: Returns the list of groups and test cases that
|
|
%% are to be executed.
|
|
%%--------------------------------------------------------------------
|
|
all() ->
|
|
[].
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% TEST CASES
|
|
%%--------------------------------------------------------------------
|
|
|
|
%%--------------------------------------------------------------------
|
|
%% Function: TestCase(Config0) ->
|
|
%% ok | exit() | {skip,Reason} | {comment,Comment} |
|
|
%% {save_config,Config1} | {skip_and_save,Reason,Config1}
|
|
%%
|
|
%% Config0 = Config1 = [tuple()]
|
|
%% A list of key/value pairs, holding the test case configuration.
|
|
%% Reason = term()
|
|
%% The reason for skipping the test case.
|
|
%% Comment = term()
|
|
%% A comment about the test case that will be printed in the html log.
|
|
%%
|
|
%% Description: Test case function. (The name of it must be specified in
|
|
%% the all/0 list or in a test case group for the test case
|
|
%% to be executed).
|
|
%%--------------------------------------------------------------------
|
|
|