aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2014-02-03 10:27:39 +0100
committerHans Bolinder <[email protected]>2014-02-23 15:01:29 +0100
commitb66e75c285cba469c5225f3394da149456d17d16 (patch)
tree3b11b80782cff70e478e8f11017bfc26745843cd /lib/stdlib/test
parent85a5aca047ea4c3dcdeb1e47cdf523a48140bf18 (diff)
downloadotp-b66e75c285cba469c5225f3394da149456d17d16.tar.gz
otp-b66e75c285cba469c5225f3394da149456d17d16.tar.bz2
otp-b66e75c285cba469c5225f3394da149456d17d16.zip
Deprecate pre-defined built-in types
The types array(), dict(), digraph(), gb_set(), gb_tree(), queue(), set(), and tid() have been deprecated. They will be removed in OTP 18.0. Instead the types array:array(), dict:dict(), digraph:graph(), gb_set:set(), gb_tree:tree(), queue:queue(), sets:set(), and ets:tid() can be used. (Note: it has always been necessary to use ets:tid().) It is allowed in OTP 17.0 to locally re-define the types array(), dict(), and so on. New types array:array/1, dict:dict/2, gb_sets:set/1, gb_trees:tree/2, queue:queue/1, and sets:set/1 have been added.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/erl_lint_SUITE.erl30
-rw-r--r--lib/stdlib/test/erl_lint_SUITE_data/predef.erl67
-rw-r--r--lib/stdlib/test/erl_lint_SUITE_data/predef2.erl56
3 files changed, 148 insertions, 5 deletions
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 48f50d5f43..1614a2722f 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1999-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -60,7 +60,8 @@
format_warn/1,
on_load_successful/1, on_load_failing/1,
too_many_arguments/1,
- basic_errors/1,bin_syntax_errors/1
+ basic_errors/1,bin_syntax_errors/1,
+ predef/1
]).
% Default timetrap timeout (set in init_per_testcase).
@@ -87,7 +88,7 @@ all() ->
otp_5878, otp_5917, otp_6585, otp_6885, otp_10436, otp_11254,export_all,
bif_clash, behaviour_basic, behaviour_multiple,
otp_7550, otp_8051, format_warn, {group, on_load},
- too_many_arguments, basic_errors, bin_syntax_errors].
+ too_many_arguments, basic_errors, bin_syntax_errors, predef].
groups() ->
[{unused_vars_warn, [],
@@ -3241,6 +3242,23 @@ bin_syntax_errors(Config) ->
[] = run(Config, Ts),
ok.
+predef(doc) ->
+ "Predefined types: array(), digraph(), and so on";
+predef(suite) -> [];
+predef(Config) when is_list(Config) ->
+ W = get_compilation_warnings(Config, "predef", []),
+ [] = W,
+ W2 = get_compilation_warnings(Config, "predef2", []),
+ [{7,erl_lint,{deprecated_type,{array,0},{array,array},"OTP 18.0"}},
+ {12,erl_lint,{deprecated_type,{dict,0},{dict,dict},"OTP 18.0"}},
+ {17,erl_lint,{deprecated_type,{digraph,0},{digraph,graph},"OTP 18.0"}},
+ {27,erl_lint,{deprecated_type,{gb_set,0},{gb_sets,set},"OTP 18.0"}},
+ {32,erl_lint,{deprecated_type,{gb_tree,0},{gb_trees,tree},"OTP 18.0"}},
+ {37,erl_lint,{deprecated_type,{queue,0},{queue,queue},"OTP 18.0"}},
+ {42,erl_lint,{deprecated_type,{set,0},{sets,set},"OTP 18.0"}},
+ {47,erl_lint,{deprecated_type,{tid,0},{ets,tid},"OTP 18.0"}}] = W2,
+ ok.
+
run(Config, Tests) ->
F = fun({N,P,Ws,E}, BadL) ->
case catch run_test(Config, P, Ws) of
@@ -3263,8 +3281,10 @@ get_compilation_warnings(Conf, Filename, Warnings) ->
FileS = binary_to_list(Bin),
{match,[{Start,Length}|_]} = re:run(FileS, "-module.*\\n"),
Test = lists:nthtail(Start+Length, FileS),
- {warnings, Ws} = run_test(Conf, Test, Warnings),
- Ws.
+ case run_test(Conf, Test, Warnings) of
+ {warnings, Ws} -> Ws;
+ [] -> []
+ end.
%% Compiles a test module and returns the list of errors and warnings.
diff --git a/lib/stdlib/test/erl_lint_SUITE_data/predef.erl b/lib/stdlib/test/erl_lint_SUITE_data/predef.erl
new file mode 100644
index 0000000000..c2364fd1c2
--- /dev/null
+++ b/lib/stdlib/test/erl_lint_SUITE_data/predef.erl
@@ -0,0 +1,67 @@
+-module(predef).
+
+-export([array/1, dict/1, digraph/1, digraph2/1, gb_set/1, gb_tree/1,
+ queue/1, set/1, tid/0, tid2/0]).
+
+-export_type([array/0, digraph/0, gb_set/0]).
+
+%% Before R17B local re-definitions of pre-defined opaque types were
+%% ignored but did not generate any warning.
+-opaque array() :: atom().
+-opaque digraph() :: atom().
+-opaque gb_set() :: atom().
+-type dict() :: atom().
+-type gb_tree() :: atom().
+-type queue() :: atom().
+-type set() :: atom().
+-type tid() :: atom().
+
+-spec array(array()) -> array:array().
+
+array(A) ->
+ array:relax(A).
+
+-spec dict(dict()) -> dict:dict().
+
+dict(D) ->
+ dict:store(1, a, D).
+
+-spec digraph(digraph()) -> [digraph:edge()].
+
+digraph(G) ->
+ digraph:edges(G).
+
+-spec digraph2(digraph:graph()) -> [digraph:edge()].
+
+digraph2(G) ->
+ digraph:edges(G).
+
+-spec gb_set(gb_set()) -> gb_sets:set().
+
+gb_set(S) ->
+ gb_sets:balance(S).
+
+-spec gb_tree(gb_tree()) -> gb_trees:tree().
+
+gb_tree(S) ->
+ gb_trees:balance(S).
+
+-spec queue(queue()) -> queue:queue().
+
+queue(Q) ->
+ queue:reverse(Q).
+
+-spec set(set()) -> sets:set().
+
+set(S) ->
+ sets:union([S]).
+
+-spec tid() -> tid().
+
+tid() ->
+ ets:new(tid, []).
+
+-spec tid2() -> ets:tid().
+
+tid2() ->
+ ets:new(tid, []).
diff --git a/lib/stdlib/test/erl_lint_SUITE_data/predef2.erl b/lib/stdlib/test/erl_lint_SUITE_data/predef2.erl
new file mode 100644
index 0000000000..b1d941a49a
--- /dev/null
+++ b/lib/stdlib/test/erl_lint_SUITE_data/predef2.erl
@@ -0,0 +1,56 @@
+-module(predef2).
+
+-export([array/1, dict/1, digraph/1, digraph2/1, gb_set/1, gb_tree/1,
+ queue/1, set/1, tid/0, tid2/0]).
+
+-export_type([array/0, digraph/0, gb_set/0]).
+
+-spec array(array()) -> array:array().
+
+array(A) ->
+ array:relax(A).
+
+-spec dict(dict()) -> dict:dict().
+
+dict(D) ->
+ dict:store(1, a, D).
+
+-spec digraph(digraph()) -> [digraph:edge()].
+
+digraph(G) ->
+ digraph:edges(G).
+
+-spec digraph2(digraph:graph()) -> [digraph:edge()].
+
+digraph2(G) ->
+ digraph:edges(G).
+
+-spec gb_set(gb_set()) -> gb_sets:set().
+
+gb_set(S) ->
+ gb_sets:balance(S).
+
+-spec gb_tree(gb_tree()) -> gb_trees:tree().
+
+gb_tree(S) ->
+ gb_trees:balance(S).
+
+-spec queue(queue()) -> queue:queue().
+
+queue(Q) ->
+ queue:reverse(Q).
+
+-spec set(set()) -> sets:set().
+
+set(S) ->
+ sets:union([S]).
+
+-spec tid() -> tid().
+
+tid() ->
+ ets:new(tid, []).
+
+-spec tid2() -> ets:tid().
+
+tid2() ->
+ ets:new(tid, []).