From 40706594b498291d57528ccb3e966febccb959b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 7 Nov 2013 15:27:56 +0100 Subject: edoc: Add test for Maps in EDoc --- lib/edoc/test/edoc_SUITE.erl | 39 +++++++++++++++------------- lib/edoc/test/edoc_SUITE_data/map_module.erl | 27 +++++++++++++++++++ 2 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 lib/edoc/test/edoc_SUITE_data/map_module.erl (limited to 'lib/edoc/test') diff --git a/lib/edoc/test/edoc_SUITE.erl b/lib/edoc/test/edoc_SUITE.erl index 5b95c35756..b649971e99 100644 --- a/lib/edoc/test/edoc_SUITE.erl +++ b/lib/edoc/test/edoc_SUITE.erl @@ -22,12 +22,12 @@ init_per_group/2,end_per_group/2]). %% Test cases --export([build_std/1]). +-export([build_std/1,build_map_module/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [build_std]. + [build_std,build_map_module]. groups() -> []. @@ -45,25 +45,28 @@ end_per_group(_GroupName, Config) -> Config. -build_std(suite) -> - []; -build_std(doc) -> - ["Build some documentation using standard EDoc layout"]; +build_std(suite) -> []; +build_std(doc) -> ["Build some documentation using standard EDoc layout"]; build_std(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + Overview1 = filename:join(DataDir, "overview.edoc"), + Overview2 = filename:join(DataDir, "overview.syntax_tools"), + PrivDir = ?config(priv_dir, Config), - ?line DataDir = ?config(data_dir, Config), - ?line Overview1 = filename:join(DataDir, "overview.edoc"), - ?line Overview2 = filename:join(DataDir, "overview.syntax_tools"), - ?line PrivDir = ?config(priv_dir, Config), + ok = edoc:application(edoc, [{overview, Overview1}, + {def, {vsn,"TEST"}}, + {dir, PrivDir}]), - ?line ok = edoc:application(edoc, [{overview, Overview1}, - {def, {vsn,"TEST"}}, - {dir, PrivDir}]), + ok = edoc:application(syntax_tools, [{overview, Overview2}, + {def, {vsn,"TEST"}}, + {dir, PrivDir}]), - ?line ok = edoc:application(syntax_tools, [{overview, Overview2}, - {def, {vsn,"TEST"}}, - {dir, PrivDir}]), - - ?line ok = edoc:application(xmerl, [{dir, PrivDir}]), + ok = edoc:application(xmerl, [{dir, PrivDir}]), + ok. +build_map_module(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + PrivDir = ?config(priv_dir, Config), + Filename = filename:join(DataDir, "map_module.erl"), + ok = edoc:file(Filename, [{dir, PrivDir}]), ok. diff --git a/lib/edoc/test/edoc_SUITE_data/map_module.erl b/lib/edoc/test/edoc_SUITE_data/map_module.erl new file mode 100644 index 0000000000..94ee7e6f26 --- /dev/null +++ b/lib/edoc/test/edoc_SUITE_data/map_module.erl @@ -0,0 +1,27 @@ +-module(map_module). + +-export([foo1/1,foo2/3]). + +%% @type wazzup() = integer() +%% @type some_type() = map() +%% @type some_other_type() = {a, #{ list() => term()}} + +-type some_type() :: map(). +-type some_other_type() :: {'a', #{ list() => term()} }. +-type wazzup() :: integer(). + +-spec foo1(Map :: #{ 'a' => integer(), 'b' => term()}) -> term(). + +%% @doc Gets value from map. + +foo1(#{ a:= 1, b := V}) -> V. + +%% @spec foo2(some_type(), Type2 :: some_other_type(), map()) -> Value +%% @doc Gets value from map. + +-spec foo2( + Type1 :: some_type(), + Type2 :: some_other_type(), + Map :: #{ get => 'value', 'value' => binary()}) -> binary(). + +foo2(Type1, {a,#{ "a" := _}}, #{get := value, value := B}) when is_map(Type1) -> B. -- cgit v1.2.3