aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/Makefile2
-rw-r--r--lib/stdlib/test/base64_SUITE.erl14
-rw-r--r--lib/stdlib/test/binary_module_SUITE.erl9
-rw-r--r--lib/stdlib/test/c_SUITE.erl13
-rw-r--r--lib/stdlib/test/dets_SUITE.erl3968
-rw-r--r--lib/stdlib/test/dict_SUITE.erl22
-rw-r--r--lib/stdlib/test/dict_test_lib.erl57
-rw-r--r--lib/stdlib/test/digraph_SUITE.erl4
-rw-r--r--lib/stdlib/test/epp_SUITE.erl129
-rw-r--r--lib/stdlib/test/erl_eval_SUITE.erl110
-rw-r--r--lib/stdlib/test/erl_eval_helper.erl28
-rw-r--r--lib/stdlib/test/erl_expand_records_SUITE.erl49
-rw-r--r--lib/stdlib/test/erl_lint_SUITE.erl201
-rw-r--r--lib/stdlib/test/erl_pp_SUITE.erl219
-rw-r--r--lib/stdlib/test/erl_scan_SUITE.erl325
-rw-r--r--lib/stdlib/test/escript_SUITE.erl49
-rw-r--r--lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl4
-rw-r--r--lib/stdlib/test/escript_SUITE_data/emulator_flags_no_shebang10
-rwxr-xr-xlib/stdlib/test/escript_SUITE_data/unicode114
-rwxr-xr-xlib/stdlib/test/escript_SUITE_data/unicode214
-rwxr-xr-xlib/stdlib/test/escript_SUITE_data/unicode313
-rwxr-xr-xlib/stdlib/test/escript_SUITE_data/unicode412
-rwxr-xr-xlib/stdlib/test/escript_SUITE_data/unicode512
-rwxr-xr-xlib/stdlib/test/escript_SUITE_data/unicode613
-rw-r--r--lib/stdlib/test/ets_SUITE.erl309
-rw-r--r--lib/stdlib/test/filelib_SUITE.erl97
-rw-r--r--lib/stdlib/test/filename_SUITE.erl248
-rw-r--r--lib/stdlib/test/gen_event_SUITE.erl49
-rw-r--r--lib/stdlib/test/gen_fsm_SUITE.erl57
-rw-r--r--lib/stdlib/test/gen_server_SUITE.erl75
-rw-r--r--lib/stdlib/test/id_transform_SUITE.erl15
-rw-r--r--lib/stdlib/test/io_SUITE.erl201
-rw-r--r--lib/stdlib/test/io_proto_SUITE.erl41
-rw-r--r--lib/stdlib/test/lists_SUITE.erl6
-rw-r--r--lib/stdlib/test/proc_lib_SUITE.erl31
-rw-r--r--lib/stdlib/test/qlc_SUITE.erl48
-rw-r--r--lib/stdlib/test/qlc_SUITE_data/join_info_compat.erl217
-rw-r--r--lib/stdlib/test/re_SUITE.erl27
-rw-r--r--lib/stdlib/test/re_testoutput1_replacement_test.erl55
-rw-r--r--lib/stdlib/test/re_testoutput1_split_test.erl81
-rw-r--r--lib/stdlib/test/sets_SUITE.erl344
-rw-r--r--lib/stdlib/test/sets_test_lib.erl84
-rw-r--r--lib/stdlib/test/shell_SUITE.erl262
-rw-r--r--lib/stdlib/test/stdlib.cover15
-rw-r--r--lib/stdlib/test/stdlib.spec.vxworks8
-rw-r--r--lib/stdlib/test/string_SUITE.erl7
-rw-r--r--lib/stdlib/test/supervisor_3.erl45
-rw-r--r--lib/stdlib/test/supervisor_SUITE.erl145
-rw-r--r--lib/stdlib/test/supervisor_SUITE_data/Makefile.src15
-rw-r--r--lib/stdlib/test/supervisor_SUITE_data/app_faulty/ebin/app_faulty.app10
-rw-r--r--lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty.erl17
-rw-r--r--lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty_server.erl32
-rw-r--r--lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty_sup.erl17
-rw-r--r--lib/stdlib/test/sys_SUITE.erl90
-rw-r--r--lib/stdlib/test/timer_SUITE.erl10
-rw-r--r--lib/stdlib/test/unicode_SUITE.erl149
-rw-r--r--lib/stdlib/test/zip_SUITE.erl25
57 files changed, 4784 insertions, 3339 deletions
diff --git a/lib/stdlib/test/Makefile b/lib/stdlib/test/Makefile
index 29b8e28d3a..af82f22b21 100644
--- a/lib/stdlib/test/Makefile
+++ b/lib/stdlib/test/Makefile
@@ -23,7 +23,6 @@ MODULES= \
dummy_via \
edlin_expand_SUITE \
epp_SUITE \
- erl_eval_helper \
erl_eval_SUITE \
erl_expand_records_SUITE \
erl_internal_SUITE \
@@ -67,6 +66,7 @@ MODULES= \
string_SUITE \
supervisor_1 \
supervisor_2 \
+ supervisor_3 \
supervisor_deadlock \
naughty_child \
shell_SUITE \
diff --git a/lib/stdlib/test/base64_SUITE.erl b/lib/stdlib/test/base64_SUITE.erl
index c64a961ffa..b28df94221 100644
--- a/lib/stdlib/test/base64_SUITE.erl
+++ b/lib/stdlib/test/base64_SUITE.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2007-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2007-2012. 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
@@ -20,7 +21,6 @@
-module(base64_SUITE).
-include_lib("common_test/include/ct.hrl").
--include("test_server_line.hrl").
%% Test server specific exports
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
@@ -33,7 +33,7 @@
mime_decode_to_string/1, roundtrip/1]).
init_per_testcase(_, Config) ->
- Dog = test_server:timetrap(?t:minutes(2)),
+ Dog = test_server:timetrap(?t:minutes(4)),
NewConfig = lists:keydelete(watchdog, 1, Config),
[{watchdog, Dog} | NewConfig].
@@ -180,7 +180,7 @@ mime_decode(Config) when is_list(Config) ->
<<"o">> = base64:mime_decode(<<"b=w=====">>),
%% Test misc white space and illegals with embedded padding
<<"one">> = base64:mime_decode(<<" b~2=\r\n5()l===">>),
- <<"on">> = base64:mime_decode(<<"\tb =2\"�4=�= ==">>),
+ <<"on">> = base64:mime_decode(<<"\tb =2\"¤4=¤= ==">>),
<<"o">> = base64:mime_decode(<<"\nb=w=====">>),
%% Two pads
<<"Aladdin:open sesame">> =
@@ -189,7 +189,7 @@ mime_decode(Config) when is_list(Config) ->
<<"Hello World!!">> = base64:mime_decode(<<"SGVsb)(G8gV29ybGQ=h IQ= =">>),
%% No pad
<<"Aladdin:open sesam">> =
- base64:mime_decode("QWxhZGRpbjpvcG�\")(VuIHNlc2Ft"),
+ base64:mime_decode("QWxhZGRpbjpvcG¤\")(VuIHNlc2Ft"),
%% Encoded base 64 strings may be divided by non base 64 chars.
%% In this cases whitespaces.
<<"0123456789!@#0^&*();:<>,. []{}">> =
@@ -223,7 +223,7 @@ mime_decode_to_string(Config) when is_list(Config) ->
"o" = base64:mime_decode_to_string(<<"b=w=====">>),
%% Test misc white space and illegals with embedded padding
"one" = base64:mime_decode_to_string(<<" b~2=\r\n5()l===">>),
- "on" = base64:mime_decode_to_string(<<"\tb =2\"�4=�= ==">>),
+ "on" = base64:mime_decode_to_string(<<"\tb =2\"¤4=¤= ==">>),
"o" = base64:mime_decode_to_string(<<"\nb=w=====">>),
%% Two pads
"Aladdin:open sesame" =
@@ -232,7 +232,7 @@ mime_decode_to_string(Config) when is_list(Config) ->
"Hello World!!" = base64:mime_decode_to_string(<<"SGVsb)(G8gV29ybGQ=h IQ= =">>),
%% No pad
"Aladdin:open sesam" =
- base64:mime_decode_to_string("QWxhZGRpbjpvcG�\")(VuIHNlc2Ft"),
+ base64:mime_decode_to_string("QWxhZGRpbjpvcG¤\")(VuIHNlc2Ft"),
%% Encoded base 64 strings may be divided by non base 64 chars.
%% In this cases whitespaces.
"0123456789!@#0^&*();:<>,. []{}" =
diff --git a/lib/stdlib/test/binary_module_SUITE.erl b/lib/stdlib/test/binary_module_SUITE.erl
index bac59a3107..9b6f628aa9 100644
--- a/lib/stdlib/test/binary_module_SUITE.erl
+++ b/lib/stdlib/test/binary_module_SUITE.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. 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
@@ -1331,9 +1332,9 @@ one_random_number(N) ->
one_random(N) ->
M = ((N - 1) rem 68) + 1,
element(M,{$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,
- $u,$v,$w,$x,$y,$z,$�,$�,$�,$A,$B,$C,$D,$E,$F,$G,$H,
- $I,$J,$K,$L,$M,$N,$O,$P,$Q,$R,$S,$T,$U,$V,$W,$X,$Y,$Z,$�,
- $�,$�,$0,$1,$2,$3,$4,$5,$6,$7,$8,$9}).
+ $u,$v,$w,$x,$y,$z,$å,$ä,$ö,$A,$B,$C,$D,$E,$F,$G,$H,
+ $I,$J,$K,$L,$M,$N,$O,$P,$Q,$R,$S,$T,$U,$V,$W,$X,$Y,$Z,$Å,
+ $Ä,$Ö,$0,$1,$2,$3,$4,$5,$6,$7,$8,$9}).
random_number({Min,Max}) -> % Min and Max are *length* of number in
% decimal positions
diff --git a/lib/stdlib/test/c_SUITE.erl b/lib/stdlib/test/c_SUITE.erl
index 25281365be..a018db9c91 100644
--- a/lib/stdlib/test/c_SUITE.erl
+++ b/lib/stdlib/test/c_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. 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
@@ -20,7 +20,7 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2]).
-export([c_1/1, c_2/1, c_3/1, c_4/1, nc_1/1, nc_2/1, nc_3/1, nc_4/1,
- memory/1]).
+ ls/1, memory/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -29,7 +29,7 @@
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [c_1, c_2, c_3, c_4, nc_1, nc_2, nc_3, nc_4, memory].
+ [c_1, c_2, c_3, c_4, nc_1, nc_2, nc_3, nc_4, ls, memory].
groups() ->
[].
@@ -147,6 +147,13 @@ nc_4(Config) when is_list(Config) ->
?line Result = nc(R,[{outdir,W}]),
?line {ok, m} = Result.
+ls(Config) when is_list(Config) ->
+ Directory = ?config(data_dir, Config),
+ ok = c:ls(Directory),
+ File = filename:join(Directory, "m.erl"),
+ ok = c:ls(File),
+ ok = c:ls("no_such_file").
+
memory(doc) ->
["Checks that c:memory/[0,1] returns consistent results."];
memory(suite) ->
diff --git a/lib/stdlib/test/dets_SUITE.erl b/lib/stdlib/test/dets_SUITE.erl
index 6f77cff2b9..8ff7c3ccc9 100644
--- a/lib/stdlib/test/dets_SUITE.erl
+++ b/lib/stdlib/test/dets_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. 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
@@ -22,7 +22,6 @@
-ifdef(debug).
-define(format(S, A), io:format(S, A)).
--define(line, put(line, ?LINE), ).
-define(config(X,Y), foo).
-define(t, test_server).
-define(privdir(_), "./dets_SUITE_priv").
@@ -34,11 +33,9 @@
-define(datadir(Conf), ?config(data_dir, Conf)).
-endif.
--compile(r13). % OTP-9607
-
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2,
- not_run/1, newly_started/1, basic_v8/1, basic_v9/1,
+ newly_started/1, basic_v8/1, basic_v9/1,
open_v8/1, open_v9/1, sets_v8/1, sets_v9/1, bags_v8/1,
bags_v9/1, duplicate_bags_v8/1, duplicate_bags_v9/1,
access_v8/1, access_v9/1, dirty_mark/1, dirty_mark2/1,
@@ -55,7 +52,7 @@
simultaneous_open/1, insert_new/1, repair_continuation/1,
otp_5487/1, otp_6206/1, otp_6359/1, otp_4738/1, otp_7146/1,
otp_8070/1, otp_8856/1, otp_8898/1, otp_8899/1, otp_8903/1,
- otp_8923/1, otp_9282/1, otp_9607/1]).
+ otp_8923/1, otp_9282/1]).
-export([dets_dirty_loop/0]).
@@ -95,27 +92,25 @@ end_per_testcase(_Case, _Config) ->
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- case os:type() of
- vxworks -> [not_run];
- _ ->
- [basic_v8, basic_v9, open_v8, open_v9, sets_v8, sets_v9,
- bags_v8, bags_v9, duplicate_bags_v8, duplicate_bags_v9,
- newly_started, open_file_v8, open_file_v9,
- init_table_v8, init_table_v9, repair_v8, repair_v9,
- access_v8, access_v9, oldbugs_v8, oldbugs_v9,
- unsafe_assumptions, truncated_segment_array_v8,
- truncated_segment_array_v9, dirty_mark, dirty_mark2,
- bag_next_v8, bag_next_v9, hash_v8b_v8c, phash, fold_v8,
- fold_v9, fixtable_v8, fixtable_v9, match_v8, match_v9,
- select_v8, select_v9, update_counter, badarg,
- cache_sets_v8, cache_sets_v9, cache_bags_v8,
- cache_bags_v9, cache_duplicate_bags_v8,
- cache_duplicate_bags_v9, otp_4208, otp_4989,
- many_clients, otp_4906, otp_5402, simultaneous_open,
- insert_new, repair_continuation, otp_5487, otp_6206,
- otp_6359, otp_4738, otp_7146, otp_8070, otp_8856, otp_8898,
- otp_8899, otp_8903, otp_8923, otp_9282, otp_9607]
- end.
+ [
+ basic_v8, basic_v9, open_v8, open_v9, sets_v8, sets_v9,
+ bags_v8, bags_v9, duplicate_bags_v8, duplicate_bags_v9,
+ newly_started, open_file_v8, open_file_v9,
+ init_table_v8, init_table_v9, repair_v8, repair_v9,
+ access_v8, access_v9, oldbugs_v8, oldbugs_v9,
+ unsafe_assumptions, truncated_segment_array_v8,
+ truncated_segment_array_v9, dirty_mark, dirty_mark2,
+ bag_next_v8, bag_next_v9, hash_v8b_v8c, phash, fold_v8,
+ fold_v9, fixtable_v8, fixtable_v9, match_v8, match_v9,
+ select_v8, select_v9, update_counter, badarg,
+ cache_sets_v8, cache_sets_v9, cache_bags_v8,
+ cache_bags_v9, cache_duplicate_bags_v8,
+ cache_duplicate_bags_v9, otp_4208, otp_4989,
+ many_clients, otp_4906, otp_5402, simultaneous_open,
+ insert_new, repair_continuation, otp_5487, otp_6206,
+ otp_6359, otp_4738, otp_7146, otp_8070, otp_8856, otp_8898,
+ otp_8899, otp_8903, otp_8923, otp_9282
+ ].
groups() ->
[].
@@ -132,19 +127,15 @@ init_per_group(_GroupName, Config) ->
end_per_group(_GroupName, Config) ->
Config.
-not_run(suite) -> [];
-not_run(Conf) when is_list(Conf) ->
- {comment, "Not runnable VxWorks/NFS"}.
-
newly_started(doc) ->
["OTP-3621"];
newly_started(suite) ->
[];
newly_started(Config) when is_list(Config) ->
- ?line true = is_alive(),
- ?line {ok, Node} = test_server:start_node(slave1, slave, []),
- ?line [] = rpc:call(Node, dets, all, []),
- ?line test_server:stop_node(Node),
+ true = is_alive(),
+ {ok, Node} = test_server:start_node(slave1, slave, []),
+ [] = rpc:call(Node, dets, all, []),
+ test_server:stop_node(Node),
ok.
basic_v8(doc) ->
@@ -162,31 +153,31 @@ basic_v9(Config) when is_list(Config) ->
basic(Config, 9).
basic(Config, Version) ->
- ?line Tab = dets_basic_test,
- ?line FName = filename(Tab, Config),
+ Tab = dets_basic_test,
+ FName = filename(Tab, Config),
P0 = pps(),
- ?line {ok, _} = dets:open_file(Tab,[{file, FName},{version,Version}]),
- ?line ok = dets:insert(Tab,{mazda,japan}),
- ?line ok = dets:insert(Tab,{toyota,japan}),
- ?line ok = dets:insert(Tab,{suzuki,japan}),
- ?line ok = dets:insert(Tab,{honda,japan}),
- ?line ok = dets:insert(Tab,{renault,france}),
- ?line ok = dets:insert(Tab,{citroen,france}),
- ?line ok = dets:insert(Tab,{opel,germany}),
- ?line ok = dets:insert(Tab,{saab,sweden}),
- ?line ok = dets:insert(Tab,{volvo,sweden}),
- ?line [{opel,germany}] = dets:lookup(Tab,opel),
- ?line Japs = dets:traverse(Tab, fun(Obj) ->
- case Obj of
- {_, japan} -> {continue, Obj};
- _ -> continue
- end
- end),
- ?line 4 = length(Japs),
- ?line ok = dets:close(Tab),
- ?line file:delete(FName),
- ?line check_pps(P0),
+ {ok, _} = dets:open_file(Tab,[{file, FName},{version,Version}]),
+ ok = dets:insert(Tab,{mazda,japan}),
+ ok = dets:insert(Tab,{toyota,japan}),
+ ok = dets:insert(Tab,{suzuki,japan}),
+ ok = dets:insert(Tab,{honda,japan}),
+ ok = dets:insert(Tab,{renault,france}),
+ ok = dets:insert(Tab,{citroen,france}),
+ ok = dets:insert(Tab,{opel,germany}),
+ ok = dets:insert(Tab,{saab,sweden}),
+ ok = dets:insert(Tab,{volvo,sweden}),
+ [{opel,germany}] = dets:lookup(Tab,opel),
+ Japs = dets:traverse(Tab, fun(Obj) ->
+ case Obj of
+ {_, japan} -> {continue, Obj};
+ _ -> continue
+ end
+ end),
+ 4 = length(Japs),
+ ok = dets:close(Tab),
+ file:delete(FName),
+ check_pps(P0),
ok.
@@ -210,24 +201,24 @@ open(Config, Version) ->
%% If this becomes a problem, one should consider running this
%% test on a slave node.
- ?line {Sets, Bags, Dups} = args(Config),
+ {Sets, Bags, Dups} = args(Config),
- ?line All = Sets ++ Bags ++ Dups,
- ?line delete_files(All),
+ All = Sets ++ Bags ++ Dups,
+ delete_files(All),
- ?line Data = make_data(1),
+ Data = make_data(1),
P0 = pps(),
- ?line Tabs = open_files(1, All, Version),
- ?line initialize(Tabs, Data),
- ?line check(Tabs, Data),
+ Tabs = open_files(1, All, Version),
+ initialize(Tabs, Data),
+ check(Tabs, Data),
- ?line foreach(fun(Tab) -> ok = dets:close(Tab) end, Tabs),
+ foreach(fun(Tab) -> ok = dets:close(Tab) end, Tabs),
%% Now reopen the files
?format("Reopening closed files \n", []),
- ?line Tabs = open_files(1, All, Version),
+ Tabs = open_files(1, All, Version),
?format("Checking contents of reopened files \n", []),
- ?line check(Tabs, Data),
+ check(Tabs, Data),
%% crash the dets server
?format("Crashing dets server \n", []),
@@ -241,25 +232,25 @@ open(Config, Version) ->
%% Now reopen the files again
?format("Reopening crashed files \n", []),
- ?line open_files(1, All, Version),
+ open_files(1, All, Version),
?format("Checking contents of repaired files \n", []),
- ?line check(Tabs, Data),
+ check(Tabs, Data),
- ?line close_all(Tabs),
+ close_all(Tabs),
- ?line delete_files(All),
+ delete_files(All),
P1 = pps(),
{Ports0, Procs0} = P0,
{Ports1, Procs1} = P1,
- ?line true = Ports1 =:= Ports0,
+ true = Ports1 =:= Ports0,
%% The dets_server process has been restarted:
- ?line [_] = Procs0 -- Procs1,
- ?line [_] = Procs1 -- Procs0,
+ [_] = Procs0 -- Procs1,
+ [_] = Procs1 -- Procs0,
ok.
check(Tabs, Data) ->
foreach(fun(Tab) ->
- ?line Kp = dets:info(Tab, keypos),
+ Kp = dets:info(Tab, keypos),
?format("checking ~p~n", [Tab]),
foreach(fun(Item) ->
case dets:lookup(Tab, k(Kp,Item)) of
@@ -291,31 +282,31 @@ sets_v9(Config) when is_list(Config) ->
sets(Config, 9).
sets(Config, Version) ->
- ?line {Sets, _, _} = args(Config),
+ {Sets, _, _} = args(Config),
- ?line Data = make_data(1),
- ?line delete_files(Sets),
+ Data = make_data(1),
+ delete_files(Sets),
P0 = pps(),
- ?line Tabs = open_files(1, Sets, Version),
+ Tabs = open_files(1, Sets, Version),
Bigger = [{17,q,w,w}, {48,q,w,w,w,w,w,w}], % 48 requires a bigger buddy
- ?line initialize(Tabs, Data++Bigger++Data), % overwrite
- ?line Len = length(Data),
- ?line foreach(fun(Tab) -> trav_test(Data, Len, Tab) end, Tabs),
- ?line size_test(Len, Tabs),
- ?line no_keys_test(Tabs),
- ?line foreach(fun(Tab) -> del_test(Tab) end, Tabs),
- ?line initialize(Tabs, Data),
- ?line foreach(fun(Tab) -> del_obj_test(Tab) end, Tabs),
- ?line initialize(Tabs, Data),
- ?line foreach(fun(Tab) ->
- Len = dets:info(Tab, size) end,
- Tabs),
- ?line foreach(fun(Tab) -> match_test(Data, Tab) end, Tabs),
- ?line foreach(fun(Tab) -> match_del_test(Tab) end, Tabs),
+ initialize(Tabs, Data++Bigger++Data), % overwrite
+ Len = length(Data),
+ foreach(fun(Tab) -> trav_test(Data, Len, Tab) end, Tabs),
+ size_test(Len, Tabs),
+ no_keys_test(Tabs),
+ foreach(fun(Tab) -> del_test(Tab) end, Tabs),
+ initialize(Tabs, Data),
+ foreach(fun(Tab) -> del_obj_test(Tab) end, Tabs),
+ initialize(Tabs, Data),
+ foreach(fun(Tab) ->
+ Len = dets:info(Tab, size) end,
+ Tabs),
+ foreach(fun(Tab) -> match_test(Data, Tab) end, Tabs),
+ foreach(fun(Tab) -> match_del_test(Tab) end, Tabs),
- ?line close_all(Tabs),
- ?line delete_files(Sets),
- ?line check_pps(P0),
+ close_all(Tabs),
+ delete_files(Sets),
+ check_pps(P0),
ok.
bags_v8(doc) ->
@@ -334,27 +325,27 @@ bags_v9(Config) when is_list(Config) ->
bags(Config, Version) ->
{_, Bags, _} = args(Config),
- ?line Data = make_data(1, bag), %% gives twice as many objects
- ?line delete_files(Bags),
+ Data = make_data(1, bag), %% gives twice as many objects
+ delete_files(Bags),
P0 = pps(),
- ?line Tabs = open_files(1, Bags, Version),
- ?line initialize(Tabs, Data++Data),
- ?line Len = length(Data),
- ?line foreach(fun(Tab) -> trav_test(Data, Len, Tab) end, Tabs),
- ?line size_test(Len, Tabs),
- ?line no_keys_test(Tabs),
- ?line foreach(fun(Tab) -> del_test(Tab) end, Tabs),
- ?line initialize(Tabs, Data),
- ?line foreach(fun(Tab) -> del_obj_test(Tab) end, Tabs),
- ?line initialize(Tabs, Data),
- ?line foreach(fun(Tab) ->
- Len = dets:info(Tab, size) end,
- Tabs),
- ?line foreach(fun(Tab) -> match_test(Data, Tab) end, Tabs),
- ?line foreach(fun(Tab) -> match_del_test(Tab) end, Tabs),
- ?line close_all(Tabs),
- ?line delete_files(Bags),
- ?line check_pps(P0),
+ Tabs = open_files(1, Bags, Version),
+ initialize(Tabs, Data++Data),
+ Len = length(Data),
+ foreach(fun(Tab) -> trav_test(Data, Len, Tab) end, Tabs),
+ size_test(Len, Tabs),
+ no_keys_test(Tabs),
+ foreach(fun(Tab) -> del_test(Tab) end, Tabs),
+ initialize(Tabs, Data),
+ foreach(fun(Tab) -> del_obj_test(Tab) end, Tabs),
+ initialize(Tabs, Data),
+ foreach(fun(Tab) ->
+ Len = dets:info(Tab, size) end,
+ Tabs),
+ foreach(fun(Tab) -> match_test(Data, Tab) end, Tabs),
+ foreach(fun(Tab) -> match_del_test(Tab) end, Tabs),
+ close_all(Tabs),
+ delete_files(Bags),
+ check_pps(P0),
ok.
@@ -374,27 +365,27 @@ duplicate_bags_v9(Config) when is_list(Config) ->
duplicate_bags(Config, Version) when is_list(Config) ->
{_, _, Dups} = args(Config),
- ?line Data = make_data(1, duplicate_bag), %% gives twice as many objects
- ?line delete_files(Dups),
+ Data = make_data(1, duplicate_bag), %% gives twice as many objects
+ delete_files(Dups),
P0 = pps(),
- ?line Tabs = open_files(1, Dups, Version),
- ?line initialize(Tabs, Data),
- ?line Len = length(Data),
- ?line foreach(fun(Tab) -> trav_test(Data, Len, Tab) end, Tabs),
- ?line size_test(Len, Tabs),
- ?line no_keys_test(Tabs),
- ?line foreach(fun(Tab) -> del_test(Tab) end, Tabs),
- ?line initialize(Tabs, Data),
- ?line foreach(fun(Tab) -> del_obj_test(Tab) end, Tabs),
- ?line initialize(Tabs, Data),
- ?line foreach(fun(Tab) ->
- Len = dets:info(Tab, size) end,
- Tabs),
- ?line foreach(fun(Tab) -> match_test(Data, Tab) end, Tabs),
- ?line foreach(fun(Tab) -> match_del_test(Tab) end, Tabs),
- ?line close_all(Tabs),
- ?line delete_files(Dups),
- ?line check_pps(P0),
+ Tabs = open_files(1, Dups, Version),
+ initialize(Tabs, Data),
+ Len = length(Data),
+ foreach(fun(Tab) -> trav_test(Data, Len, Tab) end, Tabs),
+ size_test(Len, Tabs),
+ no_keys_test(Tabs),
+ foreach(fun(Tab) -> del_test(Tab) end, Tabs),
+ initialize(Tabs, Data),
+ foreach(fun(Tab) -> del_obj_test(Tab) end, Tabs),
+ initialize(Tabs, Data),
+ foreach(fun(Tab) ->
+ Len = dets:info(Tab, size) end,
+ Tabs),
+ foreach(fun(Tab) -> match_test(Data, Tab) end, Tabs),
+ foreach(fun(Tab) -> match_del_test(Tab) end, Tabs),
+ close_all(Tabs),
+ delete_files(Dups),
+ check_pps(P0),
ok.
@@ -418,26 +409,26 @@ access(Config, Version) ->
Args = [[{ram_file, true}],
[]],
- ?line {Args_acc_1, _, _} = zip_filename(Args_acc, [], [], Config),
- ?line delete_files(Args_acc_1),
- ?line {Args_1, _, _} = zip_filename(Args, [], [], Config),
+ {Args_acc_1, _, _} = zip_filename(Args_acc, [], [], Config),
+ delete_files(Args_acc_1),
+ {Args_1, _, _} = zip_filename(Args, [], [], Config),
P0 = pps(),
- ?line {error, {file_error,_,enoent}} = dets:open_file('1', hd(Args_acc_1)),
-
- ?line Tabs = open_files(1, Args_1, Version),
- ?line close_all(Tabs),
- ?line Tabs = open_files(1, Args_acc_1, Version),
-
- ?line foreach(fun(Tab) ->
- {error, {access_mode,_}} = dets:insert(Tab, {1,2}),
- [] = dets:lookup(Tab, 11),
- '$end_of_table' = dets:first(Tab),
- {error, {access_mode,_}} = dets:delete(Tab, 22)
- end, Tabs),
- ?line close_all(Tabs),
- ?line delete_files(Args_acc_1),
- ?line check_pps(P0),
+ {error, {file_error,_,enoent}} = dets:open_file('1', hd(Args_acc_1)),
+
+ Tabs = open_files(1, Args_1, Version),
+ close_all(Tabs),
+ Tabs = open_files(1, Args_acc_1, Version),
+
+ foreach(fun(Tab) ->
+ {error, {access_mode,_}} = dets:insert(Tab, {1,2}),
+ [] = dets:lookup(Tab, 11),
+ '$end_of_table' = dets:first(Tab),
+ {error, {access_mode,_}} = dets:delete(Tab, 22)
+ end, Tabs),
+ close_all(Tabs),
+ delete_files(Args_acc_1),
+ check_pps(P0),
ok.
@@ -446,23 +437,23 @@ dirty_mark(doc) ->
dirty_mark(suite) ->
[];
dirty_mark(Config) when is_list(Config) ->
- ?line true = is_alive(),
- ?line Tab = dets_dirty_mark_test,
- ?line FName = filename(Tab, Config),
+ true = is_alive(),
+ Tab = dets_dirty_mark_test,
+ FName = filename(Tab, Config),
P0 = pps(),
- ?line dets:open_file(Tab,[{file, FName}]),
- ?line dets:insert(Tab,{mazda,japan}),
- ?line dets:insert(Tab,{toyota,japan}),
- ?line dets:insert(Tab,{suzuki,japan}),
- ?line dets:insert(Tab,{honda,japan}),
- ?line dets:insert(Tab,{renault,france}),
- ?line dets:insert(Tab,{citroen,france}),
- ?line dets:insert(Tab,{opel,germany}),
- ?line dets:insert(Tab,{saab,sweden}),
- ?line dets:insert(Tab,{volvo,sweden}),
- ?line [{opel,germany}] = dets:lookup(Tab,opel),
- ?line ok = dets:close(Tab),
- ?line Call = fun(P,A) ->
+ dets:open_file(Tab,[{file, FName}]),
+ dets:insert(Tab,{mazda,japan}),
+ dets:insert(Tab,{toyota,japan}),
+ dets:insert(Tab,{suzuki,japan}),
+ dets:insert(Tab,{honda,japan}),
+ dets:insert(Tab,{renault,france}),
+ dets:insert(Tab,{citroen,france}),
+ dets:insert(Tab,{opel,germany}),
+ dets:insert(Tab,{saab,sweden}),
+ dets:insert(Tab,{volvo,sweden}),
+ [{opel,germany}] = dets:lookup(Tab,opel),
+ ok = dets:close(Tab),
+ Call = fun(P,A) ->
P ! {self(), A},
receive
{P, Ans} ->
@@ -471,26 +462,26 @@ dirty_mark(Config) when is_list(Config) ->
exit(other_process_dead)
end
end,
- ?line {ok, Node} = test_server:start_node(dets_dirty_mark,
- slave,
- [{linked, false},
- {args, "-pa " ++
- filename:dirname
+ {ok, Node} = test_server:start_node(dets_dirty_mark,
+ slave,
+ [{linked, false},
+ {args, "-pa " ++
+ filename:dirname
(code:which(?MODULE))}]),
- ?line ok = ensure_node(20, Node),
+ ok = ensure_node(20, Node),
%% io:format("~p~n",[rpc:call(Node, code, get_path, [])]),
%% io:format("~p~n",[rpc:call(Node, file, get_cwd, [])]),
%% io:format("~p~n",[Config]),
- ?line Pid = rpc:call(Node,erlang, spawn,
+ Pid = rpc:call(Node,erlang, spawn,
[?MODULE, dets_dirty_loop, []]),
- ?line {ok, Tab} = Call(Pid, [open, Tab, [{file, FName}]]),
- ?line [{opel,germany}] = Call(Pid, [read,Tab,opel]),
- ?line test_server:stop_node(Node),
- ?line {ok, Tab} = dets:open_file(Tab,[{file, FName},
- {repair,false}]),
- ?line ok = dets:close(Tab),
- ?line file:delete(FName),
- ?line check_pps(P0),
+ {ok, Tab} = Call(Pid, [open, Tab, [{file, FName}]]),
+ [{opel,germany}] = Call(Pid, [read,Tab,opel]),
+ test_server:stop_node(Node),
+ {ok, Tab} = dets:open_file(Tab,[{file, FName},
+ {repair,false}]),
+ ok = dets:close(Tab),
+ file:delete(FName),
+ check_pps(P0),
ok.
dirty_mark2(doc) ->
@@ -498,22 +489,22 @@ dirty_mark2(doc) ->
dirty_mark2(suite) ->
[];
dirty_mark2(Config) when is_list(Config) ->
- ?line true = is_alive(),
- ?line Tab = dets_dirty_mark2_test,
- ?line FName = filename(Tab, Config),
+ true = is_alive(),
+ Tab = dets_dirty_mark2_test,
+ FName = filename(Tab, Config),
P0 = pps(),
- ?line dets:open_file(Tab,[{file, FName}]),
- ?line dets:insert(Tab,{toyota,japan}),
- ?line dets:insert(Tab,{suzuki,japan}),
- ?line dets:insert(Tab,{honda,japan}),
- ?line dets:insert(Tab,{renault,france}),
- ?line dets:insert(Tab,{citroen,france}),
- ?line dets:insert(Tab,{opel,germany}),
- ?line dets:insert(Tab,{saab,sweden}),
- ?line dets:insert(Tab,{volvo,sweden}),
- ?line [{opel,germany}] = dets:lookup(Tab,opel),
- ?line ok = dets:close(Tab),
- ?line Call = fun(P,A) ->
+ dets:open_file(Tab,[{file, FName}]),
+ dets:insert(Tab,{toyota,japan}),
+ dets:insert(Tab,{suzuki,japan}),
+ dets:insert(Tab,{honda,japan}),
+ dets:insert(Tab,{renault,france}),
+ dets:insert(Tab,{citroen,france}),
+ dets:insert(Tab,{opel,germany}),
+ dets:insert(Tab,{saab,sweden}),
+ dets:insert(Tab,{volvo,sweden}),
+ [{opel,germany}] = dets:lookup(Tab,opel),
+ ok = dets:close(Tab),
+ Call = fun(P,A) ->
P ! {self(), A},
receive
{P, Ans} ->
@@ -522,25 +513,25 @@ dirty_mark2(Config) when is_list(Config) ->
exit(other_process_dead)
end
end,
- ?line {ok, Node} = test_server:start_node(dets_dirty_mark2,
- slave,
- [{linked, false},
- {args, "-pa " ++
- filename:dirname
+ {ok, Node} = test_server:start_node(dets_dirty_mark2,
+ slave,
+ [{linked, false},
+ {args, "-pa " ++
+ filename:dirname
(code:which(?MODULE))}]),
- ?line ok = ensure_node(20, Node),
- ?line Pid = rpc:call(Node,erlang, spawn,
- [?MODULE, dets_dirty_loop, []]),
- ?line {ok, Tab} = Call(Pid, [open, Tab, [{file, FName},{auto_save,1000}]]),
- ?line ok = Call(Pid, [write,Tab,{mazda,japan}]),
- ?line timer:sleep(2100),
+ ok = ensure_node(20, Node),
+ Pid = rpc:call(Node,erlang, spawn,
+ [?MODULE, dets_dirty_loop, []]),
+ {ok, Tab} = Call(Pid, [open, Tab, [{file, FName},{auto_save,1000}]]),
+ ok = Call(Pid, [write,Tab,{mazda,japan}]),
+ timer:sleep(2100),
%% Read something, just to give auto save time to finish.
- ?line [{opel,germany}] = Call(Pid, [read,Tab,opel]),
- ?line test_server:stop_node(Node),
- ?line {ok, Tab} = dets:open_file(Tab, [{file, FName}, {repair,false}]),
- ?line ok = dets:close(Tab),
- ?line file:delete(FName),
- ?line check_pps(P0),
+ [{opel,germany}] = Call(Pid, [read,Tab,opel]),
+ test_server:stop_node(Node),
+ {ok, Tab} = dets:open_file(Tab, [{file, FName}, {repair,false}]),
+ ok = dets:close(Tab),
+ file:delete(FName),
+ check_pps(P0),
ok.
dets_dirty_loop() ->
@@ -576,38 +567,38 @@ bag_next_v9(suite) ->
bag_next_v9(doc) ->
["Check that bags and next work as expected."];
bag_next_v9(Config) when is_list(Config) ->
- ?line Tab = dets_bag_next_test,
- ?line FName = filename(Tab, Config),
+ Tab = dets_bag_next_test,
+ FName = filename(Tab, Config),
%% first and next crash upon error
- ?line dets:open_file(Tab,[{file, FName}, {type, bag},{version,9}]),
- ?line ok = dets:insert(Tab, [{1,1},{2,2},{3,3},{4,4}]),
- ?line FirstKey = dets:first(Tab),
- ?line NextKey = dets:next(Tab, FirstKey),
- ?line [FirstObj | _] = dets:lookup(Tab, FirstKey),
- ?line [NextObj | _] = dets:lookup(Tab, NextKey),
- ?line {ok, FirstPos} = dets:where(Tab, FirstObj),
- ?line {ok, NextPos} = dets:where(Tab, NextObj),
+ dets:open_file(Tab,[{file, FName}, {type, bag},{version,9}]),
+ ok = dets:insert(Tab, [{1,1},{2,2},{3,3},{4,4}]),
+ FirstKey = dets:first(Tab),
+ NextKey = dets:next(Tab, FirstKey),
+ [FirstObj | _] = dets:lookup(Tab, FirstKey),
+ [NextObj | _] = dets:lookup(Tab, NextKey),
+ {ok, FirstPos} = dets:where(Tab, FirstObj),
+ {ok, NextPos} = dets:where(Tab, NextObj),
crash(FName, NextPos+12),
- ?line {'EXIT',BadObject1} = (catch dets:next(Tab, FirstKey)),
- ?line bad_object(BadObject1, FName),
+ {'EXIT',BadObject1} = (catch dets:next(Tab, FirstKey)),
+ bad_object(BadObject1, FName),
crash(FName, FirstPos+12),
- ?line {'EXIT',BadObject2} = (catch dets:first(Tab)),
- ?line bad_object(BadObject2, FName),
- ?line dets:close(Tab),
- ?line file:delete(FName),
+ {'EXIT',BadObject2} = (catch dets:first(Tab)),
+ bad_object(BadObject2, FName),
+ dets:close(Tab),
+ file:delete(FName),
bag_next(Config, 9).
bag_next(Config, Version) ->
- ?line Tab = dets_bag_next_test,
- ?line FName = filename(Tab, Config),
+ Tab = dets_bag_next_test,
+ FName = filename(Tab, Config),
P0 = pps(),
- ?line dets:open_file(Tab,[{file, FName}, {type, bag},{version,Version}]),
- ?line dets:insert(Tab,{698,hopp}),
- ?line dets:insert(Tab,{186,hopp}),
- ?line dets:insert(Tab,{hej,hopp}),
- ?line dets:insert(Tab,{186,plopp}),
+ dets:open_file(Tab,[{file, FName}, {type, bag},{version,Version}]),
+ dets:insert(Tab,{698,hopp}),
+ dets:insert(Tab,{186,hopp}),
+ dets:insert(Tab,{hej,hopp}),
+ dets:insert(Tab,{186,plopp}),
Loop = fun(N, Last, Self) ->
case N of
0 ->
@@ -621,10 +612,10 @@ bag_next(Config, Version) ->
end
end
end,
- ?line ok = Loop(4,dets:first(Tab),Loop),
- ?line dets:close(Tab),
- ?line file:delete(FName),
- ?line check_pps(P0),
+ ok = Loop(4,dets:first(Tab),Loop),
+ dets:close(Tab),
+ file:delete(FName),
+ check_pps(P0),
ok.
oldbugs_v8(doc) ->
@@ -644,15 +635,15 @@ oldbugs_v9(Config) when is_list(Config) ->
oldbugs(Config, Version) ->
FName = filename(dets_suite_oldbugs_test, Config),
P0 = pps(),
- ?line {ok, ob} = dets:open_file(ob, [{version, Version},
+ {ok, ob} = dets:open_file(ob, [{version, Version},
{type, bag}, {file, FName}]),
- ?line ok = dets:insert(ob, {1, 2}),
- ?line ok = dets:insert(ob, {1,3}),
- ?line ok = dets:insert(ob, {1, 2}),
- ?line 2 = dets:info(ob, size), %% assertion
- ?line ok = dets:close(ob),
- ?line file:delete(FName),
- ?line check_pps(P0),
+ ok = dets:insert(ob, {1, 2}),
+ ok = dets:insert(ob, {1,3}),
+ ok = dets:insert(ob, {1, 2}),
+ 2 = dets:info(ob, size), %% assertion
+ ok = dets:close(ob),
+ file:delete(FName),
+ check_pps(P0),
ok.
unsafe_assumptions(suite) -> [];
@@ -660,30 +651,30 @@ unsafe_assumptions(doc) ->
"Tests that shrinking an object and then expanding it works.";
unsafe_assumptions(Config) when is_list(Config) ->
FName = filename(dets_suite_unsafe_assumptions_test, Config),
- ?line file:delete(FName),
+ file:delete(FName),
P0 = pps(),
- ?line {ok, a} = dets:open_file(a, [{version,8},{file, FName}]),
+ {ok, a} = dets:open_file(a, [{version,8},{file, FName}]),
O0 = {2,false},
O1 = {1, false},
O2 = {1, true},
O3 = {1, duplicate(20,false)},
O4 = {1, duplicate(25,false)}, % same 2-log as O3
- ?line ok = dets:insert(a, O1),
- ?line ok = dets:insert(a, O0),
- ?line true = [O1,O0] =:= sort(get_all_objects(a)),
- ?line true = [O1,O0] =:= sort(get_all_objects_fast(a)),
- ?line ok = dets:insert(a, O2),
- ?line true = [O2,O0] =:= sort(get_all_objects(a)),
- ?line true = [O2,O0] =:= sort(get_all_objects_fast(a)),
- ?line ok = dets:insert(a, O3),
- ?line true = [O3,O0] =:= sort(get_all_objects(a)),
- ?line true = [O3,O0] =:= sort(get_all_objects_fast(a)),
- ?line ok = dets:insert(a, O4),
- ?line true = [O4,O0] =:= sort(get_all_objects(a)),
- ?line true = [O4,O0] =:= sort(get_all_objects_fast(a)),
- ?line ok = dets:close(a),
- ?line file:delete(FName),
- ?line check_pps(P0),
+ ok = dets:insert(a, O1),
+ ok = dets:insert(a, O0),
+ true = [O1,O0] =:= sort(get_all_objects(a)),
+ true = [O1,O0] =:= sort(get_all_objects_fast(a)),
+ ok = dets:insert(a, O2),
+ true = [O2,O0] =:= sort(get_all_objects(a)),
+ true = [O2,O0] =:= sort(get_all_objects_fast(a)),
+ ok = dets:insert(a, O3),
+ true = [O3,O0] =:= sort(get_all_objects(a)),
+ true = [O3,O0] =:= sort(get_all_objects_fast(a)),
+ ok = dets:insert(a, O4),
+ true = [O4,O0] =:= sort(get_all_objects(a)),
+ true = [O4,O0] =:= sort(get_all_objects_fast(a)),
+ ok = dets:close(a),
+ file:delete(FName),
+ check_pps(P0),
ok.
truncated_segment_array_v8(suite) -> [];
@@ -704,22 +695,22 @@ trunc_seg_array(Config, V) ->
TabRef = dets_suite_truncated_segment_array_test,
Fname = filename(TabRef, Config),
%% Create file that needs to be repaired
- ?line file:delete(Fname),
+ file:delete(Fname),
P0 = pps(),
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file, Fname},{version,V}]),
- ?line ok = dets:close(TabRef),
+ {ok, TabRef} = dets:open_file(TabRef, [{file, Fname},{version,V}]),
+ ok = dets:close(TabRef),
%% Truncate the file
- ?line HeadSize = headsz(V),
- ?line truncate(Fname, HeadSize + 10),
+ HeadSize = headsz(V),
+ truncate(Fname, HeadSize + 10),
%% Open the truncated file
- ?line io:format("Expect repair:~n"),
- ?line {ok, TabRef} = dets:open_file(TabRef,
+ io:format("Expect repair:~n"),
+ {ok, TabRef} = dets:open_file(TabRef,
[{file, Fname}, {repair, true}]),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
- ?line check_pps(P0),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
+ check_pps(P0),
ok.
open_file_v8(doc) ->
@@ -736,58 +727,58 @@ open_file_v9(suite) ->
open_file_v9(Config) when is_list(Config) ->
T = open_v9,
Fname = filename(T, Config),
- ?line {ok, _} = dets:open_file(T, [{file,Fname},{version,9}]),
- ?line 9 = dets:info(T, version),
- ?line true = [self()] =:= dets:info(T, users),
- ?line {ok, _} = dets:open_file(T, [{file,Fname},{version,9}]),
- ?line {error,incompatible_arguments} =
+ {ok, _} = dets:open_file(T, [{file,Fname},{version,9}]),
+ 9 = dets:info(T, version),
+ true = [self()] =:= dets:info(T, users),
+ {ok, _} = dets:open_file(T, [{file,Fname},{version,9}]),
+ {error,incompatible_arguments} =
dets:open_file(T, [{file,Fname},{version,8}]),
- ?line true = [self(),self()] =:= dets:info(T, users),
- ?line ok = dets:close(T),
- ?line true = [self()] =:= dets:info(T, users),
- ?line ok = dets:close(T),
- ?line undefined = ets:info(T, users),
- ?line file:delete(Fname),
+ true = [self(),self()] =:= dets:info(T, users),
+ ok = dets:close(T),
+ true = [self()] =:= dets:info(T, users),
+ ok = dets:close(T),
+ undefined = ets:info(T, users),
+ file:delete(Fname),
open_1(Config, 9).
open_1(Config, V) ->
TabRef = open_file_1_test,
Fname = filename(TabRef, Config),
- ?line file:delete(Fname),
+ file:delete(Fname),
P0 = pps(),
- ?line {error,{file_error,Fname,enoent}} = dets:open_file(Fname),
+ {error,{file_error,Fname,enoent}} = dets:open_file(Fname),
- ?line ok = file:write_file(Fname, duplicate(100,65)),
- ?line {error,{not_a_dets_file,Fname}} = dets:open_file(Fname),
- ?line file:delete(Fname),
+ ok = file:write_file(Fname, duplicate(100,65)),
+ {error,{not_a_dets_file,Fname}} = dets:open_file(Fname),
+ file:delete(Fname),
HeadSize = headsz(V),
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file, Fname},{version,V}]),
- ?line ok = dets:close(TabRef),
- ?line truncate(Fname, HeadSize + 10),
- ?line true = dets:is_dets_file(Fname),
- ?line io:format("Expect repair:~n"),
- ?line {ok, Ref} = dets:open_file(Fname), % repairing
- ?line ok = dets:close(Ref),
- ?line file:delete(Fname),
+ {ok, TabRef} = dets:open_file(TabRef, [{file, Fname},{version,V}]),
+ ok = dets:close(TabRef),
+ truncate(Fname, HeadSize + 10),
+ true = dets:is_dets_file(Fname),
+ io:format("Expect repair:~n"),
+ {ok, Ref} = dets:open_file(Fname), % repairing
+ ok = dets:close(Ref),
+ file:delete(Fname),
%% truncated file header, invalid type
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line ok = ins(TabRef, 3000),
- ?line ok = dets:close(TabRef),
+ {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
+ ok = ins(TabRef, 3000),
+ ok = dets:close(TabRef),
TypePos = 12,
crash(Fname, TypePos),
- ?line {error, {invalid_type_code,Fname}} = dets:open_file(Fname),
- ?line truncate(Fname, HeadSize - 10),
- ?line {error, {tooshort,Fname}} = dets:open_file(Fname),
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
-
- ?line {error,{file_error,{foo,bar},_}} = dets:is_dets_file({foo,bar}),
- ?line check_pps(P0),
+ {error, {invalid_type_code,Fname}} = dets:open_file(Fname),
+ truncate(Fname, HeadSize - 10),
+ {error, {tooshort,Fname}} = dets:open_file(Fname),
+ {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
+
+ {error,{file_error,{foo,bar},_}} = dets:is_dets_file({foo,bar}),
+ check_pps(P0),
ok.
init_table_v8(doc) ->
@@ -805,16 +796,16 @@ init_table_v9(Config) when is_list(Config) ->
%% Objects are returned in "time order".
T = init_table_v9,
Fname = filename(T, Config),
- ?line file:delete(Fname),
+ file:delete(Fname),
L = [{1,a},{2,b},{1,c},{2,c},{1,c},{2,a},{1,b}],
Input = init([L]),
- ?line {ok, _} = dets:open_file(T, [{file,Fname},{version,9},
+ {ok, _} = dets:open_file(T, [{file,Fname},{version,9},
{type,duplicate_bag}]),
- ?line ok = dets:init_table(T, Input),
- ?line [{1,a},{1,c},{1,c},{1,b}] = dets:lookup(T, 1),
- ?line [{2,b},{2,c},{2,a}] = dets:lookup(T, 2),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
+ ok = dets:init_table(T, Input),
+ [{1,a},{1,c},{1,c},{1,b}] = dets:lookup(T, 1),
+ [{2,b},{2,c},{2,a}] = dets:lookup(T, 2),
+ ok = dets:close(T),
+ file:delete(Fname),
init_table(Config, 9),
fast_init_table(Config).
@@ -822,57 +813,57 @@ init_table_v9(Config) when is_list(Config) ->
init_table(Config, V) ->
TabRef = init_table_test,
Fname = filename(TabRef, Config),
- ?line file:delete(Fname),
+ file:delete(Fname),
P0 = pps(),
Args = [{file,Fname},{version,V},{auto_save,120000}],
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {'EXIT', _} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {'EXIT', _} =
(catch dets:init_table(TabRef, fun(foo) -> bar end)),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {'EXIT', _} = (catch dets:init_table(TabRef, fun() -> foo end)),
+ {ok, _} = dets:open_file(TabRef, Args),
+ {'EXIT', _} = (catch dets:init_table(TabRef, fun() -> foo end)),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {'EXIT', {badarg, _}} = (catch dets:init_table(TabRef, nofun)),
- ?line {'EXIT', {badarg, _}} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {'EXIT', {badarg, _}} = (catch dets:init_table(TabRef, nofun)),
+ {'EXIT', {badarg, _}} =
(catch dets:init_table(TabRef, fun(_X) -> end_of_input end,
[{foo,bar}])),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line away = (catch dets:init_table(TabRef, fun(_) -> throw(away) end)),
+ {ok, _} = dets:open_file(TabRef, Args),
+ away = (catch dets:init_table(TabRef, fun(_) -> throw(away) end)),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {error, {init_fun, fopp}} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {error, {init_fun, fopp}} =
dets:init_table(TabRef, fun(read) -> fopp end),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line dets:safe_fixtable(TabRef, true),
- ?line {error, {fixed_table, TabRef}} = dets:init_table(TabRef, init([])),
- ?line dets:safe_fixtable(TabRef, false),
- ?line ET = ets:new(foo,[]),
- ?line ok = dets:from_ets(TabRef, ET),
- ?line [] = get_all_objects(TabRef),
- ?line [] = get_all_objects_fast(TabRef),
- ?line true = ets:insert(ET, {1,a}),
- ?line true = ets:insert(ET, {2,b}),
- ?line ok = dets:from_ets(TabRef, ET),
- ?line [{1,a},{2,b}] = sort(get_all_objects(TabRef)),
- ?line [{1,a},{2,b}] = sort(get_all_objects_fast(TabRef)),
- ?line true = ets:delete(ET),
- ?line 120000 = dets:info(TabRef, auto_save),
- ?line ok = dets:close(TabRef),
-
- ?line {ok, _} = dets:open_file(TabRef, [{access,read} | Args]),
- ?line {error, {access_mode, Fname}} = dets:init_table(TabRef, init([])),
- ?line ok = dets:close(TabRef),
-
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {error, invalid_objects_list} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ dets:safe_fixtable(TabRef, true),
+ {error, {fixed_table, TabRef}} = dets:init_table(TabRef, init([])),
+ dets:safe_fixtable(TabRef, false),
+ ET = ets:new(foo,[]),
+ ok = dets:from_ets(TabRef, ET),
+ [] = get_all_objects(TabRef),
+ [] = get_all_objects_fast(TabRef),
+ true = ets:insert(ET, {1,a}),
+ true = ets:insert(ET, {2,b}),
+ ok = dets:from_ets(TabRef, ET),
+ [{1,a},{2,b}] = sort(get_all_objects(TabRef)),
+ [{1,a},{2,b}] = sort(get_all_objects_fast(TabRef)),
+ true = ets:delete(ET),
+ 120000 = dets:info(TabRef, auto_save),
+ ok = dets:close(TabRef),
+
+ {ok, _} = dets:open_file(TabRef, [{access,read} | Args]),
+ {error, {access_mode, Fname}} = dets:init_table(TabRef, init([])),
+ ok = dets:close(TabRef),
+
+ {ok, _} = dets:open_file(TabRef, Args),
+ {error, invalid_objects_list} =
(catch dets:init_table(TabRef, init([[{1,2},bad,{3,4}]]))),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
L1 = [[{1,a},{2,b}],[],[{3,c}],[{4,d}],[]],
bulk_init(L1, set, 4, Config, V),
@@ -885,28 +876,28 @@ init_table(Config, V) ->
file:delete(Fname),
%% Initiate a file that contains a lot of objects.
- ?line {ok, _} = dets:open_file(TabRef, [{min_no_slots,10000} | Args]),
- ?line ok = ins(TabRef, 6000),
+ {ok, _} = dets:open_file(TabRef, [{min_no_slots,10000} | Args]),
+ ok = ins(TabRef, 6000),
Fun = init_fun(0, 10000),
- ?line ok = dets:init_table(TabRef, Fun,{format,term}),
- ?line All = sort(get_all_objects(TabRef)),
- ?line FAll = get_all_objects_fast(TabRef),
- ?line true = All =:= sort(FAll),
- ?line true = length(All) =:= 10000,
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
-
- ?line {ok, _} = dets:open_file(TabRef, [{min_no_slots,4000} | Args]),
- ?line ok = ins(TabRef, 6000),
- ?line FileSize1 = dets:info(TabRef, file_size),
+ ok = dets:init_table(TabRef, Fun,{format,term}),
+ All = sort(get_all_objects(TabRef)),
+ FAll = get_all_objects_fast(TabRef),
+ true = All =:= sort(FAll),
+ true = length(All) =:= 10000,
+ ok = dets:close(TabRef),
+ file:delete(Fname),
+
+ {ok, _} = dets:open_file(TabRef, [{min_no_slots,4000} | Args]),
+ ok = ins(TabRef, 6000),
+ FileSize1 = dets:info(TabRef, file_size),
Fun2 = init_fun(0, 4000),
- ?line ok = dets:init_table(TabRef, Fun2),
- ?line FileSize2 = dets:info(TabRef, file_size),
- ?line ok = dets:close(TabRef),
- ?line true = FileSize1 > FileSize2,
- ?line file:delete(Fname),
+ ok = dets:init_table(TabRef, Fun2),
+ FileSize2 = dets:info(TabRef, file_size),
+ ok = dets:close(TabRef),
+ true = FileSize1 > FileSize2,
+ file:delete(Fname),
- ?line check_pps(P0),
+ check_pps(P0),
ok.
bulk_init(Ls, Type, N, Config, V) ->
@@ -915,26 +906,26 @@ bulk_init(Ls, Type, N, Config, V) ->
bulk_init(Ls, Type, N, Est, Config, V) ->
T = init_table_test,
Fname = filename(T, Config),
- ?line file:delete(Fname),
+ file:delete(Fname),
Input = init(Ls),
Args = [{ram_file,false}, {type,Type},{keypos,1},{file,Fname},
{estimated_no_objects, Est},{version,V}],
- ?line {ok, T} = dets:open_file(T, Args),
- ?line ok = dets:init_table(T, Input),
- ?line All = sort(get_all_objects(T)),
- ?line FAll = get_all_objects_fast(T),
- ?line true = All =:= sort(FAll),
- ?line true = length(All) =:= N,
- ?line true = dets:info(T, size) =:= N,
- ?line ok = dets:close(T),
+ {ok, T} = dets:open_file(T, Args),
+ ok = dets:init_table(T, Input),
+ All = sort(get_all_objects(T)),
+ FAll = get_all_objects_fast(T),
+ true = All =:= sort(FAll),
+ true = length(All) =:= N,
+ true = dets:info(T, size) =:= N,
+ ok = dets:close(T),
- ?line {ok, T} = dets:open_file(T, Args),
- ?line All2 = sort(get_all_objects(T)),
- ?line FAll2 = get_all_objects_fast(T),
- ?line true = All =:= All2,
- ?line true = All =:= sort(FAll2),
- ?line ok = dets:close(T),
- ?line file:delete(Fname).
+ {ok, T} = dets:open_file(T, Args),
+ All2 = sort(get_all_objects(T)),
+ FAll2 = get_all_objects_fast(T),
+ true = All =:= All2,
+ true = All =:= sort(FAll2),
+ ok = dets:close(T),
+ file:delete(Fname).
init(L) ->
fun(close) ->
@@ -960,130 +951,130 @@ fast_init_table(Config) ->
V = 9,
TabRef = init_table_test,
Fname = filename(TabRef, Config),
- ?line file:delete(Fname),
+ file:delete(Fname),
P0 = pps(),
Args = [{file,Fname},{version,V},{auto_save,120000}],
Source = init_table_test_source,
SourceFname = filename(Source, Config),
- ?line file:delete(SourceFname),
+ file:delete(SourceFname),
SourceArgs = [{file,SourceFname},{version,V},{auto_save,120000}],
- ?line {ok, Source} = dets:open_file(Source, SourceArgs),
+ {ok, Source} = dets:open_file(Source, SourceArgs),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {'EXIT', _} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {'EXIT', _} =
(catch dets:init_table(TabRef, fun(foo) -> bar end, {format,bchunk})),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {'EXIT', _} = (catch dets:init_table(TabRef, fun() -> foo end,
+ {ok, _} = dets:open_file(TabRef, Args),
+ {'EXIT', _} = (catch dets:init_table(TabRef, fun() -> foo end,
{format,bchunk})),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {'EXIT', {badarg, _}} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {'EXIT', {badarg, _}} =
(catch dets:init_table(TabRef, nofun, {format,bchunk})),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line away = (catch dets:init_table(TabRef, fun(_) -> throw(away) end,
+ {ok, _} = dets:open_file(TabRef, Args),
+ away = (catch dets:init_table(TabRef, fun(_) -> throw(away) end,
{format,bchunk})),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {error, {init_fun, fopp}} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {error, {init_fun, fopp}} =
dets:init_table(TabRef, fun(read) -> fopp end, {format,bchunk}),
dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line dets:safe_fixtable(TabRef, true),
- ?line {error, {fixed_table, TabRef}} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ dets:safe_fixtable(TabRef, true),
+ {error, {fixed_table, TabRef}} =
dets:init_table(TabRef, init([]), {format,bchunk}),
- ?line dets:safe_fixtable(TabRef, false),
- ?line ok = dets:close(TabRef),
+ dets:safe_fixtable(TabRef, false),
+ ok = dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, [{access,read} | Args]),
- ?line {error, {access_mode, Fname}} =
+ {ok, _} = dets:open_file(TabRef, [{access,read} | Args]),
+ {error, {access_mode, Fname}} =
dets:init_table(TabRef, init([]), {format,bchunk}),
- ?line ok = dets:close(TabRef),
+ ok = dets:close(TabRef),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {error, {init_fun,{1,2}}} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {error, {init_fun,{1,2}}} =
dets:init_table(TabRef, init([[{1,2},bad,{3,4}]]), {format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {error, {init_fun, end_of_input}} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {error, {init_fun, end_of_input}} =
dets:init_table(TabRef, init([]),{format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line {'EXIT', {badarg, _}} =
+ {ok, _} = dets:open_file(TabRef, Args),
+ {'EXIT', {badarg, _}} =
(catch dets:init_table(TabRef, init([]),{format,foppla})),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line ok = ins(TabRef, 100),
+ {ok, _} = dets:open_file(TabRef, Args),
+ ok = ins(TabRef, 100),
- ?line [BParms | Objs] = collect_bchunk(TabRef, init_bchunk(TabRef)),
- ?line Parms = binary_to_term(BParms),
- ?line {error, {init_fun, <<"foobar">>}} =
+ [BParms | Objs] = collect_bchunk(TabRef, init_bchunk(TabRef)),
+ Parms = binary_to_term(BParms),
+ {error, {init_fun, <<"foobar">>}} =
dets:init_table(TabRef, init([[<<"foobar">>]]),{format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line Parms1 = setelement(1, Parms, foobar),
+ {ok, _} = dets:open_file(TabRef, Args),
+ Parms1 = setelement(1, Parms, foobar),
BParms1 = term_to_binary(Parms1),
- ?line {error, {init_fun, BParms1}} =
+ {error, {init_fun, BParms1}} =
dets:init_table(TabRef, init([[BParms1 | Objs]]),{format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(TabRef, Args),
+ {ok, _} = dets:open_file(TabRef, Args),
[{Sz1,No1} | NoColls17] = element(tuple_size(Parms), Parms),
Parms2 = setelement(tuple_size(Parms), Parms, [{Sz1,No1+1} | NoColls17]),
BParms2 = term_to_binary(Parms2),
- ?line {error, invalid_objects_list} =
+ {error, invalid_objects_list} =
dets:init_table(TabRef, init([[BParms2 | Objs]]),{format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line [{LSize1,Slot1,Obj1} | ObjsRest] = Objs,
+ {ok, _} = dets:open_file(TabRef, Args),
+ [{LSize1,Slot1,Obj1} | ObjsRest] = Objs,
- ?line BadSize = byte_size(Obj1)-1,
- ?line <<BadSizeObj:BadSize/binary,_:1/binary>> = Obj1,
- ?line BadObjs = [{LSize1,Slot1,BadSizeObj} | ObjsRest],
- ?line {error, invalid_objects_list} =
+ BadSize = byte_size(Obj1)-1,
+ <<BadSizeObj:BadSize/binary,_:1/binary>> = Obj1,
+ BadObjs = [{LSize1,Slot1,BadSizeObj} | ObjsRest],
+ {error, invalid_objects_list} =
dets:init_table(TabRef, init([[BParms | BadObjs]]),{format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
-
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line <<Size:32,BigObj0/binary>> = list_to_binary(lists:duplicate(16,Obj1)),
- ?line BigObj = <<(Size*16):32,BigObj0/binary>>,
- ?line BadColl = [BParms, {LSize1+4,Slot1,BigObj} | ObjsRest],
- ?line {error, invalid_objects_list} =
+ _ = dets:close(TabRef),
+ file:delete(Fname),
+
+ {ok, _} = dets:open_file(TabRef, Args),
+ <<Size:32,BigObj0/binary>> = list_to_binary(lists:duplicate(16,Obj1)),
+ BigObj = <<(Size*16):32,BigObj0/binary>>,
+ BadColl = [BParms, {LSize1+4,Slot1,BigObj} | ObjsRest],
+ {error, invalid_objects_list} =
dets:init_table(TabRef, init([BadColl]),{format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(TabRef, Args),
+ {ok, _} = dets:open_file(TabRef, Args),
BadObj = <<"foobar">>,
- ?line {error, invalid_objects_list} =
+ {error, invalid_objects_list} =
dets:init_table(TabRef, init([[BParms, BadObj]]),{format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(TabRef, [{type,bag} | Args]),
- ?line {error, {init_fun, _}} =
+ {ok, _} = dets:open_file(TabRef, [{type,bag} | Args]),
+ {error, {init_fun, _}} =
dets:init_table(TabRef, init([[BParms]]),{format,bchunk}),
- ?line _ = dets:close(TabRef),
- ?line file:delete(Fname),
+ _ = dets:close(TabRef),
+ file:delete(Fname),
- ?line ok = dets:close(Source),
- ?line file:delete(SourceFname),
+ ok = dets:close(Source),
+ file:delete(SourceFname),
L1 = [{1,a},{2,b},{3,c},{4,d}],
fast_bulk_init(L1, set, 4, 4, Config, V),
@@ -1096,91 +1087,91 @@ fast_init_table(Config) ->
file:delete(Fname),
%% Initiate a file that contains a lot of objects.
- ?line {ok, _} = dets:open_file(Source, [{min_no_slots,10000} | SourceArgs]),
+ {ok, _} = dets:open_file(Source, [{min_no_slots,10000} | SourceArgs]),
Fun1 = init_fun(0, 10000),
- ?line ok = dets:init_table(Source, Fun1, {format,term}),
+ ok = dets:init_table(Source, Fun1, {format,term}),
- ?line {ok, _} = dets:open_file(TabRef, [{min_no_slots,10000} | Args]),
- ?line ok = ins(TabRef, 6000),
+ {ok, _} = dets:open_file(TabRef, [{min_no_slots,10000} | Args]),
+ ok = ins(TabRef, 6000),
Fun2 = init_bchunk(Source),
- ?line true =
+ true =
dets:is_compatible_bchunk_format(TabRef,
dets:info(Source, bchunk_format)),
- ?line false = dets:is_compatible_bchunk_format(TabRef, <<"foobar">>),
- ?line ok = dets:init_table(TabRef, Fun2, {format, bchunk}),
- ?line ok = dets:close(Source),
- ?line file:delete(SourceFname),
- ?line All = sort(get_all_objects(TabRef)),
- ?line FAll = get_all_objects_fast(TabRef),
- ?line true = All =:= sort(FAll),
- ?line true = length(All) =:= 10000,
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ false = dets:is_compatible_bchunk_format(TabRef, <<"foobar">>),
+ ok = dets:init_table(TabRef, Fun2, {format, bchunk}),
+ ok = dets:close(Source),
+ file:delete(SourceFname),
+ All = sort(get_all_objects(TabRef)),
+ FAll = get_all_objects_fast(TabRef),
+ true = All =:= sort(FAll),
+ true = length(All) =:= 10000,
+ ok = dets:close(TabRef),
+ file:delete(Fname),
%% Initiate inserts fewer objects than the table contains.
- ?line {ok, _} = dets:open_file(Source, [{min_no_slots,1000} | SourceArgs]),
- ?line ok = ins(Source, 4000),
+ {ok, _} = dets:open_file(Source, [{min_no_slots,1000} | SourceArgs]),
+ ok = ins(Source, 4000),
- ?line {ok, _} = dets:open_file(TabRef, [{min_no_slots,1000} | Args]),
- ?line ok = ins(TabRef, 6000),
- ?line FileSize1 = dets:info(TabRef, file_size),
+ {ok, _} = dets:open_file(TabRef, [{min_no_slots,1000} | Args]),
+ ok = ins(TabRef, 6000),
+ FileSize1 = dets:info(TabRef, file_size),
Fun4 = init_bchunk(Source),
- ?line ok = dets:init_table(TabRef, Fun4, {format, bchunk}),
- ?line ok = dets:close(Source),
- ?line file:delete(SourceFname),
- ?line FileSize2 = dets:info(TabRef, file_size),
- ?line All_2 = sort(get_all_objects(TabRef)),
- ?line FAll_2 = get_all_objects_fast(TabRef),
- ?line true = All_2 =:= sort(FAll_2),
- ?line true = length(All_2) =:= 4000,
- ?line ok = dets:close(TabRef),
- ?line true = FileSize1 > FileSize2,
+ ok = dets:init_table(TabRef, Fun4, {format, bchunk}),
+ ok = dets:close(Source),
+ file:delete(SourceFname),
+ FileSize2 = dets:info(TabRef, file_size),
+ All_2 = sort(get_all_objects(TabRef)),
+ FAll_2 = get_all_objects_fast(TabRef),
+ true = All_2 =:= sort(FAll_2),
+ true = length(All_2) =:= 4000,
+ ok = dets:close(TabRef),
+ true = FileSize1 > FileSize2,
%% Bchunk and fixed table.
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line NoItems = dets:info(TabRef, no_objects),
- ?line AllObjects1 = sort(get_all_objects_fast(TabRef)),
- ?line dets:safe_fixtable(TabRef, true),
- ?line true = dets:info(TabRef, fixed),
- ?line Cont1 = init_bchunk(TabRef),
- ?line NoDel =
+ {ok, _} = dets:open_file(TabRef, Args),
+ NoItems = dets:info(TabRef, no_objects),
+ AllObjects1 = sort(get_all_objects_fast(TabRef)),
+ dets:safe_fixtable(TabRef, true),
+ true = dets:info(TabRef, fixed),
+ Cont1 = init_bchunk(TabRef),
+ NoDel =
dets:select_delete(TabRef, [{{'_',{item,'_','_'}},[],[true]}]),
- ?line true = (NoDel > 0),
- ?line AllObjects2 = sort(get_all_objects_fast(TabRef)),
- ?line true = dets:info(TabRef, fixed),
- ?line Cont2 = init_bchunk(TabRef),
- ?line NoItems2 = dets:info(TabRef, no_objects),
- ?line true = (NoItems =:= NoItems2 + NoDel),
- ?line NoDel2 = dets:select_delete(TabRef, [{'_',[],[true]}]),
- ?line true = (NoDel2 > 0),
- ?line AllObjects3 = sort(get_all_objects_fast(TabRef)),
- ?line NoItems3 = dets:info(TabRef, no_objects),
- ?line true = (NoItems3 =:= 0),
- ?line true = dets:info(TabRef, fixed),
- ?line true = (NoItems2 =:= NoItems3 + NoDel2),
- ?line Cont3 = init_bchunk(TabRef),
-
- ?line BinColl1 = collect_bchunk(TabRef, Cont1),
- ?line BinColl2 = collect_bchunk(TabRef, Cont2),
- ?line BinColl3 = collect_bchunk(TabRef, Cont3),
- ?line dets:safe_fixtable(TabRef, false),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ true = (NoDel > 0),
+ AllObjects2 = sort(get_all_objects_fast(TabRef)),
+ true = dets:info(TabRef, fixed),
+ Cont2 = init_bchunk(TabRef),
+ NoItems2 = dets:info(TabRef, no_objects),
+ true = (NoItems =:= NoItems2 + NoDel),
+ NoDel2 = dets:select_delete(TabRef, [{'_',[],[true]}]),
+ true = (NoDel2 > 0),
+ AllObjects3 = sort(get_all_objects_fast(TabRef)),
+ NoItems3 = dets:info(TabRef, no_objects),
+ true = (NoItems3 =:= 0),
+ true = dets:info(TabRef, fixed),
+ true = (NoItems2 =:= NoItems3 + NoDel2),
+ Cont3 = init_bchunk(TabRef),
+
+ BinColl1 = collect_bchunk(TabRef, Cont1),
+ BinColl2 = collect_bchunk(TabRef, Cont2),
+ BinColl3 = collect_bchunk(TabRef, Cont3),
+ dets:safe_fixtable(TabRef, false),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
%% Now check that the above collected binaries are correct.
- ?line {ok, _} = dets:open_file(TabRef, Args),
- ?line ok = dets:init_table(TabRef, init([BinColl1]),{format,bchunk}),
- ?line true = (AllObjects1 =:= sort(get_all_objects_fast(TabRef))),
- ?line true = (length(AllObjects1) =:= dets:info(TabRef, no_objects)),
- ?line ok = dets:init_table(TabRef, init([BinColl2]),{format,bchunk}),
- ?line true = (AllObjects2 =:= sort(get_all_objects_fast(TabRef))),
- ?line true = (length(AllObjects2) =:= dets:info(TabRef, no_objects)),
- ?line ok = dets:init_table(TabRef, init([BinColl3]),{format,bchunk}),
- ?line true = (AllObjects3 =:= sort(get_all_objects_fast(TabRef))),
- ?line true = (length(AllObjects3) =:= dets:info(TabRef, no_objects)),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
- ?line check_pps(P0),
+ {ok, _} = dets:open_file(TabRef, Args),
+ ok = dets:init_table(TabRef, init([BinColl1]),{format,bchunk}),
+ true = (AllObjects1 =:= sort(get_all_objects_fast(TabRef))),
+ true = (length(AllObjects1) =:= dets:info(TabRef, no_objects)),
+ ok = dets:init_table(TabRef, init([BinColl2]),{format,bchunk}),
+ true = (AllObjects2 =:= sort(get_all_objects_fast(TabRef))),
+ true = (length(AllObjects2) =:= dets:info(TabRef, no_objects)),
+ ok = dets:init_table(TabRef, init([BinColl3]),{format,bchunk}),
+ true = (AllObjects3 =:= sort(get_all_objects_fast(TabRef))),
+ true = (length(AllObjects3) =:= dets:info(TabRef, no_objects)),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
+ check_pps(P0),
ok.
fast_bulk_init(L, Type, N, NoKeys, Config, V) ->
@@ -1189,40 +1180,40 @@ fast_bulk_init(L, Type, N, NoKeys, Config, V) ->
fast_bulk_init(L, Type, N, NoKeys, Est, Config, V) ->
T = init_table_test,
Fname = filename(T, Config),
- ?line file:delete(Fname),
+ file:delete(Fname),
Args0 = [{ram_file,false}, {type,Type},{keypos,1},
{estimated_no_objects, Est},{version,V}],
Args = [{file,Fname} | Args0],
S = init_table_test_source,
SFname = filename(S, Config),
- ?line file:delete(SFname),
+ file:delete(SFname),
SArgs = [{file,SFname} | Args0],
- ?line {ok, S} = dets:open_file(S, SArgs),
- ?line ok = dets:insert(S, L),
+ {ok, S} = dets:open_file(S, SArgs),
+ ok = dets:insert(S, L),
Input = init_bchunk(S),
- ?line {ok, T} = dets:open_file(T, Args),
- ?line ok = dets:init_table(T, Input, [{format,bchunk}]),
- ?line All = sort(get_all_objects(T)),
- ?line FAll = get_all_objects_fast(T),
- ?line true = All =:= sort(FAll),
- ?line true = length(All) =:= N,
- ?line true = dets:info(T, size) =:= N,
- ?line true = dets:info(T, no_keys) =:= NoKeys,
- ?line ok = dets:close(T),
+ {ok, T} = dets:open_file(T, Args),
+ ok = dets:init_table(T, Input, [{format,bchunk}]),
+ All = sort(get_all_objects(T)),
+ FAll = get_all_objects_fast(T),
+ true = All =:= sort(FAll),
+ true = length(All) =:= N,
+ true = dets:info(T, size) =:= N,
+ true = dets:info(T, no_keys) =:= NoKeys,
+ ok = dets:close(T),
- ?line {ok, T} = dets:open_file(T, Args),
- ?line All2 = sort(get_all_objects(T)),
- ?line FAll2 = get_all_objects_fast(T),
- ?line true = All =:= All2,
- ?line true = All =:= sort(FAll2),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
-
- ?line ok = dets:close(S),
- ?line file:delete(SFname),
+ {ok, T} = dets:open_file(T, Args),
+ All2 = sort(get_all_objects(T)),
+ FAll2 = get_all_objects_fast(T),
+ true = All =:= All2,
+ true = All =:= sort(FAll2),
+ ok = dets:close(T),
+ file:delete(Fname),
+
+ ok = dets:close(S),
+ file:delete(SFname),
ok.
init_bchunk(T) ->
@@ -1274,94 +1265,94 @@ repair_v9(Config) when is_list(Config) ->
%% Convert from format 9 to format 8.
T = convert_98,
Fname = filename(T, Config),
- ?line file:delete(Fname),
- ?line {ok, _} = dets:open_file(T, [{file,Fname},{version,9},
+ file:delete(Fname),
+ {ok, _} = dets:open_file(T, [{file,Fname},{version,9},
{type,duplicate_bag}]),
- ?line 9 = dets:info(T, version),
- ?line true = is_binary(dets:info(T, bchunk_format)),
- ?line ok = dets:insert(T, [{1,a},{2,b},{1,c},{2,c},{1,c},{2,a},{1,b}]),
- ?line dets:close(T),
- ?line {error, {version_mismatch, _}} =
+ 9 = dets:info(T, version),
+ true = is_binary(dets:info(T, bchunk_format)),
+ ok = dets:insert(T, [{1,a},{2,b},{1,c},{2,c},{1,c},{2,a},{1,b}]),
+ dets:close(T),
+ {error, {version_mismatch, _}} =
dets:open_file(T, [{file,Fname},{version,8},{type,duplicate_bag}]),
- ?line {ok, _} = dets:open_file(T, [{file,Fname},{version,8},
+ {ok, _} = dets:open_file(T, [{file,Fname},{version,8},
{type,duplicate_bag},{repair,force}]),
- ?line 8 = dets:info(T, version),
- ?line true = undefined =:= dets:info(T, bchunk_format),
- ?line [{1,a},{1,b},{1,c},{1,c}] = sort(dets:lookup(T, 1)),
- ?line [{2,a},{2,b},{2,c}] = sort(dets:lookup(T, 2)),
- ?line 7 = dets:info(T, no_objects),
- ?line no_keys_test(T),
- ?line _ = histogram(T, silent),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
+ 8 = dets:info(T, version),
+ true = undefined =:= dets:info(T, bchunk_format),
+ [{1,a},{1,b},{1,c},{1,c}] = sort(dets:lookup(T, 1)),
+ [{2,a},{2,b},{2,c}] = sort(dets:lookup(T, 2)),
+ 7 = dets:info(T, no_objects),
+ no_keys_test(T),
+ _ = histogram(T, silent),
+ ok = dets:close(T),
+ file:delete(Fname),
%% The short lived format 9(a).
%% Not very throughly tested here.
A9 = a9,
- ?line Version9aS = filename:join(?datadir(Config), "version_9a.dets"),
- ?line Version9aT = filename('v9a.dets', Config),
- ?line {ok, _} = file:copy(Version9aS, Version9aT),
- ?line {ok, A9} = dets:open_file(A9, [{file,Version9aT}]),
- ?line undefined = dets:info(A9, bchunk_format),
- ?line [{1,a},{2,b},{3,c}] = sort(dets:match_object(A9, '_')),
- ?line ok = dets:insert(A9, {4,d}),
- ?line ok = dets:close(A9),
- ?line {ok, A9} = dets:open_file(A9, [{file,Version9aT}]),
- ?line {error, old_version} = dets:bchunk(A9, start),
- ?line ok = dets:close(A9),
- ?line io:format("Expect forced repair:~n"),
- ?line {ok, A9} = dets:open_file(A9, [{file,Version9aT},{repair,force}]),
- ?line {_, _} = dets:bchunk(A9, start),
- ?line ok = dets:close(A9),
- ?line file:delete(Version9aT),
+ Version9aS = filename:join(?datadir(Config), "version_9a.dets"),
+ Version9aT = filename('v9a.dets', Config),
+ {ok, _} = file:copy(Version9aS, Version9aT),
+ {ok, A9} = dets:open_file(A9, [{file,Version9aT}]),
+ undefined = dets:info(A9, bchunk_format),
+ [{1,a},{2,b},{3,c}] = sort(dets:match_object(A9, '_')),
+ ok = dets:insert(A9, {4,d}),
+ ok = dets:close(A9),
+ {ok, A9} = dets:open_file(A9, [{file,Version9aT}]),
+ {error, old_version} = dets:bchunk(A9, start),
+ ok = dets:close(A9),
+ io:format("Expect forced repair:~n"),
+ {ok, A9} = dets:open_file(A9, [{file,Version9aT},{repair,force}]),
+ {_, _} = dets:bchunk(A9, start),
+ ok = dets:close(A9),
+ file:delete(Version9aT),
repair(Config, 9).
repair(Config, V) ->
TabRef = repair_test,
Fname = filename(TabRef, Config),
- ?line file:delete(Fname),
+ file:delete(Fname),
HeadSize = headsz(V),
P0 = pps(),
- ?line {'EXIT', {badarg, _}} =
+ {'EXIT', {badarg, _}} =
(catch dets:open_file(TabRef, [{min_no_slots,1000},
{max_no_slots,500}])),
- ?line {error,{file_error,hoppla,enoent}} = dets:file_info(hoppla),
- ?line {error,{file_error,Fname,enoent}} =
+ {error,{file_error,hoppla,enoent}} = dets:file_info(hoppla),
+ {error,{file_error,Fname,enoent}} =
dets:open_file(TabRef, [{file, Fname}, {access, read}]),
%% compacting, and some kind of test that free lists are saved OK on file
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line 0 = dets:info(TabRef, size),
- ?line ok = ins(TabRef, 30000),
- ?line ok = del(TabRef, 30000, 3),
- ?line ok = dets:close(TabRef),
- ?line {error, {access_mode,Fname}} =
+ {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
+ 0 = dets:info(TabRef, size),
+ ok = ins(TabRef, 30000),
+ ok = del(TabRef, 30000, 3),
+ ok = dets:close(TabRef),
+ {error, {access_mode,Fname}} =
dets:open_file(foo, [{file,Fname},{repair,force},{access,read}]),
- ?line {ok, Ref3} = dets:open_file(Fname), % no repair!
- ?line 20000 = dets:info(Ref3, size),
- ?line 20000 = dets:foldl(fun(_, N) -> N+1 end, 0, Ref3),
- ?line 20000 = count_objects_quite_fast(Ref3), % actually a test of match
- ?line no_keys_test(Ref3),
- ?line ok = dets:close(Ref3),
+ {ok, Ref3} = dets:open_file(Fname), % no repair!
+ 20000 = dets:info(Ref3, size),
+ 20000 = dets:foldl(fun(_, N) -> N+1 end, 0, Ref3),
+ 20000 = count_objects_quite_fast(Ref3), % actually a test of match
+ no_keys_test(Ref3),
+ ok = dets:close(Ref3),
if
V =:= 8 ->
- ?line {ok, TabRef} = dets:open_file(TabRef,
+ {ok, TabRef} = dets:open_file(TabRef,
[{file, Fname},{version,V},{access,read}]),
- ?line ok = dets:close(TabRef),
- ?line io:format("Expect compacting repair:~n"),
- ?line {ok, TabRef} = dets:open_file(TabRef,
+ ok = dets:close(TabRef),
+ io:format("Expect compacting repair:~n"),
+ {ok, TabRef} = dets:open_file(TabRef,
[{file, Fname},{version,V}]),
- ?line 20000 = dets:info(TabRef, size),
- ?line _ = histogram(TabRef, silent),
- ?line ok = dets:close(TabRef);
+ 20000 = dets:info(TabRef, size),
+ _ = histogram(TabRef, silent),
+ ok = dets:close(TabRef);
true ->
ok
end,
- ?line {error,{keypos_mismatch,Fname}} =
+ {error,{keypos_mismatch,Fname}} =
dets:open_file(TabRef, [{file, Fname},{keypos,17}]),
- ?line {error,{type_mismatch,Fname}} =
+ {error,{type_mismatch,Fname}} =
dets:open_file(TabRef, [{file, Fname},{type,duplicate_bag}]),
%% make one of the temporary files unwritable
@@ -1370,257 +1361,257 @@ repair(Config, V) ->
Fname ++ ".TMP.10000";
true -> Fname ++ ".TMP.1"
end,
- ?line file:delete(TmpFile),
- ?line {ok, TmpFd} = file:open(TmpFile, [read,write]),
- ?line ok = file:close(TmpFd),
- ?line unwritable(TmpFile),
- ?line {error,{file_error,TmpFile,eacces}} = dets:fsck(Fname, V),
- ?line {ok, _} = dets:open_file(TabRef,
- [{repair,false},{file, Fname},{version,V}]),
- ?line 20000 = length(get_all_objects(TabRef)),
- ?line _ = histogram(TabRef, silent),
- ?line 20000 = length(get_all_objects_fast(TabRef)),
- ?line ok = dets:close(TabRef),
- ?line writable(TmpFile),
- ?line file:delete(TmpFile),
-
- ?line truncate(Fname, HeadSize + 10),
- ?line {error,{not_closed, Fname}} =
+ file:delete(TmpFile),
+ {ok, TmpFd} = file:open(TmpFile, [read,write]),
+ ok = file:close(TmpFd),
+ unwritable(TmpFile),
+ {error,{file_error,TmpFile,eacces}} = dets:fsck(Fname, V),
+ {ok, _} = dets:open_file(TabRef,
+ [{repair,false},{file, Fname},{version,V}]),
+ 20000 = length(get_all_objects(TabRef)),
+ _ = histogram(TabRef, silent),
+ 20000 = length(get_all_objects_fast(TabRef)),
+ ok = dets:close(TabRef),
+ writable(TmpFile),
+ file:delete(TmpFile),
+
+ truncate(Fname, HeadSize + 10),
+ {error,{not_closed, Fname}} =
dets:open_file(TabRef, [{file, Fname}, {access, read}]),
- ?line {error,{not_closed, Fname}} =
+ {error,{not_closed, Fname}} =
dets:open_file(TabRef, [{file, Fname}, {access, read},
{repair,force}]),
- ?line {error,{needs_repair, Fname}} =
+ {error,{needs_repair, Fname}} =
dets:open_file(TabRef, [{file, Fname}, {repair, false}]),
- ?line file:delete(Fname),
+ file:delete(Fname),
%% truncated file header
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line ok = ins(TabRef, 100),
- ?line ok = dets:close(TabRef),
- ?line truncate(Fname, HeadSize - 10),
+ {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
+ ok = ins(TabRef, 100),
+ ok = dets:close(TabRef),
+ truncate(Fname, HeadSize - 10),
%% a new file is created ('tooshort')
- ?line {ok, TabRef} = dets:open_file(TabRef,
- [{file,Fname},{version,V},
- {min_no_slots,1000},
- {max_no_slots,1000000}]),
+ {ok, TabRef} = dets:open_file(TabRef,
+ [{file,Fname},{version,V},
+ {min_no_slots,1000},
+ {max_no_slots,1000000}]),
case dets:info(TabRef, no_slots) of
undefined -> ok;
{Min1,Slot1,Max1} ->
- ?line true = Min1 =< Slot1, true = Slot1 =< Max1,
- ?line true = 1000 < Min1, true = 1000+256 > Min1,
- ?line true = 1000000 < Max1, true = (1 bsl 20)+256 > Max1
+ true = Min1 =< Slot1, true = Slot1 =< Max1,
+ true = 1000 < Min1, true = 1000+256 > Min1,
+ true = 1000000 < Max1, true = (1 bsl 20)+256 > Max1
end,
- ?line 0 = dets:info(TabRef, size),
- ?line no_keys_test(TabRef),
- ?line _ = histogram(TabRef, silent),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ 0 = dets:info(TabRef, size),
+ no_keys_test(TabRef),
+ _ = histogram(TabRef, silent),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
%% version bump (v8)
- ?line Version7S = filename:join(?datadir(Config), "version_r2d.dets"),
- ?line Version7T = filename('v2.dets', Config),
- ?line {ok, _} = file:copy(Version7S, Version7T),
- ?line {error,{version_bump, Version7T}} = dets:open_file(Version7T),
- ?line {error,{version_bump, Version7T}} =
+ Version7S = filename:join(?datadir(Config), "version_r2d.dets"),
+ Version7T = filename('v2.dets', Config),
+ {ok, _} = file:copy(Version7S, Version7T),
+ {error,{version_bump, Version7T}} = dets:open_file(Version7T),
+ {error,{version_bump, Version7T}} =
dets:open_file(Version7T, [{file,Version7T},{repair,false}]),
- ?line {error,{version_bump, Version7T}} =
+ {error,{version_bump, Version7T}} =
dets:open_file(Version7T, [{file, Version7T}, {access, read}]),
- ?line io:format("Expect upgrade:~n"),
- ?line {ok, _} = dets:open_file(Version7T,
+ io:format("Expect upgrade:~n"),
+ {ok, _} = dets:open_file(Version7T,
[{file, Version7T},{version, V}]),
- ?line [{1,a},{2,b}] = sort(get_all_objects(Version7T)),
- ?line [{1,a},{2,b}] = sort(get_all_objects_fast(Version7T)),
+ [{1,a},{2,b}] = sort(get_all_objects(Version7T)),
+ [{1,a},{2,b}] = sort(get_all_objects_fast(Version7T)),
Phash = if
V =:= 8 -> phash;
true -> phash2
end,
- ?line Phash = dets:info(Version7T, hash),
- ?line _ = histogram(Version7T, silent),
- ?line ok = dets:close(Version7T),
- ?line {ok, _} = dets:open_file(Version7T, [{file, Version7T}]),
- ?line Phash = dets:info(Version7T, hash),
- ?line ok = dets:close(Version7T),
- ?line file:delete(Version7T),
+ Phash = dets:info(Version7T, hash),
+ _ = histogram(Version7T, silent),
+ ok = dets:close(Version7T),
+ {ok, _} = dets:open_file(Version7T, [{file, Version7T}]),
+ Phash = dets:info(Version7T, hash),
+ ok = dets:close(Version7T),
+ file:delete(Version7T),
%% converting free lists
- ?line Version8aS = filename:join(?datadir(Config), "version_r3b02.dets"),
- ?line Version8aT = filename('v3.dets', Config),
- ?line {ok, _} = file:copy(Version8aS, Version8aT),
+ Version8aS = filename:join(?datadir(Config), "version_r3b02.dets"),
+ Version8aT = filename('v3.dets', Config),
+ {ok, _} = file:copy(Version8aS, Version8aT),
%% min_no_slots and max_no_slots are ignored - no repair is taking place
- ?line {ok, _} = dets:open_file(version_8a,
+ {ok, _} = dets:open_file(version_8a,
[{file, Version8aT},{min_no_slots,1000},
{max_no_slots,100000}]),
- ?line [{1,b},{2,a},{a,1},{b,2}] = sort(get_all_objects(version_8a)),
- ?line [{1,b},{2,a},{a,1},{b,2}] = sort(get_all_objects_fast(version_8a)),
- ?line ok = ins(version_8a, 1000),
- ?line 1002 = dets:info(version_8a, size),
- ?line no_keys_test(version_8a),
- ?line All8a = sort(get_all_objects(version_8a)),
- ?line 1002 = length(All8a),
- ?line FAll8a = sort(get_all_objects_fast(version_8a)),
- ?line true = sort(All8a) =:= sort(FAll8a),
- ?line ok = del(version_8a, 300, 3),
- ?line 902 = dets:info(version_8a, size),
- ?line no_keys_test(version_8a),
- ?line All8a2 = sort(get_all_objects(version_8a)),
- ?line 902 = length(All8a2),
- ?line FAll8a2 = sort(get_all_objects_fast(version_8a)),
- ?line true = sort(All8a2) =:= sort(FAll8a2),
- ?line _ = histogram(version_8a, silent),
- ?line ok = dets:close(version_8a),
- ?line file:delete(Version8aT),
+ [{1,b},{2,a},{a,1},{b,2}] = sort(get_all_objects(version_8a)),
+ [{1,b},{2,a},{a,1},{b,2}] = sort(get_all_objects_fast(version_8a)),
+ ok = ins(version_8a, 1000),
+ 1002 = dets:info(version_8a, size),
+ no_keys_test(version_8a),
+ All8a = sort(get_all_objects(version_8a)),
+ 1002 = length(All8a),
+ FAll8a = sort(get_all_objects_fast(version_8a)),
+ true = sort(All8a) =:= sort(FAll8a),
+ ok = del(version_8a, 300, 3),
+ 902 = dets:info(version_8a, size),
+ no_keys_test(version_8a),
+ All8a2 = sort(get_all_objects(version_8a)),
+ 902 = length(All8a2),
+ FAll8a2 = sort(get_all_objects_fast(version_8a)),
+ true = sort(All8a2) =:= sort(FAll8a2),
+ _ = histogram(version_8a, silent),
+ ok = dets:close(version_8a),
+ file:delete(Version8aT),
%% will fail unless the slots are properly sorted when repairing (v8)
BArgs = [{file, Fname},{type,duplicate_bag},
{delayed_write,{3000,10000}},{version,V}],
- ?line {ok, TabRef} = dets:open_file(TabRef, BArgs),
+ {ok, TabRef} = dets:open_file(TabRef, BArgs),
Seq = seq(1, 500),
Small = map(fun(X) -> {X,X} end, Seq),
Big = map(fun(X) -> erlang:make_tuple(20, X) end, Seq),
- ?line ok = dets:insert(TabRef, Small),
- ?line ok = dets:insert(TabRef, Big),
- ?line ok = dets:insert(TabRef, Small),
- ?line ok = dets:insert(TabRef, Big),
- ?line All = sort(safe_get_all_objects(TabRef)),
- ?line ok = dets:close(TabRef),
- ?line io:format("Expect forced repair:~n"),
- ?line {ok, _} =
+ ok = dets:insert(TabRef, Small),
+ ok = dets:insert(TabRef, Big),
+ ok = dets:insert(TabRef, Small),
+ ok = dets:insert(TabRef, Big),
+ All = sort(safe_get_all_objects(TabRef)),
+ ok = dets:close(TabRef),
+ io:format("Expect forced repair:~n"),
+ {ok, _} =
dets:open_file(TabRef, [{repair,force},{min_no_slots,2000} | BArgs]),
if
V =:= 9 ->
- ?line {MinNoSlots,_,MaxNoSlots} = dets:info(TabRef, no_slots),
- ?line ok = dets:close(TabRef),
- ?line io:format("Expect compaction:~n"),
- ?line {ok, _} =
+ {MinNoSlots,_,MaxNoSlots} = dets:info(TabRef, no_slots),
+ ok = dets:close(TabRef),
+ io:format("Expect compaction:~n"),
+ {ok, _} =
dets:open_file(TabRef, [{repair,force},
{min_no_slots,MinNoSlots},
{max_no_slots,MaxNoSlots} | BArgs]);
true ->
ok
end,
- ?line All2 = get_all_objects(TabRef),
- ?line true = All =:= sort(All2),
- ?line FAll2 = get_all_objects_fast(TabRef),
- ?line true = All =:= sort(FAll2),
- ?line true = length(All) =:= dets:info(TabRef, size),
- ?line no_keys_test(TabRef),
+ All2 = get_all_objects(TabRef),
+ true = All =:= sort(All2),
+ FAll2 = get_all_objects_fast(TabRef),
+ true = All =:= sort(FAll2),
+ true = length(All) =:= dets:info(TabRef, size),
+ no_keys_test(TabRef),
Fun = fun(X) -> 4 = length(dets:lookup(TabRef, X)) end,
- ?line foreach(Fun, Seq),
- ?line _ = histogram(TabRef, silent),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ foreach(Fun, Seq),
+ _ = histogram(TabRef, silent),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
%% object bigger than segments, the "hole" is taken care of
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file, Fname},{version,V}]),
+ {ok, TabRef} = dets:open_file(TabRef, [{file, Fname},{version,V}]),
Tuple = erlang:make_tuple(1000, foobar), % > 2 kB
- ?line ok = dets:insert(TabRef, Tuple),
+ ok = dets:insert(TabRef, Tuple),
%% at least one full segment (objects smaller than 2 kB):
- ?line ins(TabRef, 2000),
- ?line ok = dets:close(TabRef),
+ ins(TabRef, 2000),
+ ok = dets:close(TabRef),
if
V =:= 8 ->
%% first estimated number of objects is wrong, repair once more
- ?line {ok, Fd} = file:open(Fname, [read,write]),
+ {ok, Fd} = file:open(Fname, [read,write]),
NoPos = HeadSize - 8, % no_objects
- ?line file:pwrite(Fd, NoPos, <<0:32>>), % NoItems
+ file:pwrite(Fd, NoPos, <<0:32>>), % NoItems
ok = file:close(Fd),
- ?line dets:fsck(Fname, V),
- ?line {ok, _} =
+ dets:fsck(Fname, V),
+ {ok, _} =
dets:open_file(TabRef,
[{repair,false},{file, Fname},{version,V}]),
- ?line 2001 = length(get_all_objects(TabRef)),
- ?line _ = histogram(TabRef, silent),
- ?line 2001 = length(get_all_objects_fast(TabRef)),
- ?line ok = dets:close(TabRef);
+ 2001 = length(get_all_objects(TabRef)),
+ _ = histogram(TabRef, silent),
+ 2001 = length(get_all_objects_fast(TabRef)),
+ ok = dets:close(TabRef);
true ->
ok
end,
- ?line {ok, _} =
+ {ok, _} =
dets:open_file(TabRef,
[{repair,false},{file, Fname},{version,V}]),
- ?line {ok, ObjPos} = dets:where(TabRef, {66,{item,number,66}}),
- ?line ok = dets:close(TabRef),
+ {ok, ObjPos} = dets:where(TabRef, {66,{item,number,66}}),
+ ok = dets:close(TabRef),
%% Damaged object.
Pos = 12, % v9: compaction fails, proper repair follows
crash(Fname, ObjPos+Pos),
- ?line io:format(
+ io:format(
"Expect forced repair (possibly after attempted compaction):~n"),
- ?line {ok, _} =
+ {ok, _} =
dets:open_file(TabRef, [{repair,force},{file, Fname},{version,V}]),
- ?line true = dets:info(TabRef, size) < 2001,
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ true = dets:info(TabRef, size) < 2001,
+ ok = dets:close(TabRef),
+ file:delete(Fname),
%% The file is smaller than the padded object.
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line ok = dets:insert(TabRef, Tuple),
- ?line ok = dets:close(TabRef),
- ?line io:format("Expect forced repair or compaction:~n"),
- ?line {ok, _} =
+ {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
+ ok = dets:insert(TabRef, Tuple),
+ ok = dets:close(TabRef),
+ io:format("Expect forced repair or compaction:~n"),
+ {ok, _} =
dets:open_file(TabRef, [{repair,force},{file, Fname},{version,V}]),
- ?line true = 1 =:= dets:info(TabRef, size),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ true = 1 =:= dets:info(TabRef, size),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
%% Damaged free lists.
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line ok = ins(TabRef, 300),
- ?line ok = dets:sync(TabRef),
- ?line ok = del(TabRef, 300, 3),
+ {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
+ ok = ins(TabRef, 300),
+ ok = dets:sync(TabRef),
+ ok = del(TabRef, 300, 3),
%% FileSize is approximately where the free lists will be written.
- ?line FileSize = dets:info(TabRef, memory),
- ?line ok = dets:close(TabRef),
+ FileSize = dets:info(TabRef, memory),
+ ok = dets:close(TabRef),
crash(Fname, FileSize+20),
%% Used to return bad_freelists, but that changed in OTP-9622
- ?line {ok, TabRef} =
+ {ok, TabRef} =
dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
%% File not closed, opening with read and read_write access tried.
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line ok = ins(TabRef, 300),
- ?line ok = dets:close(TabRef),
- ?line crash(Fname, ?CLOSED_PROPERLY_POS+3, ?NOT_PROPERLY_CLOSED),
- ?line {error, {not_closed, Fname}} =
+ {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
+ ok = ins(TabRef, 300),
+ ok = dets:close(TabRef),
+ crash(Fname, ?CLOSED_PROPERLY_POS+3, ?NOT_PROPERLY_CLOSED),
+ {error, {not_closed, Fname}} =
dets:open_file(foo, [{file,Fname},{version,V},{repair,force},
{access,read}]),
- ?line {error, {not_closed, Fname}} =
+ {error, {not_closed, Fname}} =
dets:open_file(foo, [{file,Fname},{version,V},{repair,true},
{access,read}]),
- ?line io:format("Expect repair:~n"),
- ?line {ok, TabRef} =
+ io:format("Expect repair:~n"),
+ {ok, TabRef} =
dets:open_file(TabRef, [{file,Fname},{version,V},{repair,true},
{access,read_write}]),
- ?line ok = dets:close(TabRef),
- ?line crash(Fname, ?CLOSED_PROPERLY_POS+3, ?NOT_PROPERLY_CLOSED),
- ?line io:format("Expect forced repair:~n"),
- ?line {ok, TabRef} =
+ ok = dets:close(TabRef),
+ crash(Fname, ?CLOSED_PROPERLY_POS+3, ?NOT_PROPERLY_CLOSED),
+ io:format("Expect forced repair:~n"),
+ {ok, TabRef} =
dets:open_file(TabRef, [{file,Fname},{version,V},{repair,force},
{access,read_write}]),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
%% The size of an object is huge.
- ?line {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
- ?line ok = dets:insert(TabRef, [{1,2,3},{2,3,4}]),
- ?line {ok, ObjPos2} = dets:where(TabRef, {1,2,3}),
- ?line ok = dets:close(TabRef),
+ {ok, TabRef} = dets:open_file(TabRef, [{file,Fname},{version,V}]),
+ ok = dets:insert(TabRef, [{1,2,3},{2,3,4}]),
+ {ok, ObjPos2} = dets:where(TabRef, {1,2,3}),
+ ok = dets:close(TabRef),
ObjPos3 = if
V =:= 8 -> ObjPos2 + 4;
V =:= 9 -> ObjPos2
end,
crash(Fname, ObjPos3, 255),
- ?line io:format("Expect forced repair:~n"),
- ?line {ok, TabRef} =
+ io:format("Expect forced repair:~n"),
+ {ok, TabRef} =
dets:open_file(TabRef, [{file,Fname},{version,V},{repair,force}]),
- ?line ok = dets:close(TabRef),
- ?line file:delete(Fname),
+ ok = dets:close(TabRef),
+ file:delete(Fname),
- ?line check_pps(P0),
+ check_pps(P0),
ok.
hash_v8b_v8c(doc) ->
@@ -1629,77 +1620,77 @@ hash_v8b_v8c(doc) ->
hash_v8b_v8c(suite) ->
[];
hash_v8b_v8c(Config) when is_list(Config) ->
- ?line Source =
+ Source =
filename:join(?datadir(Config), "dets_test_v8b.dets"),
%% Little endian version of old file (there is an endianess bug in
%% the old hash). This is all about version 8 of the dets file format.
P0 = pps(),
- ?line SourceLE =
+ SourceLE =
filename:join(?datadir(Config),
"dets_test_v8b_little_endian.dets"),
- ?line Target1 = filename('oldhash1.dets', Config),
- ?line Target1LE = filename('oldhash1le.dets', Config),
- ?line Target2 = filename('oldhash2.dets', Config),
- ?line {ok, Bin} = file:read_file(Source),
- ?line {ok, BinLE} = file:read_file(SourceLE),
- ?line ok = file:write_file(Target1,Bin),
- ?line ok = file:write_file(Target1LE,BinLE),
- ?line ok = file:write_file(Target2,Bin),
- ?line {ok, d1} = dets:open_file(d1,[{file,Target1}]),
- ?line {ok, d1le} = dets:open_file(d1le,[{file,Target1LE}]),
- ?line {ok, d2} = dets:open_file(d2,[{file,Target2},{repair,force},
+ Target1 = filename('oldhash1.dets', Config),
+ Target1LE = filename('oldhash1le.dets', Config),
+ Target2 = filename('oldhash2.dets', Config),
+ {ok, Bin} = file:read_file(Source),
+ {ok, BinLE} = file:read_file(SourceLE),
+ ok = file:write_file(Target1,Bin),
+ ok = file:write_file(Target1LE,BinLE),
+ ok = file:write_file(Target2,Bin),
+ {ok, d1} = dets:open_file(d1,[{file,Target1}]),
+ {ok, d1le} = dets:open_file(d1le,[{file,Target1LE}]),
+ {ok, d2} = dets:open_file(d2,[{file,Target2},{repair,force},
{version,8}]),
- ?line FF = fun(N,_F,_T) when N > 16#FFFFFFFFFFFFFFFF ->
- ok;
- (N,F,T) ->
- V = integer_to_list(N),
- case dets:lookup(T,N) of
- [{N,V}] ->
- F(N*2,F,T);
- _Error ->
- exit({failed,{lookup,T,N}})
- end
- end,
- ?line Mess = case (catch FF(1,FF,d1)) of
- {'EXIT', {failed, {lookup,_,_}}} ->
- ?line ok = dets:close(d1),
- ?line FF(1,FF,d1le),
- ?line hash = dets:info(d1le,hash),
- ?line dets:insert(d1le,{33333333333,hejsan}),
- ?line [{33333333333,hejsan}] =
- dets:lookup(d1le,33333333333),
- ?line ok = dets:close(d1le),
- ?line {ok, d1le} = dets:open_file(d1le,
- [{file,Target1LE}]),
- ?line [{33333333333,hejsan}] =
- dets:lookup(d1le,33333333333),
- ?line FF(1,FF,d1le),
- ?line ok = dets:close(d1le),
- "Seems to be a little endian machine";
- {'EXIT', Fault} ->
- exit(Fault);
- _ ->
- ?line ok = dets:close(d1le),
- ?line hash = dets:info(d1,hash),
- ?line dets:insert(d1,{33333333333,hejsan}),
- ?line [{33333333333,hejsan}] =
- dets:lookup(d1,33333333333),
- ?line ok = dets:close(d1),
- ?line {ok, d1} = dets:open_file(d1,[{file,Target1}]),
- ?line [{33333333333,hejsan}] =
- dets:lookup(d1,33333333333),
- ?line FF(1,FF,d1),
- ?line ok = dets:close(d1),
- "Seems to be a big endian machine"
- end,
- ?line FF(1,FF,d2),
- ?line phash = dets:info(d2,hash),
- ?line ok = dets:close(d2),
- ?line file:delete(Target1),
- ?line file:delete(Target1LE),
- ?line file:delete(Target2),
- ?line check_pps(P0),
+ FF = fun(N,_F,_T) when N > 16#FFFFFFFFFFFFFFFF ->
+ ok;
+ (N,F,T) ->
+ V = integer_to_list(N),
+ case dets:lookup(T,N) of
+ [{N,V}] ->
+ F(N*2,F,T);
+ _Error ->
+ exit({failed,{lookup,T,N}})
+ end
+ end,
+ Mess = case (catch FF(1,FF,d1)) of
+ {'EXIT', {failed, {lookup,_,_}}} ->
+ ok = dets:close(d1),
+ FF(1,FF,d1le),
+ hash = dets:info(d1le,hash),
+ dets:insert(d1le,{33333333333,hejsan}),
+ [{33333333333,hejsan}] =
+ dets:lookup(d1le,33333333333),
+ ok = dets:close(d1le),
+ {ok, d1le} = dets:open_file(d1le,
+ [{file,Target1LE}]),
+ [{33333333333,hejsan}] =
+ dets:lookup(d1le,33333333333),
+ FF(1,FF,d1le),
+ ok = dets:close(d1le),
+ "Seems to be a little endian machine";
+ {'EXIT', Fault} ->
+ exit(Fault);
+ _ ->
+ ok = dets:close(d1le),
+ hash = dets:info(d1,hash),
+ dets:insert(d1,{33333333333,hejsan}),
+ [{33333333333,hejsan}] =
+ dets:lookup(d1,33333333333),
+ ok = dets:close(d1),
+ {ok, d1} = dets:open_file(d1,[{file,Target1}]),
+ [{33333333333,hejsan}] =
+ dets:lookup(d1,33333333333),
+ FF(1,FF,d1),
+ ok = dets:close(d1),
+ "Seems to be a big endian machine"
+ end,
+ FF(1,FF,d2),
+ phash = dets:info(d2,hash),
+ ok = dets:close(d2),
+ file:delete(Target1),
+ file:delete(Target1LE),
+ file:delete(Target2),
+ check_pps(P0),
{comment, Mess}.
phash(doc) ->
@@ -1710,57 +1701,57 @@ phash(Config) when is_list(Config) ->
T = phash,
Phash_v9bS = filename:join(?datadir(Config), "version_9b_phash.dat"),
Fname = filename('v9b.dets', Config),
- ?line {ok, _} = file:copy(Phash_v9bS, Fname),
+ {ok, _} = file:copy(Phash_v9bS, Fname),
%% Deleting all objects changes the hash function.
%% A feature... (it's for free)
- ?line {ok, T} = dets:open_file(T, [{file, Fname}]),
- ?line phash = dets:info(T, hash),
- ?line dets:delete_all_objects(T),
- ?line phash2 = dets:info(T, hash),
- ?line [] = get_all_objects(T),
- ?line [] = get_all_objects_fast(T),
- ?line ok = dets:close(T),
+ {ok, T} = dets:open_file(T, [{file, Fname}]),
+ phash = dets:info(T, hash),
+ dets:delete_all_objects(T),
+ phash2 = dets:info(T, hash),
+ [] = get_all_objects(T),
+ [] = get_all_objects_fast(T),
+ ok = dets:close(T),
%% The hash function is kept when compacting a table.
- ?line {ok, _} = file:copy(Phash_v9bS, Fname),
- ?line io:format("Expect compaction:~n"),
- ?line {ok, T} = dets:open_file(T, [{file, Fname},{repair,force}]),
- ?line phash = dets:info(T, hash),
- ?line [{1,a},{2,b},{3,c},{4,d},{5,e}] =
+ {ok, _} = file:copy(Phash_v9bS, Fname),
+ io:format("Expect compaction:~n"),
+ {ok, T} = dets:open_file(T, [{file, Fname},{repair,force}]),
+ phash = dets:info(T, hash),
+ [{1,a},{2,b},{3,c},{4,d},{5,e}] =
lists:sort(dets:lookup_keys(T, [1,2,3,4,5])),
- ?line ok = dets:close(T),
+ ok = dets:close(T),
%% The hash function is updated when repairing a table (no cost).
- ?line {ok, _} = file:copy(Phash_v9bS, Fname),
+ {ok, _} = file:copy(Phash_v9bS, Fname),
crash(Fname, ?CLOSED_PROPERLY_POS+3, 0),
- ?line io:format("Expect repair:~n"),
- ?line {ok, T} = dets:open_file(T, [{file, Fname}]),
- ?line phash2 = dets:info(T, hash),
- ?line [{1,a},{2,b},{3,c},{4,d},{5,e}] =
+ io:format("Expect repair:~n"),
+ {ok, T} = dets:open_file(T, [{file, Fname}]),
+ phash2 = dets:info(T, hash),
+ [{1,a},{2,b},{3,c},{4,d},{5,e}] =
lists:sort(dets:lookup_keys(T, [1,2,3,4,5])),
- ?line ok = dets:close(T),
+ ok = dets:close(T),
%% One cannot use the bchunk format when copying between a phash
%% table and a phash2 table. (There is no test for the case an R9
%% (or later) node (using phash2) copies a table to an R8 node
%% (using phash).) See also the comment on HASH_PARMS in dets_v9.erl.
- ?line {ok, _} = file:copy(Phash_v9bS, Fname),
- ?line {ok, T} = dets:open_file(T, [{file, Fname}]),
- ?line Type = dets:info(T, type),
- ?line KeyPos = dets:info(T, keypos),
+ {ok, _} = file:copy(Phash_v9bS, Fname),
+ {ok, T} = dets:open_file(T, [{file, Fname}]),
+ Type = dets:info(T, type),
+ KeyPos = dets:info(T, keypos),
Input = init_bchunk(T),
T2 = phash_table,
Fname2 = filename(T2, Config),
Args = [{type,Type},{keypos,KeyPos},{version,9},{file,Fname2}],
- ?line {ok, T2} = dets:open_file(T2, Args),
- ?line {error, {init_fun, _}} =
+ {ok, T2} = dets:open_file(T2, Args),
+ {error, {init_fun, _}} =
dets:init_table(T2, Input, {format,bchunk}),
- ?line _ = dets:close(T2),
- ?line ok = dets:close(T),
- ?line file:delete(Fname2),
+ _ = dets:close(T2),
+ ok = dets:close(T),
+ file:delete(Fname2),
- ?line file:delete(Fname),
+ file:delete(Fname),
ok.
fold_v8(doc) ->
@@ -1780,50 +1771,50 @@ fold_v9(Config) when is_list(Config) ->
fold(Config, Version) ->
T = test_table,
N = 100,
- ?line Fname = filename(T, Config),
- ?line file:delete(Fname),
+ Fname = filename(T, Config),
+ file:delete(Fname),
P0 = pps(),
Args = [{version, Version}, {file,Fname}, {estimated_no_objects, N}],
- ?line {ok, _} = dets:open_file(T, Args),
+ {ok, _} = dets:open_file(T, Args),
- ?line ok = ins(T, N),
+ ok = ins(T, N),
- ?line Ets = ets:new(to_ets, [public]),
- ?line dets:to_ets(T, Ets),
- ?line true = N =:= ets:info(Ets, size),
- ?line ets:delete(Ets),
+ Ets = ets:new(to_ets, [public]),
+ dets:to_ets(T, Ets),
+ true = N =:= ets:info(Ets, size),
+ ets:delete(Ets),
- ?line Ets2 = ets:new(to_ets, [private]),
- ?line dets:to_ets(T, Ets2),
- ?line true = N =:= ets:info(Ets2, size),
- ?line ets:delete(Ets2),
+ Ets2 = ets:new(to_ets, [private]),
+ dets:to_ets(T, Ets2),
+ true = N =:= ets:info(Ets2, size),
+ ets:delete(Ets2),
- ?line {'EXIT', {badarg, _}} = (catch dets:to_ets(T, not_an_ets_table)),
+ {'EXIT', {badarg, _}} = (catch dets:to_ets(T, not_an_ets_table)),
F0 = fun(X, A) -> [X | A] end,
- ?line true = N =:= length(dets:foldl(F0, [], T)),
- ?line true = N =:= length(dets:foldr(F0, [], T)),
+ true = N =:= length(dets:foldl(F0, [], T)),
+ true = N =:= length(dets:foldr(F0, [], T)),
F1 = fun(_X, _A) -> throw(away) end,
- ?line away = (catch dets:foldl(F1, [], T)),
- ?line away = (catch dets:foldr(F1, [], T)),
+ away = (catch dets:foldl(F1, [], T)),
+ away = (catch dets:foldr(F1, [], T)),
F2 = fun(X, A) -> X + A end,
- ?line {'EXIT', _} = (catch dets:foldl(F2, [], T)),
- ?line {'EXIT', _} = (catch dets:foldr(F2, [], T)),
+ {'EXIT', _} = (catch dets:foldl(F2, [], T)),
+ {'EXIT', _} = (catch dets:foldr(F2, [], T)),
F3 = fun(_X) -> throw(away) end,
- ?line away = (catch dets:traverse(T, F3)),
+ away = (catch dets:traverse(T, F3)),
F4 = fun(X) -> X + 17 end,
- ?line {'EXIT', _} = (catch dets:traverse(T, F4)),
+ {'EXIT', _} = (catch dets:traverse(T, F4)),
- ?line F5 = fun(_X) -> done end,
- ?line done = dets:traverse(T, F5),
+ F5 = fun(_X) -> done end,
+ done = dets:traverse(T, F5),
- ?line {ok, ObjPos} = dets:where(T, {66,{item,number,66}}),
- ?line ok = dets:close(T),
+ {ok, ObjPos} = dets:where(T, {66,{item,number,66}}),
+ ok = dets:close(T),
%% Damaged object.
Pos = if
@@ -1831,15 +1822,15 @@ fold(Config, Version) ->
Version =:= 9 -> 8
end,
crash(Fname, ObjPos+Pos),
- ?line {ok, _} = dets:open_file(T, Args),
- ?line io:format("Expect corrupt table:~n"),
- ?line BadObject1 = dets:foldl(F0, [], T),
- ?line bad_object(BadObject1, Fname),
- ?line BadObject2 = dets:close(T),
- ?line bad_object(BadObject2, Fname),
-
- ?line file:delete(Fname),
- ?line check_pps(P0),
+ {ok, _} = dets:open_file(T, Args),
+ io:format("Expect corrupt table:~n"),
+ BadObject1 = dets:foldl(F0, [], T),
+ bad_object(BadObject1, Fname),
+ BadObject2 = dets:close(T),
+ bad_object(BadObject2, Fname),
+
+ file:delete(Fname),
+ check_pps(P0),
ok.
fixtable_v8(doc) ->
@@ -1858,64 +1849,64 @@ fixtable_v9(Config) when is_list(Config) ->
fixtable(Config, Version) when is_list(Config) ->
T = fixtable,
- ?line Fname = filename(fixtable, Config),
- ?line file:delete(Fname),
+ Fname = filename(fixtable, Config),
+ file:delete(Fname),
Args = [{version,Version},{file,Fname}],
P0 = pps(),
- ?line {ok, _} = dets:open_file(T, Args),
+ {ok, _} = dets:open_file(T, Args),
%% badarg
- ?line check_badarg(catch dets:safe_fixtable(no_table,true),
+ check_badarg(catch dets:safe_fixtable(no_table,true),
dets, safe_fixtable, [no_table,true]),
- ?line check_badarg(catch dets:safe_fixtable(T,undefined),
+ check_badarg(catch dets:safe_fixtable(T,undefined),
dets, safe_fixtable, [T,undefined]),
%% The table is not allowed to grow while the elements are inserted:
- ?line ok = ins(T, 500),
- ?line dets:safe_fixtable(T, false),
+ ok = ins(T, 500),
+ dets:safe_fixtable(T, false),
%% Now the table can grow. At the same time as elements are inserted,
%% the table tries to catch up with the previously inserted elements.
- ?line ok = ins(T, 1000),
- ?line 1000 = dets:info(T, size),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
+ ok = ins(T, 1000),
+ 1000 = dets:info(T, size),
+ ok = dets:close(T),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(T, [{type, duplicate_bag} | Args]),
+ {ok, _} = dets:open_file(T, [{type, duplicate_bag} | Args]),
%% In a fixed table, delete and re-insert an object.
- ?line ok = dets:insert(T, {1, a, b}),
- ?line dets:safe_fixtable(T, true),
- ?line ok = dets:match_delete(T, {1, a, b}),
- ?line ok = dets:insert(T, {1, a, b}),
- ?line dets:safe_fixtable(T, false),
- ?line 1 = length(dets:match_object(T, '_')),
-
- ?line ok = dets:match_delete(T, '_'),
+ ok = dets:insert(T, {1, a, b}),
+ dets:safe_fixtable(T, true),
+ ok = dets:match_delete(T, {1, a, b}),
+ ok = dets:insert(T, {1, a, b}),
+ dets:safe_fixtable(T, false),
+ 1 = length(dets:match_object(T, '_')),
+
+ ok = dets:match_delete(T, '_'),
%% In a fixed table, delete and insert a smaller object.
- ?line ok = dets:insert(T, {1, duplicate(100, e)}),
- ?line dets:safe_fixtable(T, true),
- ?line ok = dets:match_delete(T, {1, '_'}),
- ?line ok = dets:insert(T, {1, a, b}),
- ?line dets:safe_fixtable(T, false),
- ?line 1 = length(dets:match_object(T, '_')),
-
- ?line ok = dets:delete_all_objects(T),
+ ok = dets:insert(T, {1, duplicate(100, e)}),
+ dets:safe_fixtable(T, true),
+ ok = dets:match_delete(T, {1, '_'}),
+ ok = dets:insert(T, {1, a, b}),
+ dets:safe_fixtable(T, false),
+ 1 = length(dets:match_object(T, '_')),
+
+ ok = dets:delete_all_objects(T),
%% Like the last one, but one extra object.
- ?line ok = dets:insert(T, {1, duplicate(100, e)}),
- ?line ok = dets:insert(T, {2, duplicate(100, e)}),
- ?line dets:safe_fixtable(T, true),
- ?line ok = dets:match_delete(T, {1, '_'}),
- ?line ok = dets:insert(T, {1, a, b}),
- ?line dets:safe_fixtable(T, false),
- ?line 2 = length(dets:match_object(T, '_')),
- ?line dets:safe_fixtable(T, true),
- ?line ok = dets:delete_all_objects(T),
- ?line true = dets:info(T, fixed),
- ?line 0 = length(dets:match_object(T, '_')),
-
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
- ?line check_pps(P0),
+ ok = dets:insert(T, {1, duplicate(100, e)}),
+ ok = dets:insert(T, {2, duplicate(100, e)}),
+ dets:safe_fixtable(T, true),
+ ok = dets:match_delete(T, {1, '_'}),
+ ok = dets:insert(T, {1, a, b}),
+ dets:safe_fixtable(T, false),
+ 2 = length(dets:match_object(T, '_')),
+ dets:safe_fixtable(T, true),
+ ok = dets:delete_all_objects(T),
+ true = dets:info(T, fixed),
+ 0 = length(dets:match_object(T, '_')),
+
+ ok = dets:close(T),
+ file:delete(Fname),
+ check_pps(P0),
ok.
match_v8(doc) ->
@@ -1934,164 +1925,164 @@ match_v9(Config) when is_list(Config) ->
match(Config, Version) ->
T = match,
- ?line Fname = filename(match, Config),
- ?line file:delete(Fname),
+ Fname = filename(match, Config),
+ file:delete(Fname),
P0 = pps(),
Args = [{version, Version}, {file,Fname}, {type, duplicate_bag},
{estimated_no_objects,550}],
- ?line {ok, _} = dets:open_file(T, Args),
- ?line ok = dets:insert(T, {1, a, b}),
- ?line ok = dets:insert(T, {1, b, a}),
- ?line ok = dets:insert(T, {2, a, b}),
- ?line ok = dets:insert(T, {2, b, a}),
+ {ok, _} = dets:open_file(T, Args),
+ ok = dets:insert(T, {1, a, b}),
+ ok = dets:insert(T, {1, b, a}),
+ ok = dets:insert(T, {2, a, b}),
+ ok = dets:insert(T, {2, b, a}),
%% match, badarg
MSpec = [{'_',[],['$_']}],
- ?line check_badarg(catch dets:match(no_table, '_'),
- dets, safe_fixtable, [no_table,true]),
- ?line check_badarg(catch dets:match(T, '_', not_a_number),
- dets, match, [T,'_',not_a_number]),
- ?line {EC1, _} = dets:select(T, MSpec, 1),
- ?line check_badarg(catch dets:match(EC1),
- dets, match, [EC1]),
+ check_badarg(catch dets:match(no_table, '_'),
+ dets, match, [no_table,'_']),
+ check_badarg(catch dets:match(T, '_', not_a_number),
+ dets, match, [T,'_',not_a_number]),
+ {EC1, _} = dets:select(T, MSpec, 1),
+ check_badarg(catch dets:match(EC1),
+ dets, match, [EC1]),
%% match_object, badarg
- ?line check_badarg(catch dets:match_object(no_table, '_'),
- dets, safe_fixtable, [no_table,true]),
- ?line check_badarg(catch dets:match_object(T, '_', not_a_number),
- dets, match_object, [T,'_',not_a_number]),
- ?line {EC2, _} = dets:select(T, MSpec, 1),
- ?line check_badarg(catch dets:match_object(EC2),
- dets, match_object, [EC2]),
+ check_badarg(catch dets:match_object(no_table, '_'),
+ dets, match_object, [no_table,'_']),
+ check_badarg(catch dets:match_object(T, '_', not_a_number),
+ dets, match_object, [T,'_',not_a_number]),
+ {EC2, _} = dets:select(T, MSpec, 1),
+ check_badarg(catch dets:match_object(EC2),
+ dets, match_object, [EC2]),
+
+ dets:safe_fixtable(T, true),
+ {[_, _], C1} = dets:match_object(T, '_', 2),
+ {[_, _], C2} = dets:match_object(C1),
+ '$end_of_table' = dets:match_object(C2),
+ {[_, _], C3} = dets:match_object(T, {1, '_', '_'}, 100),
+ '$end_of_table' = dets:match_object(C3),
+ '$end_of_table' = dets:match_object(T, {'_'}, default),
+ dets:safe_fixtable(T, false),
dets:safe_fixtable(T, true),
- ?line {[_, _], C1} = dets:match_object(T, '_', 2),
- ?line {[_, _], C2} = dets:match_object(C1),
- ?line '$end_of_table' = dets:match_object(C2),
- ?line {[_, _], C3} = dets:match_object(T, {1, '_', '_'}, 100),
- ?line '$end_of_table' = dets:match_object(C3),
- ?line '$end_of_table' = dets:match_object(T, {'_'}, default),
- ?line dets:safe_fixtable(T, false),
-
- ?line dets:safe_fixtable(T, true),
- ?line {[_, _], C30} = dets:match(T, '$1', 2),
- ?line {[_, _], C31} = dets:match(C30),
- ?line '$end_of_table' = dets:match(C31),
- ?line {[_, _], C32} = dets:match(T, {1, '$1', '_'}, 100),
- ?line '$end_of_table' = dets:match(C32),
- ?line '$end_of_table' = dets:match(T, {'_'}, default),
- ?line dets:safe_fixtable(T, false),
- ?line [[1],[1],[2],[2]] = sort(dets:match(T, {'$1','_','_'})),
+ {[_, _], C30} = dets:match(T, '$1', 2),
+ {[_, _], C31} = dets:match(C30),
+ '$end_of_table' = dets:match(C31),
+ {[_, _], C32} = dets:match(T, {1, '$1', '_'}, 100),
+ '$end_of_table' = dets:match(C32),
+ '$end_of_table' = dets:match(T, {'_'}, default),
+ dets:safe_fixtable(T, false),
+ [[1],[1],[2],[2]] = sort(dets:match(T, {'$1','_','_'})),
%% delete and insert while chunking
%% (this case almost worthless after changes in OTP-5232)
- ?line ok = dets:match_delete(T, '_'),
+ ok = dets:match_delete(T, '_'),
L500 = seq(1, 500),
Fun = fun(X) -> ok = dets:insert(T, {X, a, b, c, d}) end,
- ?line foreach(Fun, L500),
+ foreach(Fun, L500),
%% Select one object DI in L3 below to be deleted.
- ?line {_, TmpCont} = dets:match_object(T, '_', 200),
- ?line {_, TmpCont1} = dets:match_object(TmpCont),
- ?line {TTL, _} = dets:match_object(TmpCont1),
- ?line DI = if Version =:= 8 -> last(TTL); Version =:= 9 -> hd(TTL) end,
- ?line dets:safe_fixtable(T, true),
- ?line {L1, C20} = dets:match_object(T, '_', 200),
- ?line true = 200 =< length(L1),
- ?line ok = dets:match_delete(T, {'2','_','_'}), % no match
- ?line ok = dets:match_delete(T, DI), % last object
+ {_, TmpCont} = dets:match_object(T, '_', 200),
+ {_, TmpCont1} = dets:match_object(TmpCont),
+ {TTL, _} = dets:match_object(TmpCont1),
+ DI = if Version =:= 8 -> last(TTL); Version =:= 9 -> hd(TTL) end,
+ dets:safe_fixtable(T, true),
+ {L1, C20} = dets:match_object(T, '_', 200),
+ true = 200 =< length(L1),
+ ok = dets:match_delete(T, {'2','_','_'}), % no match
+ ok = dets:match_delete(T, DI), % last object
Tiny = {1050},
- ?line ok = dets:insert(T, Tiny),
- ?line true = member(Tiny, dets:match_object(T, '_')),
- ?line {_L2, C21} = dets:match_object(C20),
- ?line {_L3, _C22} = dets:match_object(C21),
+ ok = dets:insert(T, Tiny),
+ true = member(Tiny, dets:match_object(T, '_')),
+ {_L2, C21} = dets:match_object(C20),
+ {_L3, _C22} = dets:match_object(C21),
%% It used to be that Tiny was not visible here, but since the
%% scanning of files was changed to inspect the free lists every
%% now and then it may very well be visible here.
- %% ?line false = member(Tiny, _L3),
+ %% false = member(Tiny, _L3),
%% DI used to visible here, but the above mentioned modification
%% has changed that; it may or may not be visible.
- %% ?line true = member(DI, _L3),
- ?line dets:safe_fixtable(T, false),
- ?line true = dets:member(T, 1050),
- ?line true = member(Tiny, dets:match_object(T, '_')),
- ?line false = member(DI, dets:match_object(T, '_')),
+ %% true = member(DI, _L3),
+ dets:safe_fixtable(T, false),
+ true = dets:member(T, 1050),
+ true = member(Tiny, dets:match_object(T, '_')),
+ false = member(DI, dets:match_object(T, '_')),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
+ ok = dets:close(T),
+ file:delete(Fname),
N = 100,
- ?line {ok, _} = dets:open_file(T, [{estimated_no_objects,N} | Args]),
- ?line ok = ins(T, N),
+ {ok, _} = dets:open_file(T, [{estimated_no_objects,N} | Args]),
+ ok = ins(T, N),
Obj = {66,{item,number,66}},
Spec = {'_','_'},
- ?line {ok, ObjPos} = dets:where(T, Obj),
- ?line ok = dets:close(T),
+ {ok, ObjPos} = dets:where(T, Obj),
+ ok = dets:close(T),
%% Damaged object.
crash(Fname, ObjPos+12),
- ?line {ok, _} = dets:open_file(T, Args),
- ?line io:format("Expect corrupt table:~n"),
- ?line case ins(T, N) of
+ {ok, _} = dets:open_file(T, Args),
+ io:format("Expect corrupt table:~n"),
+ case ins(T, N) of
ok ->
- ?line bad_object(dets:sync(T), Fname);
+ bad_object(dets:sync(T), Fname);
Else ->
- ?line bad_object(Else, Fname)
+ bad_object(Else, Fname)
end,
- ?line io:format("Expect corrupt table:~n"),
- ?line bad_object(dets:match(T, Spec), Fname),
- ?line io:format("Expect corrupt table:~n"),
- ?line bad_object(dets:match_delete(T, Spec), Fname),
- ?line bad_object(dets:close(T), Fname),
- ?line file:delete(Fname),
-
- ?line {ok, _} = dets:open_file(T, [{estimated_no_objects,N} | Args]),
- ?line ok = ins(T, N),
- ?line {ok, ObjPos2} = dets:where(T, Obj),
- ?line ok = dets:close(T),
+ io:format("Expect corrupt table:~n"),
+ bad_object(dets:match(T, Spec), Fname),
+ io:format("Expect corrupt table:~n"),
+ bad_object(dets:match_delete(T, Spec), Fname),
+ bad_object(dets:close(T), Fname),
+ file:delete(Fname),
+
+ {ok, _} = dets:open_file(T, [{estimated_no_objects,N} | Args]),
+ ok = ins(T, N),
+ {ok, ObjPos2} = dets:where(T, Obj),
+ ok = dets:close(T),
%% Damaged size of object.
%% In v8, there is a next pointer before the size.
CrashPos = if Version =:= 8 -> 5; Version =:= 9 -> 1 end,
crash(Fname, ObjPos2+CrashPos),
- ?line {ok, _} = dets:open_file(T, Args),
- ?line io:format("Expect corrupt table:~n"),
- ?line case ins(T, N) of
- ok ->
- ?line bad_object(dets:sync(T), Fname);
- Else2 ->
- ?line bad_object(Else2, Fname)
- end,
+ {ok, _} = dets:open_file(T, Args),
+ io:format("Expect corrupt table:~n"),
+ case ins(T, N) of
+ ok ->
+ bad_object(dets:sync(T), Fname);
+ Else2 ->
+ bad_object(Else2, Fname)
+ end,
%% Just echoes...
- ?line bad_object(dets:match(T, Spec), Fname),
- ?line bad_object(dets:match_delete(T, Spec), Fname),
- ?line bad_object(dets:close(T), Fname),
- ?line file:delete(Fname),
+ bad_object(dets:match(T, Spec), Fname),
+ bad_object(dets:match_delete(T, Spec), Fname),
+ bad_object(dets:close(T), Fname),
+ file:delete(Fname),
- ?line {ok, _} = dets:open_file(T, [{estimated_no_objects,N} | Args]),
- ?line ok = ins(T, N),
- ?line {ok, ObjPos3} = dets:where(T, Obj),
- ?line ok = dets:close(T),
+ {ok, _} = dets:open_file(T, [{estimated_no_objects,N} | Args]),
+ ok = ins(T, N),
+ {ok, ObjPos3} = dets:where(T, Obj),
+ ok = dets:close(T),
%% match_delete finds an error
CrashPos3 = if Version =:= 8 -> 12; Version =:= 9 -> 16 end,
crash(Fname, ObjPos3+CrashPos3),
- ?line {ok, _} = dets:open_file(T, Args),
- ?line bad_object(dets:match_delete(T, Spec), Fname),
- ?line bad_object(dets:close(T), Fname),
- ?line file:delete(Fname),
+ {ok, _} = dets:open_file(T, Args),
+ bad_object(dets:match_delete(T, Spec), Fname),
+ bad_object(dets:close(T), Fname),
+ file:delete(Fname),
%% The key is not fixed, but not all objects with the key are removed.
- ?line {ok, _} = dets:open_file(T, Args),
- ?line ok = dets:insert(T, [{1,a},{1,b},{1,c},{1,a},{1,b},{1,c}]),
- ?line 6 = dets:info(T, size),
- ?line ok = dets:match_delete(T, {'_',a}),
- ?line 4 = dets:info(T, size),
- ?line [{1,b},{1,b},{1,c},{1,c}] =
+ {ok, _} = dets:open_file(T, Args),
+ ok = dets:insert(T, [{1,a},{1,b},{1,c},{1,a},{1,b},{1,c}]),
+ 6 = dets:info(T, size),
+ ok = dets:match_delete(T, {'_',a}),
+ 4 = dets:info(T, size),
+ [{1,b},{1,b},{1,c},{1,c}] =
sort(dets:match_object(T,{'_','_'})),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
+ ok = dets:close(T),
+ file:delete(Fname),
- ?line check_pps(P0),
+ check_pps(P0),
ok.
select_v8(doc) ->
@@ -2110,102 +2101,102 @@ select_v9(Config) when is_list(Config) ->
select(Config, Version) ->
T = select,
- ?line Fname = filename(select, Config),
- ?line file:delete(Fname),
+ Fname = filename(select, Config),
+ file:delete(Fname),
P0 = pps(),
- ?line Args = [{version,Version}, {file,Fname}, {type, duplicate_bag},
- {estimated_no_objects,550}],
- ?line {ok, _} = dets:open_file(T, Args),
- ?line ok = dets:insert(T, {1, a, b}),
- ?line ok = dets:insert(T, {1, b, a}),
- ?line ok = dets:insert(T, {2, a, b}),
- ?line ok = dets:insert(T, {2, b, a}),
- ?line ok = dets:insert(T, {3, a, b}),
- ?line ok = dets:insert(T, {3, b, a}),
+ Args = [{version,Version}, {file,Fname}, {type, duplicate_bag},
+ {estimated_no_objects,550}],
+ {ok, _} = dets:open_file(T, Args),
+ ok = dets:insert(T, {1, a, b}),
+ ok = dets:insert(T, {1, b, a}),
+ ok = dets:insert(T, {2, a, b}),
+ ok = dets:insert(T, {2, b, a}),
+ ok = dets:insert(T, {3, a, b}),
+ ok = dets:insert(T, {3, b, a}),
%% badarg
MSpec = [{'_',[],['$_']}],
- ?line check_badarg(catch dets:select(no_table, MSpec),
- dets, safe_fixtable, [no_table,true]),
- ?line check_badarg(catch dets:select(T, <<17>>),
- dets, select, [T,<<17>>]),
- ?line check_badarg(catch dets:select(T, []),
- dets, select, [T,[]]),
- ?line check_badarg(catch dets:select(T, MSpec, not_a_number),
- dets, select, [T,MSpec,not_a_number]),
- ?line {EC, _} = dets:match(T, '_', 1),
- ?line check_badarg(catch dets:select(EC),
- dets, select, [EC]),
+ check_badarg(catch dets:select(no_table, MSpec),
+ dets, select, [no_table,MSpec]),
+ check_badarg(catch dets:select(T, <<17>>),
+ dets, select, [T,<<17>>]),
+ check_badarg(catch dets:select(T, []),
+ dets, select, [T,[]]),
+ check_badarg(catch dets:select(T, MSpec, not_a_number),
+ dets, select, [T,MSpec,not_a_number]),
+ {EC, _} = dets:match(T, '_', 1),
+ check_badarg(catch dets:select(EC),
+ dets, select, [EC]),
AllSpec = [{'_',[],['$_']}],
- ?line dets:safe_fixtable(T, true),
- ?line {[_, _], C1} = dets:select(T, AllSpec, 2),
- ?line {[_, _], C2} = dets:select(C1),
- ?line {[_, _], C2a} = dets:select(C2),
- ?line '$end_of_table' = dets:select(C2a),
- ?line {[_, _], C3} = dets:select(T, [{{1,'_','_'},[],['$_']}], 100),
- ?line '$end_of_table' = dets:select(C3),
- ?line '$end_of_table' = dets:select(T, [{{'_'},[],['$_']}], default),
- ?line dets:safe_fixtable(T, false),
+ dets:safe_fixtable(T, true),
+ {[_, _], C1} = dets:select(T, AllSpec, 2),
+ {[_, _], C2} = dets:select(C1),
+ {[_, _], C2a} = dets:select(C2),
+ '$end_of_table' = dets:select(C2a),
+ {[_, _], C3} = dets:select(T, [{{1,'_','_'},[],['$_']}], 100),
+ '$end_of_table' = dets:select(C3),
+ '$end_of_table' = dets:select(T, [{{'_'},[],['$_']}], default),
+ dets:safe_fixtable(T, false),
Sp1 = [{{1,'_','_'},[],['$_']},{{1,'_','_'},[],['$_']},
{{2,'_','_'},[],['$_']}],
- ?line [_,_,_,_] = dets:select(T, Sp1),
+ [_,_,_,_] = dets:select(T, Sp1),
Sp2 = [{{1,'_','_'},[],['$_']},{{1,'_','_'},[],['$_']},
{{'_','_','_'},[],['$_']}],
- ?line [_,_,_,_,_,_] = dets:select(T, Sp2),
+ [_,_,_,_,_,_] = dets:select(T, Sp2),
AllDeleteSpec = [{'_',[],[true]}],
%% delete and insert while chunking
%% (this case almost worthless after changes in OTP-5232)
- ?line 6 = dets:select_delete(T, AllDeleteSpec),
+ 6 = dets:select_delete(T, AllDeleteSpec),
L500 = seq(1, 500),
Fun = fun(X) -> ok = dets:insert(T, {X, a, b, c, d}) end,
- ?line foreach(Fun, L500),
+ foreach(Fun, L500),
%% Select one object DI in L3 below to be deleted.
- ?line {_, TmpCont} = dets:match_object(T, '_', 200),
- ?line {_, TmpCont1} = dets:match_object(TmpCont),
- ?line {TTL, _} = dets:match_object(TmpCont1),
- ?line DI = if Version =:= 8 -> last(TTL); Version =:= 9 -> hd(TTL) end,
- ?line dets:safe_fixtable(T, true),
- ?line {L1, C20} = dets:select(T, AllSpec, 200),
- ?line true = 200 =< length(L1),
- ?line 0 = dets:select_delete(T, [{{2,'_','_'},[],[true]}]),
- ?line 1 = dets:select_delete(T, [{DI,[],[true]}]), % last object
+ {_, TmpCont} = dets:match_object(T, '_', 200),
+ {_, TmpCont1} = dets:match_object(TmpCont),
+ {TTL, _} = dets:match_object(TmpCont1),
+ DI = if Version =:= 8 -> last(TTL); Version =:= 9 -> hd(TTL) end,
+ dets:safe_fixtable(T, true),
+ {L1, C20} = dets:select(T, AllSpec, 200),
+ true = 200 =< length(L1),
+ 0 = dets:select_delete(T, [{{2,'_','_'},[],[true]}]),
+ 1 = dets:select_delete(T, [{DI,[],[true]}]), % last object
Tiny = {1050},
- ?line ok = dets:insert(T, Tiny),
- ?line true = member(Tiny, dets:select(T, AllSpec)),
- ?line {_L2, C21} = dets:select(C20),
- ?line {_L3, _C22} = dets:select(C21),
+ ok = dets:insert(T, Tiny),
+ true = member(Tiny, dets:select(T, AllSpec)),
+ {_L2, C21} = dets:select(C20),
+ {_L3, _C22} = dets:select(C21),
%% It used to be that Tiny was not visible here, but since the
%% scanning of files was changed to inspect the free lists every
%% now and then it may very well be visible here.
- %% ?line false = member(Tiny, _L3),
+ %% false = member(Tiny, _L3),
%% DI used to visible here, but the above mentioned modification
%% has changed that; it may or may not be visible.
- %% ?line true = member(DI, _L3),
- ?line true = dets:member(T, 1050),
- ?line true = member(Tiny, dets:select(T, AllSpec)),
- ?line false = member(DI, dets:select(T, AllSpec)),
- ?line dets:safe_fixtable(T, false),
- ?line true = dets:member(T, 1050),
- ?line true = member(Tiny, dets:select(T, AllSpec)),
- ?line false = member(DI, dets:select(T, AllSpec)),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
+ %% true = member(DI, _L3),
+ true = dets:member(T, 1050),
+ true = member(Tiny, dets:select(T, AllSpec)),
+ false = member(DI, dets:select(T, AllSpec)),
+ dets:safe_fixtable(T, false),
+ true = dets:member(T, 1050),
+ true = member(Tiny, dets:select(T, AllSpec)),
+ false = member(DI, dets:select(T, AllSpec)),
+ ok = dets:close(T),
+ file:delete(Fname),
%% The key is not fixed, but not all objects with the key are removed.
- ?line {ok, _} = dets:open_file(T, Args),
- ?line ok = dets:insert(T, [{1,a},{1,b},{1,c},{1,a},{1,b},{1,c}]),
- ?line 6 = dets:info(T, size),
- ?line 2 = dets:select_delete(T, [{{'_',a},[],[true]}]),
- ?line 4 = dets:info(T, size),
- ?line [{1,b},{1,b},{1,c},{1,c}] = sort(dets:select(T, AllSpec)),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
-
- ?line check_pps(P0),
+ {ok, _} = dets:open_file(T, Args),
+ ok = dets:insert(T, [{1,a},{1,b},{1,c},{1,a},{1,b},{1,c}]),
+ 6 = dets:info(T, size),
+ 2 = dets:select_delete(T, [{{'_',a},[],[true]}]),
+ 4 = dets:info(T, size),
+ [{1,b},{1,b},{1,c},{1,c}] = sort(dets:select(T, AllSpec)),
+ ok = dets:close(T),
+ file:delete(Fname),
+
+ check_pps(P0),
ok.
update_counter(doc) ->
@@ -2214,34 +2205,34 @@ update_counter(suite) ->
[];
update_counter(Config) when is_list(Config) ->
T = update_counter,
- ?line Fname = filename(select, Config),
- ?line file:delete(Fname),
+ Fname = filename(select, Config),
+ file:delete(Fname),
P0 = pps(),
- ?line check_badarg(catch dets:update_counter(no_table, 1, 1),
- dets, update_counter, [no_table,1,1]),
+ check_badarg(catch dets:update_counter(no_table, 1, 1),
+ dets, update_counter, [no_table,1,1]),
Args = [{file,Fname},{keypos,2}],
- ?line {ok, _} = dets:open_file(T, [{type,set} | Args]),
- ?line {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, 1)),
- ?line ok = dets:insert(T, {1,a}),
- ?line {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, 1)),
- ?line ok = dets:insert(T, {0,1}),
- ?line {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, 1)),
- ?line ok = dets:insert(T, {0,1,0}),
- ?line 1 = dets:update_counter(T, 1, 1),
- ?line 2 = dets:update_counter(T, 1, 1),
- ?line 6 = dets:update_counter(T, 1, {3,4}),
- ?line {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, {0,3})),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
-
- ?line {ok, _} = dets:open_file(T, [{type,bag} | Args]),
- ?line ok = dets:insert(T, {0,1,0}),
- ?line {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, 1)),
- ?line ok = dets:close(T),
- ?line file:delete(Fname),
- ?line check_pps(P0),
+ {ok, _} = dets:open_file(T, [{type,set} | Args]),
+ {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, 1)),
+ ok = dets:insert(T, {1,a}),
+ {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, 1)),
+ ok = dets:insert(T, {0,1}),
+ {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, 1)),
+ ok = dets:insert(T, {0,1,0}),
+ 1 = dets:update_counter(T, 1, 1),
+ 2 = dets:update_counter(T, 1, 1),
+ 6 = dets:update_counter(T, 1, {3,4}),
+ {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, {0,3})),
+ ok = dets:close(T),
+ file:delete(Fname),
+
+ {ok, _} = dets:open_file(T, [{type,bag} | Args]),
+ ok = dets:insert(T, {0,1,0}),
+ {'EXIT', {badarg, _}} = (catch dets:update_counter(T, 1, 1)),
+ ok = dets:close(T),
+ file:delete(Fname),
+ check_pps(P0),
ok.
@@ -2251,131 +2242,133 @@ badarg(suite) ->
[];
badarg(Config) when is_list(Config) ->
T = badarg,
- ?line Fname = filename(select, Config),
- ?line file:delete(Fname),
+ Fname = filename(select, Config),
+ file:delete(Fname),
P0 = pps(),
Args = [{file,Fname},{keypos,3}],
- ?line {ok, _} = dets:open_file(T, [{type,set} | Args]),
- % ?line dets:verbose(),
+ {ok, _} = dets:open_file(T, [{type,set} | Args]),
+ % dets:verbose(),
%% badargs are tested in match, select and fixtable too.
%% open
- ?line check_badarg(catch dets:open_file({a,tuple},[]),
- dets, open_file, [{a,tuple},[]]),
- ?line check_badarg(catch dets:open_file({a,tuple}),
- dets, open_file,[{a,tuple}]),
- ?line check_badarg(catch dets:open_file(file,[foo]),
- dets, open_file, [file,[foo]]),
- ?line check_badarg(catch dets:open_file({hej,san},[{type,set}|3]),
- dets, open_file, [{hej,san},[{type,set}|3]]),
+ check_badarg(catch dets:open_file({a,tuple},[]),
+ dets, open_file, [{a,tuple},[]]),
+ check_badarg(catch dets:open_file({a,tuple}),
+ dets, open_file,[{a,tuple}]),
+ check_badarg(catch dets:open_file(file,[foo]),
+ dets, open_file, [file,[foo]]),
+ check_badarg(catch dets:open_file({hej,san},[{type,set}|3]),
+ dets, open_file, [{hej,san},[{type,set}|3]]),
%% insert
- ?line check_badarg(catch dets:insert(no_table, {1,2}),
- dets, insert, [no_table,{1,2}]),
- ?line check_badarg(catch dets:insert(no_table, [{1,2}]),
- dets, insert, [no_table,[{1,2}]]),
- ?line check_badarg(catch dets:insert(T, {1,2}),
- dets, insert, [T,{1,2}]),
- ?line check_badarg(catch dets:insert(T, [{1,2}]),
- dets, insert, [T,[{1,2}]]),
- ?line check_badarg(catch dets:insert(T, [{1,2,3} | 3]),
- dets, insert, [T,[{1,2,3}|3]]),
+ check_badarg(catch dets:insert(no_table, {1,2}),
+ dets, insert, [no_table,{1,2}]),
+ check_badarg(catch dets:insert(no_table, [{1,2}]),
+ dets, insert, [no_table,[{1,2}]]),
+ check_badarg(catch dets:insert(T, {1,2}),
+ dets, insert, [T,{1,2}]),
+ check_badarg(catch dets:insert(T, [{1,2}]),
+ dets, insert, [T,[{1,2}]]),
+ check_badarg(catch dets:insert(T, [{1,2,3} | 3]),
+ dets, insert, [T,[{1,2,3}|3]]),
%% lookup{_keys}
- ?line check_badarg(catch dets:lookup_keys(T, []),
- dets, lookup_keys, [badarg,[]]),
- ?line check_badarg(catch dets:lookup(no_table, 1),
- dets, lookup, [no_table,1]),
- ?line check_badarg(catch dets:lookup_keys(T, [1 | 2]),
- dets, lookup_keys, [T,[1|2]]),
+ check_badarg(catch dets:lookup_keys(T, []),
+ dets, lookup_keys, [badarg,[]]),
+ check_badarg(catch dets:lookup(no_table, 1),
+ dets, lookup, [no_table,1]),
+ check_badarg(catch dets:lookup_keys(T, [1 | 2]),
+ dets, lookup_keys, [T,[1|2]]),
%% member
- ?line check_badarg(catch dets:member(no_table, 1),
- dets, member, [no_table,1]),
+ check_badarg(catch dets:member(no_table, 1),
+ dets, member, [no_table,1]),
%% sync
- ?line check_badarg(catch dets:sync(no_table),
- dets, sync, [no_table]),
+ check_badarg(catch dets:sync(no_table),
+ dets, sync, [no_table]),
%% delete{_keys}
- ?line check_badarg(catch dets:delete(no_table, 1),
- dets, delete, [no_table,1]),
+ check_badarg(catch dets:delete(no_table, 1),
+ dets, delete, [no_table,1]),
%% delete_object
- ?line check_badarg(catch dets:delete_object(no_table, {1,2,3}),
- dets, delete_object, [no_table,{1,2,3}]),
- ?line check_badarg(catch dets:delete_object(T, {1,2}),
- dets, delete_object, [T,{1,2}]),
- ?line check_badarg(catch dets:delete_object(no_table, [{1,2,3}]),
- dets, delete_object, [no_table,[{1,2,3}]]),
- ?line check_badarg(catch dets:delete_object(T, [{1,2}]),
- dets, delete_object, [T,[{1,2}]]),
- ?line check_badarg(catch dets:delete_object(T, [{1,2,3} | 3]),
- dets, delete_object, [T,[{1,2,3}|3]]),
+ check_badarg(catch dets:delete_object(no_table, {1,2,3}),
+ dets, delete_object, [no_table,{1,2,3}]),
+ check_badarg(catch dets:delete_object(T, {1,2}),
+ dets, delete_object, [T,{1,2}]),
+ check_badarg(catch dets:delete_object(no_table, [{1,2,3}]),
+ dets, delete_object, [no_table,[{1,2,3}]]),
+ check_badarg(catch dets:delete_object(T, [{1,2}]),
+ dets, delete_object, [T,[{1,2}]]),
+ check_badarg(catch dets:delete_object(T, [{1,2,3} | 3]),
+ dets, delete_object, [T,[{1,2,3}|3]]),
%% first,next,slot
- ?line check_badarg(catch dets:first(no_table),
- dets, first, [no_table]),
- ?line check_badarg(catch dets:next(no_table, 1),
- dets, next, [no_table,1]),
- ?line check_badarg(catch dets:slot(no_table, 0),
- dets, slot, [no_table,0]),
+ check_badarg(catch dets:first(no_table),
+ dets, first, [no_table]),
+ check_badarg(catch dets:next(no_table, 1),
+ dets, next, [no_table,1]),
+ check_badarg(catch dets:slot(no_table, 0),
+ dets, slot, [no_table,0]),
%% info
- ?line undefined = dets:info(no_table),
- ?line undefined = dets:info(no_table, foo),
- ?line undefined = dets:info(T, foo),
+ undefined = dets:info(no_table),
+ undefined = dets:info(no_table, foo),
+ undefined = dets:info(T, foo),
%% match_delete
- ?line check_badarg(catch dets:match_delete(no_table, '_'),
- dets, safe_fixtable, [no_table,true]),
+ check_badarg(catch dets:match_delete(no_table, '_'),
+ dets, match_delete, [no_table,'_']),
%% delete_all_objects
- ?line check_badarg(catch dets:delete_all_objects(no_table),
- dets, delete_all_objects, [no_table]),
+ check_badarg(catch dets:delete_all_objects(no_table),
+ dets, delete_all_objects, [no_table]),
%% select_delete
MSpec = [{'_',[],['$_']}],
- ?line check_badarg(catch dets:select_delete(no_table, MSpec),
- dets, safe_fixtable, [no_table,true]),
- ?line check_badarg(catch dets:select_delete(T, <<17>>),
- dets, select_delete, [T, <<17>>]),
+ check_badarg(catch dets:select_delete(no_table, MSpec),
+ dets, select_delete, [no_table,MSpec]),
+ check_badarg(catch dets:select_delete(T, <<17>>),
+ dets, select_delete, [T, <<17>>]),
%% traverse, fold
- ?line check_badarg(catch dets:traverse(no_table, fun(_) -> continue end),
- dets, safe_fixtable, [no_table,true]),
- ?line check_badarg(catch dets:foldl(fun(_, A) -> A end, [], no_table),
- dets, safe_fixtable, [no_table,true]),
- ?line check_badarg(catch dets:foldr(fun(_, A) -> A end, [], no_table),
- dets, safe_fixtable, [no_table,true]),
+ TF = fun(_) -> continue end,
+ check_badarg(catch dets:traverse(no_table, TF),
+ dets, traverse, [no_table,TF]),
+ FF = fun(_, A) -> A end,
+ check_badarg(catch dets:foldl(FF, [], no_table),
+ dets, foldl, [FF,[],no_table]),
+ check_badarg(catch dets:foldr(FF, [], no_table),
+ dets, foldl, [FF,[],no_table]),
%% close
- ?line ok = dets:close(T),
- ?line {error, not_owner} = dets:close(T),
- ?line {error, not_owner} = dets:close(T),
+ ok = dets:close(T),
+ {error, not_owner} = dets:close(T),
+ {error, not_owner} = dets:close(T),
%% init_table
IF = fun(X) -> X end,
- ?line check_badarg(catch dets:init_table(no_table, IF),
- dets, init_table, [no_table,IF,[]]),
- ?line check_badarg(catch dets:init_table(no_table, IF, []),
- dets, init_table, [no_table,IF,[]]),
+ check_badarg(catch dets:init_table(no_table, IF),
+ dets, init_table, [no_table,IF,[]]),
+ check_badarg(catch dets:init_table(no_table, IF, []),
+ dets, init_table, [no_table,IF,[]]),
%% from_ets
Ets = ets:new(ets,[]),
- ?line check_badarg(catch dets:from_ets(no_table, Ets),
- dets, from_ets, [no_table,Ets]),
+ check_badarg(catch dets:from_ets(no_table, Ets),
+ dets, from_ets, [no_table,Ets]),
ets:delete(Ets),
- ?line {ok, T} = dets:open_file(T, Args),
- ?line {error,incompatible_arguments} =
+ {ok, T} = dets:open_file(T, Args),
+ {error,incompatible_arguments} =
dets:open_file(T, [{type,bag} | Args]),
- ?line ok = dets:close(T),
+ ok = dets:close(T),
file:delete(Fname),
- ?line check_pps(P0),
+ check_pps(P0),
ok.
cache_sets_v8(doc) ->
@@ -2411,11 +2404,11 @@ cache_sets(Config, DelayedWrite, Extra, Sz, Version) ->
%% Sz = integer(). Size of the inserted tuples.
T = cache,
- ?line Fname = filename(cache, Config),
- ?line file:delete(Fname),
+ Fname = filename(cache, Config),
+ file:delete(Fname),
P0 = pps(),
- ?line {ok, _} =
+ {ok, _} =
dets:open_file(T,[{version, Version}, {file,Fname}, {type,set},
{delayed_write, DelayedWrite}]),
@@ -2424,48 +2417,48 @@ cache_sets(Config, DelayedWrite, Extra, Sz, Version) ->
if
Extra ->
%% Insert enough to get three keys in some slot.
- ?line dets:safe_fixtable(T, true),
+ dets:safe_fixtable(T, true),
insert_objs(T, 1, Sz, Dups);
true ->
{1,[]}
end,
Tuple = erlang:make_tuple(Sz, Key),
- ?line ok = dets:delete(T, Key),
- ?line ok = dets:sync(T),
+ ok = dets:delete(T, Key),
+ ok = dets:sync(T),
%% The values of keys in the same slot as Key are checked.
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
- ?line ok = dets:insert(T, Tuple),
- ?line [Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
- ?line ok = dets:insert(T, [Tuple,Tuple]),
+ ok = dets:insert(T, Tuple),
+ [Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+ ok = dets:insert(T, [Tuple,Tuple]),
%% If no delay, the cache gets filled immediately, and written.
- ?line [Tuple] = dets:lookup_keys(T, [Key,a,b,c,d,e,f]),
- ?line true = dets:member(T, Key),
+ [Tuple] = dets:lookup_keys(T, [Key,a,b,c,d,e,f]),
+ true = dets:member(T, Key),
%% If delay, this happens without file access.
- ?line ok = dets:delete(T,Key),
- ?line ok = dets:insert(T,Tuple),
- ?line ok = dets:insert(T,Tuple),
- ?line [Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
- ?line ok = dets:sync(T),
- ?line [Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
+ ok = dets:delete(T,Key),
+ ok = dets:insert(T,Tuple),
+ ok = dets:insert(T,Tuple),
+ [Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+ ok = dets:sync(T),
+ [Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
%% Key's objects are is on file only,
%% key 'toto' in the cache (if there is one).
- ?line ok = dets:delete(T,toto),
- ?line ok = dets:insert(T,[{toto,b},{toto,b}]),
- ?line true = sort([Tuple,{toto,b}]) =:=
- sort(dets:lookup_keys(T, [Key,toto])),
- ?line true = dets:member(T, toto),
+ ok = dets:delete(T,toto),
+ ok = dets:insert(T,[{toto,b},{toto,b}]),
+ true = sort([Tuple,{toto,b}]) =:=
+ sort(dets:lookup_keys(T, [Key,toto])),
+ true = dets:member(T, toto),
- ?line ok = dets:delete(T, Key),
- ?line ok = dets:sync(T),
- ?line false = dets:member(T, Key),
- ?line Size = dets:info(T, size),
+ ok = dets:delete(T, Key),
+ ok = dets:sync(T),
+ false = dets:member(T, Key),
+ Size = dets:info(T, size),
%% No object with the key on the file.
%% Delete, add one object.
@@ -2487,37 +2480,37 @@ cache_sets(Config, DelayedWrite, Extra, Sz, Version) ->
E -> E + 1
end,
Tuple2 = setelement(2, Tuple, Element),
- ?line ok = dets:sync(T),
- ?line ok = dets:insert(T, Tuple2),
- ?line [Tuple2] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
- ?line ok = dets:sync(T),
- ?line [Tuple2] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
-
- ?line ok = dets:insert(T, {3,a}),
- ?line ok = dets:insert(T, {3,b}),
- ?line ok = dets:delete_object(T, {3,c}),
- ?line ok = dets:delete_object(T, {3,d}),
- ?line [{3,b}] = dets:lookup(T, 3),
-
- ?line ok = dets:delete(T, 3),
- ?line ok = dets:delete_object(T, {3,c}),
- ?line ok = dets:delete_object(T, {3,d}),
- ?line [] = dets:lookup(T, 3),
-
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
+ ok = dets:sync(T),
+ ok = dets:insert(T, Tuple2),
+ [Tuple2] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+ ok = dets:sync(T),
+ [Tuple2] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+
+ ok = dets:insert(T, {3,a}),
+ ok = dets:insert(T, {3,b}),
+ ok = dets:delete_object(T, {3,c}),
+ ok = dets:delete_object(T, {3,d}),
+ [{3,b}] = dets:lookup(T, 3),
+
+ ok = dets:delete(T, 3),
+ ok = dets:delete_object(T, {3,c}),
+ ok = dets:delete_object(T, {3,d}),
+ [] = dets:lookup(T, 3),
+
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
if
Extra ->
%% Let the table grow a while, if it needs to.
- ?line All1 = get_all_objects(T),
- ?line dets:safe_fixtable(T, false),
- ?line timer:sleep(1000),
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
- ?line dets:safe_fixtable(T, true),
- ?line All2 = get_all_objects(T),
- ?line FAll2 = get_all_objects_fast(T),
- ?line true = sort(All2) =:= sort(FAll2),
+ All1 = get_all_objects(T),
+ dets:safe_fixtable(T, false),
+ timer:sleep(1000),
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
+ dets:safe_fixtable(T, true),
+ All2 = get_all_objects(T),
+ FAll2 = get_all_objects_fast(T),
+ true = sort(All2) =:= sort(FAll2),
case symdiff(All1, All2) of
{[],[]} -> ok;
{X,Y} ->
@@ -2527,10 +2520,10 @@ cache_sets(Config, DelayedWrite, Extra, Sz, Version) ->
true ->
ok
end,
- ?line ok = dets:close(T),
+ ok = dets:close(T),
file:delete(Fname),
- ?line check_pps(P0),
+ check_pps(P0),
ok.
cache_bags_v8(doc) ->
@@ -2566,11 +2559,11 @@ cache_bags(Config, DelayedWrite, Extra, Sz, Version) ->
%% Sz = integer(). Size of the inserted tuples.
T = cache,
- ?line Fname = filename(cache, Config),
- ?line file:delete(Fname),
+ Fname = filename(cache, Config),
+ file:delete(Fname),
P0 = pps(),
- ?line {ok, _} =
+ {ok, _} =
dets:open_file(T,[{version, Version}, {file,Fname}, {type,bag},
{delayed_write, DelayedWrite}]),
@@ -2579,49 +2572,49 @@ cache_bags(Config, DelayedWrite, Extra, Sz, Version) ->
if
Extra ->
%% Insert enough to get three keys in some slot.
- ?line dets:safe_fixtable(T, true),
+ dets:safe_fixtable(T, true),
insert_objs(T, 1, Sz, Dups);
true ->
{1,[]}
end,
Tuple = erlang:make_tuple(Sz, Key),
- ?line ok = dets:delete(T, Key),
- ?line ok = dets:sync(T),
+ ok = dets:delete(T, Key),
+ ok = dets:sync(T),
%% The values of keys in the same slot as Key are checked.
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
- ?line ok = dets:insert(T, Tuple),
- ?line [Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
- ?line ok = dets:insert(T, [Tuple,Tuple]),
+ ok = dets:insert(T, Tuple),
+ [Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+ ok = dets:insert(T, [Tuple,Tuple]),
%% If no delay, the cache gets filled immediately, and written.
- ?line [Tuple] = dets:lookup_keys(T, [Key,a,b,c,d,e,f]),
- ?line true = dets:member(T, Key),
+ [Tuple] = dets:lookup_keys(T, [Key,a,b,c,d,e,f]),
+ true = dets:member(T, Key),
%% If delay, this happens without file access.
%% (This is no longer true; cache lookup has been simplified.)
- ?line ok = dets:delete(T,Key),
- ?line ok = dets:insert(T,Tuple),
- ?line ok = dets:insert(T,Tuple),
- ?line [Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
- ?line ok = dets:sync(T),
- ?line [Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
+ ok = dets:delete(T,Key),
+ ok = dets:insert(T,Tuple),
+ ok = dets:insert(T,Tuple),
+ [Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+ ok = dets:sync(T),
+ [Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
%% Key's objects are is on file only,
%% key toto in the cache (if there is one).
- ?line ok = dets:delete(T,toto),
- ?line false = dets:member(T, toto),
- ?line ok = dets:insert(T,[{toto,b},{toto,b}]),
- ?line true = sort([Tuple,{toto,b}]) =:=
- sort(dets:lookup_keys(T, [Key,toto])),
- ?line true = dets:member(T, toto),
+ ok = dets:delete(T,toto),
+ false = dets:member(T, toto),
+ ok = dets:insert(T,[{toto,b},{toto,b}]),
+ true = sort([Tuple,{toto,b}]) =:=
+ sort(dets:lookup_keys(T, [Key,toto])),
+ true = dets:member(T, toto),
- ?line ok = dets:delete(T, Key),
- ?line ok = dets:sync(T),
- ?line Size = dets:info(T, size),
+ ok = dets:delete(T, Key),
+ ok = dets:sync(T),
+ Size = dets:info(T, size),
%% No object with the key on the file.
%% Delete, add one object.
@@ -2638,50 +2631,50 @@ cache_bags(Config, DelayedWrite, Extra, Sz, Version) ->
del_and_ins(both, T, Size2, Tuple, Key, 1),
%% Overwrite an objekt on file with the same object.
- ?line ok = dets:insert(T, Tuple),
- ?line ok = dets:sync(T),
- ?line [Tuple2] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
- ?line ok = dets:insert(T, Tuple),
- ?line ok = dets:sync(T),
- ?line [Tuple2] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
+ ok = dets:insert(T, Tuple),
+ ok = dets:sync(T),
+ [Tuple2] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+ ok = dets:insert(T, Tuple),
+ ok = dets:sync(T),
+ [Tuple2] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
%% A mix of insert and delete.
- ?line ok = dets:delete(T, Key),
- ?line ok = dets:sync(T),
- ?line ok = dets:delete(T, Key),
- ?line ok = dets:insert(T, {Key,foo}),
- ?line ok = dets:insert(T, {Key,bar}),
- ?line [{Key,bar},{Key,foo}] = sort(dets:lookup(T, Key)),
- ?line true = dets:member(T, Key),
- ?line ok = dets:delete_object(T, {Key,foo}),
- ?line ok = dets:insert(T, {Key,kar}),
- ?line [{Key,bar},{Key,kar}] = sort(dets:lookup(T, Key)),
- ?line true = dets:member(T, Key),
- ?line ok = dets:insert(T, [{Key,kar},{Key,kar}]),
- ?line [{Key,bar},{Key,kar}] = sort(dets:lookup(T, Key)),
- ?line true = dets:member(T, Key),
- ?line ok = dets:delete_object(T, {Key,bar}),
- ?line ok = dets:delete_object(T, {Key,kar}),
- ?line [] = dets:lookup(T, Key),
- ?line false = dets:member(T, Key),
- ?line ok = dets:sync(T),
- ?line [] = dets:lookup(T, Key),
- ?line false = dets:member(T, Key),
-
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
+ ok = dets:delete(T, Key),
+ ok = dets:sync(T),
+ ok = dets:delete(T, Key),
+ ok = dets:insert(T, {Key,foo}),
+ ok = dets:insert(T, {Key,bar}),
+ [{Key,bar},{Key,foo}] = sort(dets:lookup(T, Key)),
+ true = dets:member(T, Key),
+ ok = dets:delete_object(T, {Key,foo}),
+ ok = dets:insert(T, {Key,kar}),
+ [{Key,bar},{Key,kar}] = sort(dets:lookup(T, Key)),
+ true = dets:member(T, Key),
+ ok = dets:insert(T, [{Key,kar},{Key,kar}]),
+ [{Key,bar},{Key,kar}] = sort(dets:lookup(T, Key)),
+ true = dets:member(T, Key),
+ ok = dets:delete_object(T, {Key,bar}),
+ ok = dets:delete_object(T, {Key,kar}),
+ [] = dets:lookup(T, Key),
+ false = dets:member(T, Key),
+ ok = dets:sync(T),
+ [] = dets:lookup(T, Key),
+ false = dets:member(T, Key),
+
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
if
Extra ->
%% Let the table grow for a while, if it needs to.
- ?line All1 = get_all_objects(T),
- ?line dets:safe_fixtable(T, false),
- ?line timer:sleep(1200),
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
- ?line dets:safe_fixtable(T, true),
- ?line All2 = get_all_objects(T),
- ?line FAll2 = get_all_objects_fast(T),
- ?line true = sort(All2) =:= sort(FAll2),
+ All1 = get_all_objects(T),
+ dets:safe_fixtable(T, false),
+ timer:sleep(1200),
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
+ dets:safe_fixtable(T, true),
+ All2 = get_all_objects(T),
+ FAll2 = get_all_objects_fast(T),
+ true = sort(All2) =:= sort(FAll2),
case symdiff(All1, All2) of
{[],[]} -> ok;
{X,Y} ->
@@ -2691,28 +2684,28 @@ cache_bags(Config, DelayedWrite, Extra, Sz, Version) ->
true ->
ok
end,
- ?line ok = dets:close(T),
+ ok = dets:close(T),
file:delete(Fname),
%% Second object of a key added and looked up simultaneously.
R1 = {index_test,1,2,3,4},
R2 = {index_test,2,2,13,14},
R3 = {index_test,1,12,13,14},
- ?line {ok, _} = dets:open_file(T,[{version,Version},{type,bag},
- {keypos,2},{file,Fname}]),
- ?line ok = dets:insert(T,R1),
- ?line ok = dets:sync(T),
- ?line ok = dets:insert(T,R2),
- ?line ok = dets:sync(T),
- ?line ok = dets:insert(T,R3),
- ?line [R1,R3] = sort(dets:lookup(T,1)),
- ?line true = dets:member(T, 1),
- ?line [R1,R3] = sort(dets:lookup(T,1)),
- ?line true = dets:member(T, 1),
- ?line ok = dets:close(T),
+ {ok, _} = dets:open_file(T,[{version,Version},{type,bag},
+ {keypos,2},{file,Fname}]),
+ ok = dets:insert(T,R1),
+ ok = dets:sync(T),
+ ok = dets:insert(T,R2),
+ ok = dets:sync(T),
+ ok = dets:insert(T,R3),
+ [R1,R3] = sort(dets:lookup(T,1)),
+ true = dets:member(T, 1),
+ [R1,R3] = sort(dets:lookup(T,1)),
+ true = dets:member(T, 1),
+ ok = dets:close(T),
file:delete(Fname),
- ?line check_pps(P0),
+ check_pps(P0),
ok.
cache_duplicate_bags_v8(doc) ->
@@ -2747,11 +2740,11 @@ cache_dup_bags(Config, DelayedWrite, Extra, Sz, Version) ->
%% Sz = integer(). Size of the inserted tuples.
T = cache,
- ?line Fname = filename(cache, Config),
- ?line file:delete(Fname),
+ Fname = filename(cache, Config),
+ file:delete(Fname),
P0 = pps(),
- ?line {ok, _} =
+ {ok, _} =
dets:open_file(T,[{version, Version}, {file,Fname},
{type,duplicate_bag},
{delayed_write, DelayedWrite}]),
@@ -2761,53 +2754,53 @@ cache_dup_bags(Config, DelayedWrite, Extra, Sz, Version) ->
if
Extra ->
%% Insert enough to get three keys in some slot.
- ?line dets:safe_fixtable(T, true),
+ dets:safe_fixtable(T, true),
insert_objs(T, 1, Sz, Dups);
true ->
{1,[]}
end,
Tuple = erlang:make_tuple(Sz, Key),
- ?line ok = dets:delete(T, Key),
- ?line ok = dets:sync(T),
- ?line false = dets:member(T, Key),
+ ok = dets:delete(T, Key),
+ ok = dets:sync(T),
+ false = dets:member(T, Key),
%% The values of keys in the same slot as Key are checked.
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
- ?line ok = dets:insert(T, Tuple),
- ?line [Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
- ?line ok = dets:insert(T, [Tuple,Tuple]),
+ ok = dets:insert(T, Tuple),
+ [Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+ ok = dets:insert(T, [Tuple,Tuple]),
%% If no delay, the cache gets filled immediately, and written.
- ?line [Tuple,Tuple,Tuple] = dets:lookup_keys(T, [Key,a,b,c,d,e,f]),
- ?line true = dets:member(T, Key),
+ [Tuple,Tuple,Tuple] = dets:lookup_keys(T, [Key,a,b,c,d,e,f]),
+ true = dets:member(T, Key),
%% If delay, this happens without file access.
%% (This is no longer true; cache lookup has been simplified.)
- ?line ok = dets:delete(T,Key),
- ?line ok = dets:insert(T,Tuple),
- ?line ok = dets:insert(T,Tuple),
- ?line [Tuple,Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
- ?line ok = dets:sync(T),
- ?line [Tuple,Tuple] = dets:lookup(T, Key),
- ?line true = dets:member(T, Key),
+ ok = dets:delete(T,Key),
+ ok = dets:insert(T,Tuple),
+ ok = dets:insert(T,Tuple),
+ [Tuple,Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
+ ok = dets:sync(T),
+ [Tuple,Tuple] = dets:lookup(T, Key),
+ true = dets:member(T, Key),
%% One object in the cache, one on the file.
- ?line ok = dets:delete(T,Key),
- ?line ok = dets:insert(T,Tuple),
- ?line ok = dets:sync(T),
- ?line ok = dets:insert(T,Tuple),
- ?line true = dets:member(T, Key), % should not read the file, but it does..
+ ok = dets:delete(T,Key),
+ ok = dets:insert(T,Tuple),
+ ok = dets:sync(T),
+ ok = dets:insert(T,Tuple),
+ true = dets:member(T, Key), % should not read the file, but it does..
%% Key's objects are is on file only,
%% key toto in the cache (if there is one).
- ?line ok = dets:delete(T,toto),
- ?line ok = dets:insert(T,[{toto,b},{toto,b}]),
- ?line true = sort([Tuple,Tuple,{toto,b},{toto,b}]) =:=
+ ok = dets:delete(T,toto),
+ ok = dets:insert(T,[{toto,b},{toto,b}]),
+ true = sort([Tuple,Tuple,{toto,b},{toto,b}]) =:=
sort(dets:lookup_keys(T, [Key,toto])),
- ?line true = dets:member(T, toto),
- ?line Size = dets:info(T, size),
+ true = dets:member(T, toto),
+ Size = dets:info(T, size),
%% Two objects with the same key on the file.
%% Delete them, add two objects.
@@ -2828,18 +2821,18 @@ cache_dup_bags(Config, DelayedWrite, Extra, Sz, Version) ->
del_and_ins(object, T, Size, Tuple, Key, 1),
del_and_ins(both, T, Size, Tuple, Key, 1),
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
if
Extra ->
%% Let the table grow for a while, if it needs to.
- ?line All1 = get_all_objects(T),
- ?line dets:safe_fixtable(T, false),
- ?line timer:sleep(1200),
- ?line OtherValues = sort(lookup_keys(T, OtherKeys)),
- ?line dets:safe_fixtable(T, true),
- ?line All2 = get_all_objects(T),
- ?line FAll2 = get_all_objects_fast(T),
- ?line true = sort(All2) =:= sort(FAll2),
+ All1 = get_all_objects(T),
+ dets:safe_fixtable(T, false),
+ timer:sleep(1200),
+ OtherValues = sort(lookup_keys(T, OtherKeys)),
+ dets:safe_fixtable(T, true),
+ All2 = get_all_objects(T),
+ FAll2 = get_all_objects_fast(T),
+ true = sort(All2) =:= sort(FAll2),
case symdiff(All1, All2) of
{[],[]} -> ok;
{X,Y} ->
@@ -2849,10 +2842,10 @@ cache_dup_bags(Config, DelayedWrite, Extra, Sz, Version) ->
true ->
ok
end,
- ?line ok = dets:close(T),
+ ok = dets:close(T),
file:delete(Fname),
- ?line check_pps(P0),
+ check_pps(P0),
ok.
lookup_keys(_T, []) ->
@@ -2863,47 +2856,47 @@ lookup_keys(T, Keys) ->
del_and_ins(W, T, Size, Obj, Key, N) ->
case W of
object ->
- ?line ok = dets:delete_object(T, Obj);
+ ok = dets:delete_object(T, Obj);
key ->
- ?line ok = dets:delete(T, Key);
+ ok = dets:delete(T, Key);
both ->
- ?line ok = dets:delete(T, Key),
- ?line ok = dets:delete_object(T, Obj)
+ ok = dets:delete(T, Key),
+ ok = dets:delete_object(T, Obj)
end,
Objs = duplicate(N, Obj),
- ?line [] = dets:lookup(T, Key),
- ?line ok = dets:insert(T, Objs),
- ?line Objs = dets:lookup_keys(T, [snurrespratt,Key]),
- ?line true = Size + length(Objs)-2 =:= dets:info(T, size),
- ?line Objs = dets:lookup(T, Key).
+ [] = dets:lookup(T, Key),
+ ok = dets:insert(T, Objs),
+ Objs = dets:lookup_keys(T, [snurrespratt,Key]),
+ true = Size + length(Objs)-2 =:= dets:info(T, size),
+ Objs = dets:lookup(T, Key).
insert_objs(T, N, Sz, Dups) ->
Seq = seq(N,N+255),
L0 = map(fun(I) -> erlang:make_tuple(Sz, I) end, Seq),
L = append(duplicate(Dups, L0)),
- ?line ok = dets:insert(T, L),
- ?line case search_slot(T, 0) of
- false ->
- insert_objs(T, N+256, Sz, Dups);
- Keys ->
- Keys
- end.
+ ok = dets:insert(T, L),
+ case search_slot(T, 0) of
+ false ->
+ insert_objs(T, N+256, Sz, Dups);
+ Keys ->
+ Keys
+ end.
search_slot(T, I) ->
- ?line case dets:slot(T, I) of
- '$end_of_table' ->
- false;
- Objs ->
- case usort(map(fun(X) -> element(1, X) end, Objs)) of
- [_, Key, _ | _] = Keys0 ->
- Keys = delete(Key, Keys0),
- {Key, Keys};
- _ ->
- search_slot(T, I+1)
- end
- end.
+ case dets:slot(T, I) of
+ '$end_of_table' ->
+ false;
+ Objs ->
+ case usort(map(fun(X) -> element(1, X) end, Objs)) of
+ [_, Key, _ | _] = Keys0 ->
+ Keys = delete(Key, Keys0),
+ {Key, Keys};
+ _ ->
+ search_slot(T, I+1)
+ end
+ end.
symdiff(L1, L2) ->
{X, _, Y} =
@@ -2916,18 +2909,18 @@ otp_4208(suite) ->
[];
otp_4208(Config) when is_list(Config) ->
Tab = otp_4208,
- ?line FName = filename(Tab, Config),
+ FName = filename(Tab, Config),
Expected = sort([{3,ghi,12},{1,abc,10},{4,jkl,13},{2,def,11}]),
file:delete(FName),
- ?line {ok, Tab} = dets:open_file(Tab, [{file,FName}]),
- ?line ok = dets:insert(Tab, [{1,abc,10},{2,def,11},{3,ghi,12},{4,jkl,13}]),
- ?line Expected = sort(dets:traverse(Tab, fun(X) -> {continue, X} end)),
- ?line ok = dets:close(Tab),
-
- ?line {ok, Tab} = dets:open_file(Tab, [{access, read},{file,FName}]),
- ?line Expected = sort(dets:traverse(Tab, fun(X) -> {continue, X} end)),
- ?line ok = dets:close(Tab),
+ {ok, Tab} = dets:open_file(Tab, [{file,FName}]),
+ ok = dets:insert(Tab, [{1,abc,10},{2,def,11},{3,ghi,12},{4,jkl,13}]),
+ Expected = sort(dets:traverse(Tab, fun(X) -> {continue, X} end)),
+ ok = dets:close(Tab),
+
+ {ok, Tab} = dets:open_file(Tab, [{access, read},{file,FName}]),
+ Expected = sort(dets:traverse(Tab, fun(X) -> {continue, X} end)),
+ ok = dets:close(Tab),
file:delete(FName),
ok.
@@ -2938,21 +2931,21 @@ otp_4989(suite) ->
[];
otp_4989(Config) when is_list(Config) ->
Tab = otp_4989,
- ?line FName = filename(Tab, Config),
+ FName = filename(Tab, Config),
%% Do exactly as in the error report.
- ?line _Ets = ets:new(Tab, [named_table]),
+ _Ets = ets:new(Tab, [named_table]),
ets_init(Tab, 100000),
- ?line {ok, Tab} =
+ {ok, Tab} =
dets:open_file(Tab, [{access, read_write}, {file,FName}, {keypos,2}]),
- ?line ok = dets:from_ets(Tab, Tab),
- ?line ok = dets:close(Tab),
+ ok = dets:from_ets(Tab, Tab),
+ ok = dets:close(Tab),
%% Restore.
- ?line {ok, Tab} =
+ {ok, Tab} =
dets:open_file(Tab, [{access, read}, {keypos, 2}, {file, FName}]),
- ?line true = ets:delete_all_objects(Tab),
- ?line true = ets:from_dets(Tab, Tab),
- ?line ok = dets:close(Tab),
+ true = ets:delete_all_objects(Tab),
+ true = ets:from_dets(Tab, Tab),
+ ok = dets:close(Tab),
ets:delete(Tab),
file:delete(FName),
ok.
@@ -2969,20 +2962,20 @@ otp_8898(suite) ->
[];
otp_8898(Config) when is_list(Config) ->
Tab = otp_8898,
- ?line FName = filename(Tab, Config),
+ FName = filename(Tab, Config),
Server = self(),
- ?line file:delete(FName),
- ?line {ok, _} = dets:open_file(Tab,[{file, FName}]),
- ?line [P1,P2,P3] = new_clients(3, Tab),
+ file:delete(FName),
+ {ok, _} = dets:open_file(Tab,[{file, FName}]),
+ [P1,P2,P3] = new_clients(3, Tab),
Seq = [{P1,[sync]},{P2,[{lookup,1,[]}]},{P3,[{insert,{1,b}}]}],
- ?line atomic_requests(Server, Tab, [[]], Seq),
- ?line true = get_replies([{P1,ok},{P2,ok},{P3,ok}]),
- ?line ok = dets:close(Tab),
- ?line {ok, _} = dets:open_file(Tab,[{file, FName}]),
- ?line file:delete(FName),
+ atomic_requests(Server, Tab, [[]], Seq),
+ true = get_replies([{P1,ok},{P2,ok},{P3,ok}]),
+ ok = dets:close(Tab),
+ {ok, _} = dets:open_file(Tab,[{file, FName}]),
+ file:delete(FName),
ok.
@@ -2992,25 +2985,25 @@ otp_8899(suite) ->
[];
otp_8899(Config) when is_list(Config) ->
Tab = many_clients,
- ?line FName = filename(Tab, Config),
+ FName = filename(Tab, Config),
Server = self(),
- ?line file:delete(FName),
- ?line {ok, _} = dets:open_file(Tab,[{file, FName},{version,9}]),
- ?line [P1,P2,P3,P4] = new_clients(4, Tab),
+ file:delete(FName),
+ {ok, _} = dets:open_file(Tab,[{file, FName},{version,9}]),
+ [P1,P2,P3,P4] = new_clients(4, Tab),
MC = [Tab],
Seq6a = [{P1,[{insert,[{used_to_be_skipped_by,match}]},
{lookup,1,[{1,a}]}]},
{P2,[{verbose,true,MC}]},
{P3,[{lookup,1,[{1,a}]}]}, {P4,[{verbose,true,MC}]}],
- ?line atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq6a),
- ?line true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
- ?line [{1,a},{2,b},{3,c},{used_to_be_skipped_by,match}] =
+ atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq6a),
+ true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
+ [{1,a},{2,b},{3,c},{used_to_be_skipped_by,match}] =
lists:sort(dets:match_object(Tab, '_')),
- ?line _ = dets:close(Tab),
- ?line file:delete(FName),
+ _ = dets:close(Tab),
+ file:delete(FName),
ok.
@@ -3020,14 +3013,14 @@ many_clients(suite) ->
[];
many_clients(Config) when is_list(Config) ->
Tab = many_clients,
- ?line FName = filename(Tab, Config),
+ FName = filename(Tab, Config),
Server = self(),
- ?line file:delete(FName),
+ file:delete(FName),
P0 = pps(),
- ?line {ok, _} = dets:open_file(Tab,[{file, FName},{version,9}]),
- ?line [P1,P2,P3,P4] = new_clients(4, Tab),
+ {ok, _} = dets:open_file(Tab,[{file, FName},{version,9}]),
+ [P1,P2,P3,P4] = new_clients(4, Tab),
%% dets:init_table/2 is used for making sure that all processes
%% start sending requests before the Dets process begins to handle
@@ -3038,67 +3031,67 @@ many_clients(Config) when is_list(Config) ->
%% One key is read, updated, and read again.
Seq1 = [{P1,[{lookup,1,[{1,a}]}]}, {P2,[{insert,{1,b}}]},
{P3,[{lookup,1,[{1,b}]}]}, {P4,[{lookup,1,[{1,b}]}]}],
- ?line atomic_requests(Server, Tab, [[{1,a}]], Seq1),
- ?line true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
+ atomic_requests(Server, Tab, [[{1,a}]], Seq1),
+ true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
%% Different keys read by different processes
Seq2 = [{P1,[{member,1,true}]}, {P2,[{lookup,2,[{2,b}]}]},
{P3,[{lookup,1,[{1,a}]}]}, {P4,[{lookup,3,[{3,c}]}]}],
- ?line atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq2),
- ?line true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
+ atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq2),
+ true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
%% Reading deleted key.
Seq3 = [{P1,[{delete_key,2}]}, {P2,[{lookup,1,[{1,a}]}]},
{P3,[{lookup,1,[{1,a}]}]}, {P4,[{member,2,false}]}],
- ?line atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq3),
- ?line true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
+ atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq3),
+ true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
%% Inserting objects.
Seq4 = [{P1,[{insert,[{1,a},{2,b}]}]}, {P2,[{insert,[{2,c},{3,a}]}]},
{P3,[{insert,[{3,b},{4,d}]}]},
{P4,[{lookup_keys,[1,2,3,4],[{1,a},{2,c},{3,b},{4,d}]}]}],
- ?line atomic_requests(Server, Tab, [], Seq4),
- ?line true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
+ atomic_requests(Server, Tab, [], Seq4),
+ true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
%% Deleting objects.
Seq5 = [{P1,[{delete_object,{1,a}}]}, {P2,[{delete_object,{1,a}}]},
{P3,[{delete_object,{3,c}}]},
{P4,[{lookup_keys,[1,2,3,4],[{2,b}]}]}],
- ?line atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq5),
- ?line true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
+ atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq5),
+ true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
%% Some request not streamed.
Seq6 = [{P1,[{lookup,1,[{1,a}]}]}, {P2,[{info,size,3}]},
{P3,[{lookup,1,[{1,a}]}]}, {P4,[{info,size,3}]}],
- ?line atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq6),
- ?line true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
+ atomic_requests(Server, Tab, [[{1,a},{2,b},{3,c}]], Seq6),
+ true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
%% Some request not streamed.
Seq7 = [{P1,[{insert,[{3,a}]}]}, {P2,[{insert,[{3,b}]}]},
{P3,[{delete_object,{3,c}}]},
{P4,[{lookup,3,[{3,b}]}]}],
- ?line atomic_requests(Server, Tab, [[{3,c}]], Seq7),
- ?line true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
+ atomic_requests(Server, Tab, [[{3,c}]], Seq7),
+ true = get_replies([{P1,ok}, {P2,ok}, {P3,ok}, {P4,ok}]),
- ?line put_requests(Server, [{P1,stop},{P2,stop},{P3,stop},{P4,stop}]),
- ?line ok = dets:close(Tab),
- ?line file:delete(FName),
+ put_requests(Server, [{P1,stop},{P2,stop},{P3,stop},{P4,stop}]),
+ ok = dets:close(Tab),
+ file:delete(FName),
%% Check that errors are handled correctly by the streaming operators.
- ?line {ok, _} = dets:open_file(Tab,[{file, FName},{version,9}]),
- ?line ok = ins(Tab, 100),
+ {ok, _} = dets:open_file(Tab,[{file, FName},{version,9}]),
+ ok = ins(Tab, 100),
Obj = {66,{item,number,66}},
- ?line {ok, ObjPos} = dets:where(Tab, Obj),
- ?line ok = dets:close(Tab),
+ {ok, ObjPos} = dets:where(Tab, Obj),
+ ok = dets:close(Tab),
%% Damaged object.
crash(FName, ObjPos+12),
- ?line {ok, _} = dets:open_file(Tab,[{file, FName},{version,9}]),
- ?line BadObject1 = dets:lookup_keys(Tab, [65,66,67,68,69]),
- ?line bad_object(BadObject1, FName),
- ?line _Error = dets:close(Tab),
- ?line file:delete(FName),
+ {ok, _} = dets:open_file(Tab,[{file, FName},{version,9}]),
+ BadObject1 = dets:lookup_keys(Tab, [65,66,67,68,69]),
+ bad_object(BadObject1, FName),
+ _Error = dets:close(Tab),
+ file:delete(FName),
- ?line check_pps(P0),
+ check_pps(P0),
ok.
@@ -3124,7 +3117,7 @@ get_replies(L) ->
lists:all(fun({Pid,Reply}) -> Reply =:= get_reply(Pid) end, L).
get_reply(Pid) ->
- ?line receive {Pid, Reply} -> Reply end.
+ receive {Pid, Reply} -> Reply end.
new_clients(0, _Tab) ->
[];
@@ -3139,7 +3132,7 @@ client(S, Tab) ->
{S, stop} ->
exit(normal);
{S, ToDo} ->
- ?line Reply = eval(ToDo, Tab),
+ Reply = eval(ToDo, Tab),
case Reply of
{error, _} -> io:format("~p: ~p~n", [self(), Reply]);
_ -> ok
@@ -3151,55 +3144,55 @@ client(S, Tab) ->
eval([], _Tab) ->
ok;
eval([{verbose,Bool,Expected} | L], Tab) ->
- ?line case dets:verbose(Bool) of
- Expected -> eval(L, Tab);
- Error -> {error, {verbose,Error}}
- end;
+ case dets:verbose(Bool) of
+ Expected -> eval(L, Tab);
+ Error -> {error, {verbose,Error}}
+ end;
eval([sync | L], Tab) ->
- ?line case dets:sync(Tab) of
- ok -> eval(L, Tab);
- Error -> {error, {sync,Error}}
- end;
+ case dets:sync(Tab) of
+ ok -> eval(L, Tab);
+ Error -> {error, {sync,Error}}
+ end;
eval([{insert,Stuff} | L], Tab) ->
- ?line case dets:insert(Tab, Stuff) of
- ok -> eval(L, Tab);
- Error -> {error, {insert,Stuff,Error}}
- end;
+ case dets:insert(Tab, Stuff) of
+ ok -> eval(L, Tab);
+ Error -> {error, {insert,Stuff,Error}}
+ end;
eval([{lookup,Key,Expected} | L], Tab) ->
- ?line case dets:lookup(Tab, Key) of
- Expected -> eval(L, Tab);
- Else -> {error, {lookup,Key,Expected,Else}}
- end;
+ case dets:lookup(Tab, Key) of
+ Expected -> eval(L, Tab);
+ Else -> {error, {lookup,Key,Expected,Else}}
+ end;
eval([{lookup_keys,Keys,Expected} | L], Tab) ->
%% Time order is destroyed...
- ?line case dets:lookup_keys(Tab, Keys) of
- R when is_list(R) ->
- case lists:sort(Expected) =:= lists:sort(R) of
- true -> eval(L, Tab);
- false -> {error, {lookup_keys,Keys,Expected,R}}
- end;
- Else -> {error, {lookup_keys,Keys,Expected,Else}}
- end;
+ case dets:lookup_keys(Tab, Keys) of
+ R when is_list(R) ->
+ case lists:sort(Expected) =:= lists:sort(R) of
+ true -> eval(L, Tab);
+ false -> {error, {lookup_keys,Keys,Expected,R}}
+ end;
+ Else -> {error, {lookup_keys,Keys,Expected,Else}}
+ end;
eval([{member,Key,Expected} | L], Tab) ->
- ?line case dets:member(Tab, Key) of
- Expected -> eval(L, Tab);
- Else -> {error, {member,Key,Expected,Else}}
- end;
+ case dets:member(Tab, Key) of
+ Expected -> eval(L, Tab);
+ Else -> {error, {member,Key,Expected,Else}}
+ end;
eval([{delete_key,Key} | L], Tab) ->
- ?line case dets:delete(Tab, Key) of
- ok -> eval(L, Tab);
- Else -> {error, {delete_key,Key,Else}}
- end;
+ case dets:delete(Tab, Key) of
+ ok -> eval(L, Tab);
+ Else -> {error, {delete_key,Key,Else}}
+ end;
eval([{delete_object,Object} | L], Tab) ->
- ?line case dets:delete_object(Tab, Object) of
- ok -> eval(L, Tab);
- Else -> {error, {delete_object,Object,Else}}
- end;
+ case dets:delete_object(Tab, Object) of
+ ok -> eval(L, Tab);
+ Else -> {error, {delete_object,Object,Else}}
+ end;
eval([{info,Tag,Expected} | L], Tab) ->
- ?line case dets:info(Tab, Tag) of
- Expected -> eval(L, Tab);
- Else -> {error, {info,Tag,Else,Expected}}
- end;
+ case dets:info(Tab, Tag) of
+ Expected -> eval(L, Tab);
+ Else -> {error, {info,Tag,Else,Expected}}
+ end;
eval(Else, _Tab) ->
{error, {bad_request,Else}}.
@@ -3210,44 +3203,44 @@ otp_4906(suite) ->
otp_4906(Config) when is_list(Config) ->
N = 256*512 + 400,
Tab = otp_4906,
- ?line FName = filename(Tab, Config),
+ FName = filename(Tab, Config),
file:delete(FName),
- ?line {ok, Tab} = dets:open_file(Tab, [{file, FName}]),
- ?line ok = ins_small(Tab, 0, N),
- ?line ok = dets:close(Tab),
- ?line {ok, Tab} = dets:open_file(Tab, [{file, FName}]),
- ?line ok = read_4906(Tab, N-1),
- ?line ok = dets:close(Tab),
+ {ok, Tab} = dets:open_file(Tab, [{file, FName}]),
+ ok = ins_small(Tab, 0, N),
+ ok = dets:close(Tab),
+ {ok, Tab} = dets:open_file(Tab, [{file, FName}]),
+ ok = read_4906(Tab, N-1),
+ ok = dets:close(Tab),
file:delete(FName),
%% If the (only) process fixing a table updates the table, the
%% process will no longer be punished with a 1 ms delay (hm, the
%% server is delayed, it should be the client...). In this example
%% the writing process *is* delayed.
- ?line {ok,Tab} = dets:open_file(Tab, [{file,FName}]),
+ {ok,Tab} = dets:open_file(Tab, [{file,FName}]),
Parent = self(),
FixPid = spawn_link(fun() ->
dets:safe_fixtable(Tab, true),
receive {Parent, stop} -> ok end
end),
- ?line ok = ins_small(Tab, 0, 1000),
+ ok = ins_small(Tab, 0, 1000),
FixPid ! {Parent, stop},
timer:sleep(1),
- ?line ok = dets:close(Tab),
+ ok = dets:close(Tab),
file:delete(FName),
ok.
read_4906(_T, N) when N < 0 ->
ok;
read_4906(T, N) ->
- ?line [_] = dets:lookup(T, N),
+ [_] = dets:lookup(T, N),
read_4906(T, N-1).
ins_small(_T, I, N) when I =:= N ->
ok;
ins_small(T, I, N) ->
- ?line ok = dets:insert(T, {I}),
+ ok = dets:insert(T, {I}),
ins_small(T, I+1, N).
otp_5402(doc) ->
@@ -3256,28 +3249,28 @@ otp_5402(suite) ->
[];
otp_5402(Config) when is_list(Config) ->
Tab = otp_5402,
- ?line File = filename:join(["cannot", "write", "this", "file"]),
+ File = filename:join(["cannot", "write", "this", "file"]),
%% close
- ?line{ok, T} = dets:open_file(Tab, [{ram_file,true},
- {file, File}]),
- ?line ok = dets:insert(T, {1,a}),
- ?line {error,{file_error,_,_}} = dets:close(T),
+ {ok, T} = dets:open_file(Tab, [{ram_file,true},
+ {file, File}]),
+ ok = dets:insert(T, {1,a}),
+ {error,{file_error,_,_}} = dets:close(T),
%% sync
- ?line {ok, T} = dets:open_file(Tab, [{ram_file,true},
- {file, File}]),
- ?line ok = dets:insert(T, {1,a}),
- ?line {error,{file_error,_,_}} = dets:sync(T),
- ?line {error,{file_error,_,_}} = dets:close(T),
+ {ok, T} = dets:open_file(Tab, [{ram_file,true},
+ {file, File}]),
+ ok = dets:insert(T, {1,a}),
+ {error,{file_error,_,_}} = dets:sync(T),
+ {error,{file_error,_,_}} = dets:close(T),
%% auto_save
- ?line {ok, T} = dets:open_file(Tab, [{ram_file,true},
- {auto_save, 2000},
- {file, File}]),
- ?line ok = dets:insert(T, {1,a}),
- ?line timer:sleep(5000),
- ?line {error,{file_error,_,_}} = dets:close(T),
+ {ok, T} = dets:open_file(Tab, [{ram_file,true},
+ {auto_save, 2000},
+ {file, File}]),
+ ok = dets:insert(T, {1,a}),
+ timer:sleep(5000),
+ {error,{file_error,_,_}} = dets:close(T),
ok.
simultaneous_open(doc) ->
@@ -3288,12 +3281,12 @@ simultaneous_open(Config) ->
Tab = sim_open,
File = filename(Tab, Config),
- ?line ok = monit(Tab, File),
- ?line ok = kill_while_repairing(Tab, File),
- ?line ok = kill_while_init(Tab, File),
- ?line ok = open_ro(Tab, File),
- ?line ok = open_w(Tab, File, 0, Config),
- ?line ok = open_w(Tab, File, 100, Config),
+ ok = monit(Tab, File),
+ ok = kill_while_repairing(Tab, File),
+ ok = kill_while_init(Tab, File),
+ ok = open_ro(Tab, File),
+ ok = open_w(Tab, File, 0, Config),
+ ok = open_w(Tab, File, 100, Config),
ok.
%% One process logs and another process closes the log. Before
@@ -3307,8 +3300,7 @@ monit(Tab, File) ->
timer:sleep(100),
spawn(F1),
dets:close(Tab),
- file:delete(File),
- ok.
+ ok = file:delete(File).
do_log(Tab) ->
case catch dets:insert(Tab, {hej,san,sa}) of
@@ -3318,7 +3310,7 @@ do_log(Tab) ->
%% Kill the Dets process while repair is in progress.
kill_while_repairing(Tab, File) ->
- ?line create_opened_log(File),
+ create_opened_log(File),
Delay = 1000,
dets:start(),
Parent = self(),
@@ -3328,16 +3320,22 @@ kill_while_repairing(Tab, File) ->
timer:sleep(Delay),
Parent ! {self(), R}
end,
- ?line P1 = spawn(F), % will repair
- timer:sleep(100),
- ?line P2 = spawn(F), % pending...
- ?line P3 = spawn(F), % pending...
- ?line DetsPid = find_dets_pid([P1, P2, P3 | Ps]),
+ %% One of these will open the file, the other will be pending
+ %% until the file has been repaired:
+ P1 = spawn(F),
+ P2 = spawn(F),
+ P3 = spawn(F),
+ DetsPid = find_dets_pid([P1, P2, P3 | Ps]),
exit(DetsPid, kill),
- ?line receive {P1,R1} -> {'EXIT', {dets_process_died, _}} = R1 end,
- ?line receive {P2,R2} -> {ok, _} = R2 end,
- ?line receive {P3,R3} -> {ok, _} = R3 end,
+ receive {P1,R1} -> R1 end,
+ receive {P2,R2} -> R2 end,
+ receive {P3,R3} -> R3 end,
+ io:format("Killed pid: ~p~n", [DetsPid]),
+ io:format("Remaining Dets-pids (should be nil): ~p~n",
+ [find_dets_pids()]),
+ {replies,[{'EXIT', {dets_process_died, _}}, {ok,_}, {ok, _}]} =
+ {replies,lists:sort([R1, R2, R3])},
timer:sleep(200),
case dets:info(Tab) of
@@ -3345,7 +3343,7 @@ kill_while_repairing(Tab, File) ->
ok;
_Info ->
timer:sleep(5000),
- ?line undefined = dets:info(Tab)
+ undefined = dets:info(Tab)
end,
file:delete(File),
@@ -3357,6 +3355,19 @@ find_dets_pid(P0) ->
_ -> timer:sleep(100), find_dets_pid(P0)
end.
+find_dets_pid() ->
+ case find_dets_pids() of
+ [] ->
+ timer:sleep(100),
+ find_dets_pid();
+ [Pid] ->
+ Pid
+ end.
+
+find_dets_pids() ->
+ lists:filter(fun(P) -> dets:pid2name(P) =/= undefined end,
+ erlang:processes()).
+
%% Kill the Dets process when there are users and an on-going
%% initiailization.
kill_while_init(Tab, File) ->
@@ -3368,9 +3379,9 @@ kill_while_init(Tab, File) ->
receive {Parent, die} -> ok end,
{error, not_owner} = dets:close(Tab)
end,
- ?line P1 = spawn(F),
- ?line P2 = spawn(F),
- ?line P3 = spawn(F),
+ P1 = spawn(F),
+ P2 = spawn(F),
+ P3 = spawn(F),
IF = fun() ->
R = dets:open_file(Tab, [{file,File}]),
Parent ! {self(), R},
@@ -3378,29 +3389,27 @@ kill_while_init(Tab, File) ->
{'EXIT', {badarg, _}} = (catch dets:init_table(Tab, Fun)),
receive {Parent, die} -> ok end
end,
- ?line P4 = spawn(IF),
- ?line receive {P1,R1} -> {ok, _} = R1 end,
- ?line receive {P2,R2} -> {ok, _} = R2 end,
- ?line receive {P3,R3} -> {ok, _} = R3 end,
- ?line receive {P4,R4} -> {ok, _} = R4 end,
- ?line [DetsPid] =
- lists:filter(fun(P) -> dets:pid2name(P) =/= undefined end,
- erlang:processes()),
+ P4 = spawn(IF),
+ receive {P1,R1} -> {ok, _} = R1 end,
+ receive {P2,R2} -> {ok, _} = R2 end,
+ receive {P3,R3} -> {ok, _} = R3 end,
+ receive {P4,R4} -> {ok, _} = R4 end,
+ DetsPid = find_dets_pid(),
exit(DetsPid, kill),
timer:sleep(1000),
- ?line undefined = dets:info(Tab),
- ?line P1 ! {Parent, die},
- ?line P2 ! {Parent, die},
- ?line P3 ! {Parent, die},
- ?line P4 ! {Parent, die},
+ undefined = dets:info(Tab),
+ P1 ! {Parent, die},
+ P2 ! {Parent, die},
+ P3 ! {Parent, die},
+ P4 ! {Parent, die},
file:delete(File),
timer:sleep(100),
ok.
open_ro(Tab, File) ->
- ?line create_opened_log(File),
+ create_opened_log(File),
Delay = 1000,
Parent = self(),
F = fun() ->
@@ -3408,47 +3417,47 @@ open_ro(Tab, File) ->
timer:sleep(Delay),
Parent ! {self(), R}
end,
- ?line P1 = spawn(F),
- ?line P2 = spawn(F),
- ?line P3 = spawn(F),
+ P1 = spawn(F),
+ P2 = spawn(F),
+ P3 = spawn(F),
- ?line receive {P1,R1} -> {error,{not_closed,_}} = R1 end,
- ?line receive {P2,R2} -> {error,{not_closed,_}} = R2 end,
- ?line receive {P3,R3} -> {error,{not_closed,_}} = R3 end,
+ receive {P1,R1} -> {error,{not_closed,_}} = R1 end,
+ receive {P2,R2} -> {error,{not_closed,_}} = R2 end,
+ receive {P3,R3} -> {error,{not_closed,_}} = R3 end,
ok.
open_w(Tab, File, Delay, Config) ->
- ?line create_opened_log(File),
+ create_opened_log(File),
Parent = self(),
F = fun() ->
R = dets:open_file(Tab, [{file,File}]),
timer:sleep(Delay),
Parent ! {self(), R}
end,
- ?line Pid1 = spawn(F),
- ?line Pid2 = spawn(F),
- ?line Pid3 = spawn(F),
- ?line undefined = dets:info(Tab), % is repairing now
- ?line 0 = qlen(),
+ Pid1 = spawn(F),
+ Pid2 = spawn(F),
+ Pid3 = spawn(F),
+ undefined = dets:info(Tab), % is repairing now
+ 0 = qlen(),
Tab2 = t2,
File2 = filename(Tab2, Config),
- ?line file:delete(File2),
- ?line {ok,Tab2} = dets:open_file(Tab2, [{file,File2}]),
- ?line ok = dets:close(Tab2),
- ?line file:delete(File2),
- ?line 0 = qlen(), % still repairing
-
- ?line receive {Pid1,R1} -> {ok, Tab} = R1 end,
- ?line receive {Pid2,R2} -> {ok, Tab} = R2 end,
- ?line receive {Pid3,R3} -> {ok, Tab} = R3 end,
+ file:delete(File2),
+ {ok,Tab2} = dets:open_file(Tab2, [{file,File2}]),
+ ok = dets:close(Tab2),
+ file:delete(File2),
+ 0 = qlen(), % still repairing
+
+ receive {Pid1,R1} -> {ok, Tab} = R1 end,
+ receive {Pid2,R2} -> {ok, Tab} = R2 end,
+ receive {Pid3,R3} -> {ok, Tab} = R3 end,
timer:sleep(200),
case dets:info(Tab) of
undefined ->
ok;
_Info ->
timer:sleep(5000),
- ?line undefined = dets:info(Tab)
+ undefined = dets:info(Tab)
end,
file:delete(File),
@@ -3461,10 +3470,10 @@ qlen() ->
create_opened_log(File) ->
Tab = t,
file:delete(File),
- ?line {ok, Tab} = dets:open_file(Tab, [{file,File}]),
- ?line ok = ins(Tab, 60000),
- ?line ok = dets:close(Tab),
- ?line crash(File, ?CLOSED_PROPERLY_POS+3, ?NOT_PROPERLY_CLOSED),
+ {ok, Tab} = dets:open_file(Tab, [{file,File}]),
+ ok = ins(Tab, 60000),
+ ok = dets:close(Tab),
+ crash(File, ?CLOSED_PROPERLY_POS+3, ?NOT_PROPERLY_CLOSED),
ok.
insert_new(doc) ->
@@ -3475,24 +3484,24 @@ insert_new(Config) ->
Tab = insert_new,
File = filename(Tab, Config),
file:delete(File),
- ?line {ok, T} = dets:open_file(Tab, [{file,File}]),
- ?line {'EXIT', {badarg, _}} = (catch dets:insert_new(Tab, 14)),
- ?line {'EXIT', {badarg, _}} = (catch dets:insert_new(Tab, {})),
- ?line true = dets:insert_new(Tab, {1,a}),
- ?line false = dets:insert_new(Tab, {1,a}),
- ?line true = dets:insert_new(Tab, [{2,b}, {3,c}]),
- ?line false = dets:insert_new(Tab, [{2,b}, {3,c}]),
- ?line false = dets:insert_new(Tab, [{1,a}, {4,d}]),
- ?line ok = dets:close(Tab),
+ {ok, T} = dets:open_file(Tab, [{file,File}]),
+ {'EXIT', {badarg, _}} = (catch dets:insert_new(Tab, 14)),
+ {'EXIT', {badarg, _}} = (catch dets:insert_new(Tab, {})),
+ true = dets:insert_new(Tab, {1,a}),
+ false = dets:insert_new(Tab, {1,a}),
+ true = dets:insert_new(Tab, [{2,b}, {3,c}]),
+ false = dets:insert_new(Tab, [{2,b}, {3,c}]),
+ false = dets:insert_new(Tab, [{1,a}, {4,d}]),
+ ok = dets:close(Tab),
file:delete(File),
- ?line {ok, T} = dets:open_file(Tab, [{file,File},{type,bag}]),
- ?line true = dets:insert_new(Tab, {1,a}),
- ?line false = dets:insert_new(Tab, {1,b}),
- ?line true = dets:insert_new(Tab, [{2,b}, {3,c}]),
- ?line false = dets:insert_new(Tab, [{2,a}, {3,d}]),
- ?line false = dets:insert_new(Tab, [{1,a}, {4,d}]),
- ?line ok = dets:close(Tab),
+ {ok, T} = dets:open_file(Tab, [{file,File},{type,bag}]),
+ true = dets:insert_new(Tab, {1,a}),
+ false = dets:insert_new(Tab, {1,b}),
+ true = dets:insert_new(Tab, [{2,b}, {3,c}]),
+ false = dets:insert_new(Tab, [{2,a}, {3,d}]),
+ false = dets:insert_new(Tab, [{1,a}, {4,d}]),
+ ok = dets:close(Tab),
file:delete(File),
@@ -3504,24 +3513,24 @@ repair_continuation(suite) ->
[];
repair_continuation(Config) ->
Tab = repair_continuation_table,
- ?line Fname = filename(repair_cont, Config),
- ?line file:delete(Fname),
- ?line {ok, _} = dets:open_file(Tab, [{file,Fname}]),
- ?line ok = dets:insert(Tab, [{1,a},{2,b},{3,c}]),
-
- ?line MS = [{'_',[],[true]}],
-
- ?line {[true], C1} = dets:select(Tab, MS, 1),
- ?line C2 = binary_to_term(term_to_binary(C1)),
- ?line {'EXIT', {badarg, _}} = (catch dets:select(C2)),
- ?line C3 = dets:repair_continuation(C2, MS),
- ?line {[true], C4} = dets:select(C3),
- ?line C5 = dets:repair_continuation(C4, MS),
- ?line {[true], _} = dets:select(C5),
- ?line {'EXIT', {badarg, _}} = (catch dets:repair_continuation(Tab, bu)),
-
- ?line ok = dets:close(Tab),
- ?line file:delete(Fname),
+ Fname = filename(repair_cont, Config),
+ file:delete(Fname),
+ {ok, _} = dets:open_file(Tab, [{file,Fname}]),
+ ok = dets:insert(Tab, [{1,a},{2,b},{3,c}]),
+
+ MS = [{'_',[],[true]}],
+
+ {[true], C1} = dets:select(Tab, MS, 1),
+ C2 = binary_to_term(term_to_binary(C1)),
+ {'EXIT', {badarg, _}} = (catch dets:select(C2)),
+ C3 = dets:repair_continuation(C2, MS),
+ {[true], C4} = dets:select(C3),
+ C5 = dets:repair_continuation(C4, MS),
+ {[true], _} = dets:select(C5),
+ {'EXIT', {badarg, _}} = (catch dets:repair_continuation(Tab, bu)),
+
+ ok = dets:close(Tab),
+ file:delete(Fname),
ok.
otp_5487(doc) ->
@@ -3535,20 +3544,20 @@ otp_5487(Config) ->
otp_5487(Config, Version) ->
Tab = otp_5487,
- ?line Fname = filename(otp_5487, Config),
- ?line file:delete(Fname),
- ?line Ets = ets:new(otp_5487, [public, set]),
- ?line lists:foreach(fun(I) -> ets:insert(Ets, {I,I+1}) end,
- lists:seq(0,1000)),
- ?line {ok, _} = dets:open_file(Tab, [{file,Fname},{version,Version}]),
- ?line ok = dets:from_ets(Tab, Ets),
- ?line ok = dets:sync(Tab),
- ?line ok = dets:close(Tab),
- ?line {ok, _} = dets:open_file(Tab, [{file,Fname},{access,read}]),
- ?line [{1,2}] = dets:lookup(Tab, 1),
- ?line ok = dets:close(Tab),
- ?line ets:delete(Ets),
- ?line file:delete(Fname).
+ Fname = filename(otp_5487, Config),
+ file:delete(Fname),
+ Ets = ets:new(otp_5487, [public, set]),
+ lists:foreach(fun(I) -> ets:insert(Ets, {I,I+1}) end,
+ lists:seq(0,1000)),
+ {ok, _} = dets:open_file(Tab, [{file,Fname},{version,Version}]),
+ ok = dets:from_ets(Tab, Ets),
+ ok = dets:sync(Tab),
+ ok = dets:close(Tab),
+ {ok, _} = dets:open_file(Tab, [{file,Fname},{access,read}]),
+ [{1,2}] = dets:lookup(Tab, 1),
+ ok = dets:close(Tab),
+ ets:delete(Ets),
+ file:delete(Fname).
otp_6206(doc) ->
["OTP-6206. Badly formed free lists."];
@@ -3560,15 +3569,15 @@ otp_6206(Config) ->
file:delete(File),
Options = [{file,File}],
- ?line {ok, Tab} = dets:open_file(Tab, Options),
+ {ok, Tab} = dets:open_file(Tab, Options),
NObjs = 13006,
- ?line ok = ins(Tab, NObjs),
- ?line ok = del(Tab, NObjs, 2),
- ?line ok = dets:close(Tab),
+ ok = ins(Tab, NObjs),
+ ok = del(Tab, NObjs, 2),
+ ok = dets:close(Tab),
%% Used to return {badmatch,{error,{bad_freelists,File}}.
- ?line {ok, Tab} = dets:open_file(Tab, [{repair,false}|Options]),
- ?line ok = dets:close(Tab),
+ {ok, Tab} = dets:open_file(Tab, [{repair,false}|Options]),
+ ok = dets:close(Tab),
file:delete(File),
ok.
@@ -3581,10 +3590,10 @@ otp_6359(Config) ->
File = filename(Tab, Config),
file:delete(File),
- ?line {ok, _} = dets:open_file(Tab, [{file, File}]),
+ {ok, _} = dets:open_file(Tab, [{file, File}]),
%% Used to return {[], Cont}:
- ?line '$end_of_table' = dets:match(Tab, '_', 100),
- ?line ok = dets:close(Tab),
+ '$end_of_table' = dets:match(Tab, '_', 100),
+ ok = dets:close(Tab),
file:delete(File),
ok.
@@ -3609,47 +3618,47 @@ otp_4738_dupbag(Version, Config) ->
One = 1,
FOne = float(One),
Args = [{file,File},{type,duplicate_bag},{version,Version}],
- ?line {ok, Tab} = dets:open_file(Tab, Args),
- ?line ok = dets:insert(Tab, [{I,One},{F,One},{I,FOne},{F,FOne}]),
- ?line ok = dets:sync(Tab),
- ?line [{F,One},{F,FOne}] = dets:lookup(Tab, F),
- ?line [{I,One},{I,FOne}] = dets:lookup(Tab, I),
- ?line ok = dets:insert(Tab, [{F,One},{F,FOne}]),
- ?line [{I,One},{I,FOne},{F,One},{F,FOne},{F,One},{F,FOne}] =
+ {ok, Tab} = dets:open_file(Tab, Args),
+ ok = dets:insert(Tab, [{I,One},{F,One},{I,FOne},{F,FOne}]),
+ ok = dets:sync(Tab),
+ [{F,One},{F,FOne}] = dets:lookup(Tab, F),
+ [{I,One},{I,FOne}] = dets:lookup(Tab, I),
+ ok = dets:insert(Tab, [{F,One},{F,FOne}]),
+ [{I,One},{I,FOne},{F,One},{F,FOne},{F,One},{F,FOne}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:insert(Tab, [{F,FOne},{F,One}]),
- ?line [{I,One},{I,FOne},{F,One},{F,FOne},{F,One},
+ ok = dets:insert(Tab, [{F,FOne},{F,One}]),
+ [{I,One},{I,FOne},{F,One},{F,FOne},{F,One},
{F,FOne},{F,FOne},{F,One}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:delete_object(Tab, {I,FOne}),
- ?line [{I,One},{F,One},{F,FOne},{F,One},{F,FOne},{F,FOne},{F,One}] =
+ ok = dets:delete_object(Tab, {I,FOne}),
+ [{I,One},{F,One},{F,FOne},{F,One},{F,FOne},{F,FOne},{F,One}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:insert(Tab, {I,FOne}),
- ?line [{I,One},{I,FOne},{F,One},{F,FOne},{F,One},
+ ok = dets:insert(Tab, {I,FOne}),
+ [{I,One},{I,FOne},{F,One},{F,FOne},{F,One},
{F,FOne},{F,FOne},{F,One}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:delete_object(Tab, {F,FOne}),
- ?line [{I,One},{I,FOne},{F,One},{F,One},{F,One}] =
+ ok = dets:delete_object(Tab, {F,FOne}),
+ [{I,One},{I,FOne},{F,One},{F,One},{F,One}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:delete(Tab, F),
- ?line [{I,One},{I,FOne}] = dets:match_object(Tab, '_'),
- ?line ok = dets:close(Tab),
+ ok = dets:delete(Tab, F),
+ [{I,One},{I,FOne}] = dets:match_object(Tab, '_'),
+ ok = dets:close(Tab),
file:delete(File),
Zero = 0,
FZero = float(Zero),
- ?line {ok, Tab} = dets:open_file(Tab, Args),
- ?line ok = dets:insert(Tab, [{I,One},{F,One},{I,FOne},{F,FOne}]),
- ?line ok = dets:insert(Tab, [{I,One},{F,One},{I,FOne},{F,FOne}]),
- ?line ok = dets:insert(Tab, [{I,Zero},{F,Zero},{I,FZero},{I,FZero}]),
- ?line Objs0 = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:close(Tab),
+ {ok, Tab} = dets:open_file(Tab, Args),
+ ok = dets:insert(Tab, [{I,One},{F,One},{I,FOne},{F,FOne}]),
+ ok = dets:insert(Tab, [{I,One},{F,One},{I,FOne},{F,FOne}]),
+ ok = dets:insert(Tab, [{I,Zero},{F,Zero},{I,FZero},{I,FZero}]),
+ Objs0 = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
+ ok = dets:close(Tab),
crash(File, ?CLOSED_PROPERLY_POS+3, ?NOT_PROPERLY_CLOSED),
io:format("Expect repair:~n"),
- ?line {ok, Tab} = dets:open_file(Tab, Args),
- ?line Objs1 = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:close(Tab),
- ?line Objs1 = Objs0,
+ {ok, Tab} = dets:open_file(Tab, Args),
+ Objs1 = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
+ ok = dets:close(Tab),
+ Objs1 = Objs0,
file:delete(File),
ok.
@@ -3662,26 +3671,26 @@ otp_4738_bag(Version, Config) ->
One = 1,
FOne = float(One),
Args = [{file,File},{type,bag},{version,Version}],
- ?line {ok, Tab} = dets:open_file(Tab, Args),
- ?line ok = dets:insert(Tab, [{I,One},{F,One},{I,FOne},{F,FOne}]),
- ?line ok = dets:sync(Tab),
- ?line [{F,One},{F,FOne}] = dets:lookup(Tab, F),
- ?line [{I,One},{I,FOne}] = dets:lookup(Tab, I),
- ?line ok = dets:insert(Tab, [{F,One},{F,FOne}]),
- ?line [{I,One},{I,FOne},{F,One},{F,FOne}] =
+ {ok, Tab} = dets:open_file(Tab, Args),
+ ok = dets:insert(Tab, [{I,One},{F,One},{I,FOne},{F,FOne}]),
+ ok = dets:sync(Tab),
+ [{F,One},{F,FOne}] = dets:lookup(Tab, F),
+ [{I,One},{I,FOne}] = dets:lookup(Tab, I),
+ ok = dets:insert(Tab, [{F,One},{F,FOne}]),
+ [{I,One},{I,FOne},{F,One},{F,FOne}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:insert(Tab, [{F,FOne},{F,One}]),
- ?line [{I,One},{I,FOne},{F,FOne},{F,One}] =
+ ok = dets:insert(Tab, [{F,FOne},{F,One}]),
+ [{I,One},{I,FOne},{F,FOne},{F,One}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:delete_object(Tab, {I,FOne}),
- ?line [{I,One},{F,FOne},{F,One}] =
+ ok = dets:delete_object(Tab, {I,FOne}),
+ [{I,One},{F,FOne},{F,One}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:insert(Tab, {I,FOne}),
- ?line [{I,One},{I,FOne},{F,FOne},{F,One}] =
+ ok = dets:insert(Tab, {I,FOne}),
+ [{I,One},{I,FOne},{F,FOne},{F,One}] =
dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:delete(Tab, F),
- ?line [{I,One},{I,FOne}] = dets:match_object(Tab, '_'),
- ?line ok = dets:close(Tab),
+ ok = dets:delete(Tab, F),
+ [{I,One},{I,FOne}] = dets:match_object(Tab, '_'),
+ ok = dets:close(Tab),
file:delete(File).
otp_4738_set(Version, Config) ->
@@ -3693,53 +3702,53 @@ otp_4738_set(Version, Config) ->
%% I and F share the same slot.
I = -12857447,
F = float(I),
- ?line {ok, Tab} = dets:open_file(Tab, Args),
- ?line ok = dets:insert(Tab, [{I},{F}]),
- ?line ok = dets:sync(Tab),
- ?line [{F}] = dets:lookup(Tab, F),
- ?line [{I}] = dets:lookup(Tab, I),
- ?line ok = dets:insert(Tab, [{F}]),
- ?line [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:close(Tab),
+ {ok, Tab} = dets:open_file(Tab, Args),
+ ok = dets:insert(Tab, [{I},{F}]),
+ ok = dets:sync(Tab),
+ [{F}] = dets:lookup(Tab, F),
+ [{I}] = dets:lookup(Tab, I),
+ ok = dets:insert(Tab, [{F}]),
+ [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
+ ok = dets:close(Tab),
file:delete(File),
- ?line {ok, Tab} = dets:open_file(Tab, Args),
- ?line ok = dets:insert(Tab, [{I}]),
- ?line ok = dets:sync(Tab),
- ?line [] = dets:lookup(Tab, F),
- ?line [{I}] = dets:lookup(Tab, I),
- ?line ok = dets:insert(Tab, [{F}]),
- ?line [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:close(Tab),
+ {ok, Tab} = dets:open_file(Tab, Args),
+ ok = dets:insert(Tab, [{I}]),
+ ok = dets:sync(Tab),
+ [] = dets:lookup(Tab, F),
+ [{I}] = dets:lookup(Tab, I),
+ ok = dets:insert(Tab, [{F}]),
+ [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
+ ok = dets:close(Tab),
file:delete(File),
- ?line {ok, Tab} = dets:open_file(Tab, Args),
+ {ok, Tab} = dets:open_file(Tab, Args),
ok = dets:insert(Tab, [{I},{F}]),
%% {insert, ...} in the cache, try lookup:
- ?line [{F}] = dets:lookup(Tab, F),
- ?line [{I}] = dets:lookup(Tab, I),
+ [{F}] = dets:lookup(Tab, F),
+ [{I}] = dets:lookup(Tab, I),
%% Both were found, but that cannot be verified.
- ?line [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:close(Tab),
+ [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
+ ok = dets:close(Tab),
file:delete(File),
- ?line {ok, Tab} = dets:open_file(Tab, Args),
- ?line ok = dets:insert(Tab, [{I}]),
- ?line ok = dets:sync(Tab),
- ?line ok = dets:insert(Tab, [{F}]),
+ {ok, Tab} = dets:open_file(Tab, Args),
+ ok = dets:insert(Tab, [{I}]),
+ ok = dets:sync(Tab),
+ ok = dets:insert(Tab, [{F}]),
%% {insert, ...} in the cache, try lookup:
- ?line [{F}] = dets:lookup(Tab, F),
- ?line [{I}] = dets:lookup(Tab, I),
- ?line [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:close(Tab),
+ [{F}] = dets:lookup(Tab, F),
+ [{I}] = dets:lookup(Tab, I),
+ [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
+ ok = dets:close(Tab),
file:delete(File),
- ?line {ok, Tab} = dets:open_file(Tab, Args),
+ {ok, Tab} = dets:open_file(Tab, Args),
%% Both operations in the cache:
- ?line ok = dets:insert(Tab, [{I}]),
- ?line ok = dets:insert(Tab, [{F}]),
- ?line [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
- ?line ok = dets:close(Tab),
+ ok = dets:insert(Tab, [{I}]),
+ ok = dets:insert(Tab, [{F}]),
+ [{I},{F}] = dets_utils:mkeysort(1, dets:match_object(Tab, '_')),
+ ok = dets:close(Tab),
file:delete(File),
ok.
@@ -3753,9 +3762,9 @@ otp_7146(Config) ->
file:delete(File),
Max = 2048,
- ?line {ok, Tab} = dets:open_file(Tab, [{max_no_slots,Max}, {file,File}]),
+ {ok, Tab} = dets:open_file(Tab, [{max_no_slots,Max}, {file,File}]),
write_dets(Tab, Max),
- ?line ok = dets:close(Tab),
+ ok = dets:close(Tab),
file:delete(File),
ok.
@@ -3777,11 +3786,11 @@ otp_8070(Config) when is_list(Config) ->
Tab = otp_8070,
File = filename(Tab, Config),
file:delete(File),
- ?line {ok, _} = dets:open_file(Tab, [{file,File},{type, duplicate_bag}]),
- ?line ok = dets:insert(Tab, [{3,0}]),
- ?line false = dets:insert_new(Tab, [{3,1},{3,1}]),
- ?line [{3,0}] = dets:lookup(Tab, 3),
- ?line ok = dets:close(Tab),
+ {ok, _} = dets:open_file(Tab, [{file,File},{type, duplicate_bag}]),
+ ok = dets:insert(Tab, [{3,0}]),
+ false = dets:insert_new(Tab, [{3,1},{3,1}]),
+ [{3,0}] = dets:lookup(Tab, 3),
+ ok = dets:close(Tab),
file:delete(File),
ok.
@@ -3794,19 +3803,19 @@ otp_8856(Config) when is_list(Config) ->
File = filename(Tab, Config),
file:delete(File),
Me = self(),
- ?line {ok, _} = dets:open_file(Tab, [{type, bag}, {file, File}]),
+ {ok, _} = dets:open_file(Tab, [{type, bag}, {file, File}]),
spawn(fun()-> Me ! {1, dets:insert(Tab, [])} end),
spawn(fun()-> Me ! {2, dets:insert_new(Tab, [])} end),
- ?line ok = dets:close(Tab),
- ?line receive {1, ok} -> ok end,
- ?line receive {2, true} -> ok end,
+ ok = dets:close(Tab),
+ receive {1, ok} -> ok end,
+ receive {2, true} -> ok end,
file:delete(File),
- ?line {ok, _} = dets:open_file(Tab, [{type, set}, {file, File}]),
+ {ok, _} = dets:open_file(Tab, [{type, set}, {file, File}]),
spawn(fun() -> dets:delete(Tab, 0) end),
spawn(fun() -> Me ! {3, dets:insert_new(Tab, {0,0})} end),
- ?line ok = dets:close(Tab),
- ?line receive {3, true} -> ok end,
+ ok = dets:close(Tab),
+ receive {3, true} -> ok end,
file:delete(File),
ok.
@@ -3817,19 +3826,19 @@ otp_8903(suite) ->
otp_8903(Config) when is_list(Config) ->
Tab = otp_8903,
File = filename(Tab, Config),
- ?line {ok,T} = dets:open_file(bug, [{file,File}]),
- ?line ok = dets:insert(T, [{1,a},{2,b},{3,c}]),
- ?line dets:safe_fixtable(T, true),
- ?line {[_],C1} = dets:match_object(T, '_', 1),
- ?line {BC1,_D} = dets:bchunk(T, start),
- ?line ok = dets:close(T),
- ?line {'EXIT', {badarg, _}} = (catch {foo,dets:match_object(C1)}),
- ?line {'EXIT', {badarg, _}} = (catch {foo,dets:bchunk(T, BC1)}),
- ?line {ok,T} = dets:open_file(bug, [{file,File}]),
- ?line false = dets:info(T, safe_fixed),
- ?line {'EXIT', {badarg, _}} = (catch {foo,dets:match_object(C1)}),
- ?line {'EXIT', {badarg, _}} = (catch {foo,dets:bchunk(T, BC1)}),
- ?line ok = dets:close(T),
+ {ok,T} = dets:open_file(bug, [{file,File}]),
+ ok = dets:insert(T, [{1,a},{2,b},{3,c}]),
+ dets:safe_fixtable(T, true),
+ {[_],C1} = dets:match_object(T, '_', 1),
+ {BC1,_D} = dets:bchunk(T, start),
+ ok = dets:close(T),
+ {'EXIT', {badarg, _}} = (catch {foo,dets:match_object(C1)}),
+ {'EXIT', {badarg, _}} = (catch {foo,dets:bchunk(T, BC1)}),
+ {ok,T} = dets:open_file(bug, [{file,File}]),
+ false = dets:info(T, safe_fixed),
+ {'EXIT', {badarg, _}} = (catch {foo,dets:match_object(C1)}),
+ {'EXIT', {badarg, _}} = (catch {foo,dets:bchunk(T, BC1)}),
+ ok = dets:close(T),
file:delete(File),
ok.
@@ -3845,23 +3854,23 @@ otp_8923(Config) when is_list(Config) ->
Bin = list_to_binary([ 0 || _ <- lists:seq(1, 400) ]),
BigBin = list_to_binary([ 0 ||_ <- lists:seq(1, 4000)]),
Ets = ets:new(temp, [{keypos,1}]),
- ?line [ true = ets:insert(Ets, {C,Bin}) || C <- lists:seq(1, 700) ],
- ?line true = ets:insert(Ets, {helper_data,BigBin}),
- ?line true = ets:insert(Ets, {prim_btree,BigBin}),
- ?line true = ets:insert(Ets, {sec_btree,BigBin}),
+ [ true = ets:insert(Ets, {C,Bin}) || C <- lists:seq(1, 700) ],
+ true = ets:insert(Ets, {helper_data,BigBin}),
+ true = ets:insert(Ets, {prim_btree,BigBin}),
+ true = ets:insert(Ets, {sec_btree,BigBin}),
%% Note: too few slots; re-hash will take place
- ?line {ok, Tab} = dets:open_file(Tab, [{file,File}]),
- ?line Tab = ets:to_dets(Ets, Tab),
- ?line ok = dets:close(Tab),
- ?line true = ets:delete(Ets),
+ {ok, Tab} = dets:open_file(Tab, [{file,File}]),
+ Tab = ets:to_dets(Ets, Tab),
+ ok = dets:close(Tab),
+ true = ets:delete(Ets),
- ?line {ok,Ref} = dets:open_file(File),
- ?line [{1,_}] = dets:lookup(Ref, 1),
- ?line ok = dets:close(Ref),
+ {ok,Ref} = dets:open_file(File),
+ [{1,_}] = dets:lookup(Ref, 1),
+ ok = dets:close(Ref),
- ?line {ok,Ref2} = dets:open_file(File),
- ?line [{helper_data,_}] = dets:lookup(Ref2, helper_data),
- ?line ok = dets:close(Ref2),
+ {ok,Ref2} = dets:open_file(File),
+ [{helper_data,_}] = dets:lookup(Ref2, helper_data),
+ ok = dets:close(Ref2),
file:delete(File),
ok.
@@ -3878,87 +3887,16 @@ otp_9282(Config) when is_list(Config) ->
some_calls(Tab, Config) ->
File = filename(ref, Config),
- ?line {ok,T} = dets:open_file(Tab, [{file,File}]),
- ?line T = Tab,
- ?line false = dets:info(T, safe_fixed),
- ?line File = dets:info(T, filename),
- ?line ok = dets:insert(Tab, [{3,0}]),
- ?line [{3,0}] = dets:lookup(Tab, 3),
- ?line [{3,0}] = dets:traverse(Tab, fun(X) -> {continue, X} end),
- ?line ok = dets:close(T),
+ {ok,T} = dets:open_file(Tab, [{file,File}]),
+ T = Tab,
+ false = dets:info(T, safe_fixed),
+ File = dets:info(T, filename),
+ ok = dets:insert(Tab, [{3,0}]),
+ [{3,0}] = dets:lookup(Tab, 3),
+ [{3,0}] = dets:traverse(Tab, fun(X) -> {continue, X} end),
+ ok = dets:close(T),
file:delete(File).
-otp_9607(doc) ->
- ["OTP-9607. Test downgrading the slightly changed format."];
-otp_9607(suite) ->
- [];
-otp_9607(Config) when is_list(Config) ->
- %% Note: the bug is about almost full tables. The fix of that
- %% problem is *not* tested here.
- Version = r13b,
- case ?t:is_release_available(atom_to_list(Version)) of
- true ->
- T = otp_9607,
- File = filename(T, Config),
- Key = a,
- Value = 1,
- Args = [{file,File}],
- ?line {ok, T} = dets:open_file(T, Args),
- ?line ok = dets:insert(T, {Key, Value}),
- ?line ok = dets:close(T),
-
- ?line Call = fun(P, A) ->
- P ! {self(), A},
- receive
- {P, Ans} ->
- Ans
- after 5000 ->
- exit(other_process_dead)
- end
- end,
- %% Create a file on the modified format, read the file
- %% with an emulator that doesn't know about the modified
- %% format.
- ?line {ok, Node} = start_node_rel(Version, Version, slave),
- ?line Pid = rpc:call(Node, erlang, spawn,
- [?MODULE, dets_dirty_loop, []]),
- ?line {error,{needs_repair, File}} =
- Call(Pid, [open, T, Args++[{repair,false}]]),
- io:format("Expect repair:~n"),
- ?line {ok, T} = Call(Pid, [open, T, Args]),
- ?line [{Key,Value}] = Call(Pid, [read, T, Key]),
- ?line ok = Call(Pid, [close, T]),
- file:delete(File),
-
- %% Create a file on the unmodified format. Modify the file
- %% using an emulator that must not turn the file into the
- %% modified format. Read the file and make sure it is not
- %% repaired.
- ?line {ok, T} = Call(Pid, [open, T, Args]),
- ?line ok = Call(Pid, [write, T, {Key,Value}]),
- ?line [{Key,Value}] = Call(Pid, [read, T, Key]),
- ?line ok = Call(Pid, [close, T]),
-
- Key2 = b,
- Value2 = 2,
-
- ?line {ok, T} = dets:open_file(T, Args),
- ?line [{Key,Value}] = dets:lookup(T, Key),
- ?line ok = dets:insert(T, {Key2,Value2}),
- ?line ok = dets:close(T),
-
- ?line {ok, T} = Call(Pid, [open, T, Args++[{repair,false}]]),
- ?line [{Key2,Value2}] = Call(Pid, [read, T, Key2]),
- ?line ok = Call(Pid, [close, T]),
-
- ?t:stop_node(Node),
- file:delete(File),
- ok;
- false ->
- {skipped, "No support for old node"}
- end.
-
-
%%
%% Parts common to several test cases
@@ -3966,21 +3904,21 @@ otp_9607(Config) when is_list(Config) ->
start_node_rel(Name, Rel, How) ->
Release = [{release, atom_to_list(Rel)}],
- ?line Pa = filename:dirname(code:which(?MODULE)),
- ?line test_server:start_node(Name, How,
- [{args,
- " -kernel net_setuptime 100 "
- " -pa " ++ Pa},
- {erl, Release}]).
+ Pa = filename:dirname(code:which(?MODULE)),
+ test_server:start_node(Name, How,
+ [{args,
+ " -kernel net_setuptime 100 "
+ " -pa " ++ Pa},
+ {erl, Release}]).
crash(File, Where) ->
crash(File, Where, 10).
crash(File, Where, What) when is_integer(What) ->
- ?line {ok, Fd} = file:open(File, [read,write]),
- ?line file:position(Fd, Where),
- ?line ok = file:write(Fd, [What]),
- ?line ok = file:close(Fd).
+ {ok, Fd} = file:open(File, [read,write]),
+ file:position(Fd, Where),
+ ok = file:write(Fd, [What]),
+ ok = file:close(Fd).
args(Config) ->
{Sets, Bags, Dups} =
@@ -4035,56 +3973,56 @@ zip_filename([], [], [], S1, B1, D1, _, _Conf) ->
del_test(Tab) ->
?format("Deltest on ~p~n", [Tab]),
- ?line Objs = safe_get_all_objects(Tab),
- ?line Keys = map(fun(X) -> element(1, X) end, Objs),
- ?line foreach(fun(Key) -> dets:delete(Tab, Key) end, Keys),
- ?line 0 = length(get_all_objects(Tab)),
- ?line [] = get_all_objects_fast(Tab),
- ?line 0 = dets:info(Tab, size).
+ Objs = safe_get_all_objects(Tab),
+ Keys = map(fun(X) -> element(1, X) end, Objs),
+ foreach(fun(Key) -> dets:delete(Tab, Key) end, Keys),
+ 0 = length(get_all_objects(Tab)),
+ [] = get_all_objects_fast(Tab),
+ 0 = dets:info(Tab, size).
del_obj_test(Tab) ->
?format("Delobjtest on ~p~n", [Tab]),
- ?line Objs = safe_get_all_objects(Tab),
- ?line LL = length(Objs),
- ?line LL = dets:info(Tab, size),
- ?line foreach(fun(Obj) -> dets:delete_object(Tab, Obj) end, Objs),
- ?line 0 = length(get_all_objects(Tab)),
- ?line [] = get_all_objects_fast(Tab),
- ?line 0 = dets:info(Tab, size).
+ Objs = safe_get_all_objects(Tab),
+ LL = length(Objs),
+ LL = dets:info(Tab, size),
+ foreach(fun(Obj) -> dets:delete_object(Tab, Obj) end, Objs),
+ 0 = length(get_all_objects(Tab)),
+ [] = get_all_objects_fast(Tab),
+ 0 = dets:info(Tab, size).
match_del_test(Tab) ->
- ?line ?format("Match delete test on ~p~n", [Tab]),
- ?line ok = dets:match_delete(Tab, {'_','_','_'}),
- ?line Sz = dets:info(Tab, size),
- ?line true = Sz =:= length(dets:match_object(Tab, '_')),
- ?line ok = dets:match_delete(Tab, '_'),
- ?line 0 = dets:info(Tab, size),
- ?line 0 = length(get_all_objects(Tab)),
- ?line [] = get_all_objects_fast(Tab).
+ ?format("Match delete test on ~p~n", [Tab]),
+ ok = dets:match_delete(Tab, {'_','_','_'}),
+ Sz = dets:info(Tab, size),
+ true = Sz =:= length(dets:match_object(Tab, '_')),
+ ok = dets:match_delete(Tab, '_'),
+ 0 = dets:info(Tab, size),
+ 0 = length(get_all_objects(Tab)),
+ [] = get_all_objects_fast(Tab).
trav_test(_Data, Len, Tab) ->
?format("Travtest on ~p~n", [Tab]),
- ?line _X0 = dets:traverse(Tab, fun(_X) -> continue end),
- ?line XX = dets:traverse(Tab, fun(X) -> {continue, X} end),
- ?line case Len =:= length(XX) of
+ _X0 = dets:traverse(Tab, fun(_X) -> continue end),
+ XX = dets:traverse(Tab, fun(X) -> {continue, X} end),
+ case Len =:= length(XX) of
false -> ?format("DIFF ~p~n", [XX -- _Data]);
true -> ok
end,
- ?line 1 = length(dets:traverse(Tab, fun(X) -> {done, X} end)).
+ 1 = length(dets:traverse(Tab, fun(X) -> {done, X} end)).
match_test(Data, Tab) ->
- ?line ?format("Match test on ~p~n", [Tab]),
- ?line Data1 = sort(filter(fun(X) when tuple_size(X) =:= 3 -> true;
- (_X) -> false
- end, Data)),
- ?line Data1 = sort(dets:match_object(Tab, {'$1', '$2', '$3'})),
-
- ?line Len = length(Data),
- ?line Len = length(dets:match(Tab, '_')),
- ?line Len2 = length(Data1),
- ?line Len2 = length(dets:match(Tab, {'$1', '_', '_'})),
+ ?format("Match test on ~p~n", [Tab]),
+ Data1 = sort(filter(fun(X) when tuple_size(X) =:= 3 -> true;
+ (_X) -> false
+ end, Data)),
+ Data1 = sort(dets:match_object(Tab, {'$1', '$2', '$3'})),
+
+ Len = length(Data),
+ Len = length(dets:match(Tab, '_')),
+ Len2 = length(Data1),
+ Len2 = length(dets:match(Tab, {'$1', '_', '_'})),
- ?line Data3 =
+ Data3 =
filter(fun(X) ->
K = element(1, X),
if
@@ -4092,14 +4030,14 @@ match_test(Data, Tab) ->
true -> false
end
end, Data),
- ?line Len3 = length(Data3),
- ?line Len3 = length(dets:match(Tab, {{'$1', '$2'}, '_', '_'})),
- ?line Len3 = length(dets:match_object(Tab, {{'$1', '$2'}, '_', '_'})),
+ Len3 = length(Data3),
+ Len3 = length(dets:match(Tab, {{'$1', '$2'}, '_', '_'})),
+ Len3 = length(dets:match_object(Tab, {{'$1', '$2'}, '_', '_'})),
- ?line R = make_ref(),
- ?line dets:insert(Tab, {{R, R}, 33 ,44}),
- ?line 1 = length(dets:match(Tab, {{R, R}, '_', '_'})),
- ?line 1 = length(dets:match_object(Tab, {{R, R}, '_', '_'})).
+ R = make_ref(),
+ dets:insert(Tab, {{R, R}, 33 ,44}),
+ 1 = length(dets:match(Tab, {{R, R}, '_', '_'})),
+ 1 = length(dets:match_object(Tab, {{R, R}, '_', '_'})).
%%
%% Utilities
@@ -4111,20 +4049,20 @@ headsz(_) ->
?HEADSZ_v9.
unwritable(Fname) ->
- ?line {ok, Info} = file:read_file_info(Fname),
+ {ok, Info} = file:read_file_info(Fname),
Mode = Info#file_info.mode - 8#00200,
- ?line file:write_file_info(Fname, Info#file_info{mode = Mode}).
+ file:write_file_info(Fname, Info#file_info{mode = Mode}).
writable(Fname) ->
- ?line {ok, Info} = file:read_file_info(Fname),
+ {ok, Info} = file:read_file_info(Fname),
Mode = Info#file_info.mode bor 8#00200,
- ?line file:write_file_info(Fname, Info#file_info{mode = Mode}).
+ file:write_file_info(Fname, Info#file_info{mode = Mode}).
truncate(File, Where) ->
- ?line {ok, Fd} = file:open(File, [read,write]),
- ?line file:position(Fd, Where),
- ?line ok = file:truncate(Fd),
- ?line ok = file:close(Fd).
+ {ok, Fd} = file:open(File, [read,write]),
+ file:position(Fd, Where),
+ ok = file:truncate(Fd),
+ ok = file:close(Fd).
new_filename(Name, _Config) when is_integer(Name) ->
filename:join(?privdir(_Config),
@@ -4139,8 +4077,8 @@ open_files(_Name, [], _Version) ->
[];
open_files(Name0, [Args | Tail], Version) ->
?format("init ~p~n", [Args]),
- ?line Name = list_to_atom(integer_to_list(Name0)),
- ?line {ok, Name} = dets:open_file(Name, [{version,Version} | Args]),
+ Name = list_to_atom(integer_to_list(Name0)),
+ {ok, Name} = dets:open_file(Name, [{version,Version} | Args]),
[Name | open_files(Name0+1, Tail, Version)].
close_all(Tabs) -> foreach(fun(Tab) -> ok = dets:close(Tab) end, Tabs).
@@ -4155,11 +4093,11 @@ delete_files(Args) ->
%% Initialize all tables
initialize(Tabs, Data) ->
- ?line foreach(fun(Tab) ->
- Fun = fun(Obj) -> ok = dets:insert(Tab, Obj) end,
- foreach(Fun, Data),
- dets:sync(Tab)
- end, Tabs).
+ foreach(fun(Tab) ->
+ Fun = fun(Obj) -> ok = dets:insert(Tab, Obj) end,
+ foreach(Fun, Data),
+ dets:sync(Tab)
+ end, Tabs).
%% need more than 512 objects to really trig overflow
make_data(Kp) ->
@@ -4232,9 +4170,9 @@ ensure_node(N, Node) ->
end.
size_test(Len, Tabs) ->
- ?line foreach(fun(Tab) ->
- Len = dets:info(Tab, size)
- end, Tabs).
+ foreach(fun(Tab) ->
+ Len = dets:info(Tab, size)
+ end, Tabs).
no_keys_test([T | Ts]) ->
no_keys_test(T),
@@ -4247,15 +4185,15 @@ no_keys_test(T) ->
ok;
9 ->
Kp = dets:info(T, keypos),
- ?line All = dets:match_object(T, '_'),
- ?line L = lists:map(fun(X) -> element(Kp, X) end, All),
- ?line NoKeys = length(lists:usort(L)),
- ?line case {dets:info(T, no_keys), NoKeys} of
- {N, N} ->
- ok;
- {N1, N2} ->
- exit({no_keys_test, N1, N2})
- end
+ All = dets:match_object(T, '_'),
+ L = lists:map(fun(X) -> element(Kp, X) end, All),
+ NoKeys = length(lists:usort(L)),
+ case {dets:info(T, no_keys), NoKeys} of
+ {N, N} ->
+ ok;
+ {N1, N2} ->
+ exit({no_keys_test, N1, N2})
+ end
end.
safe_get_all_objects(Tab) ->
@@ -4270,13 +4208,13 @@ get_all_objects(Tab) -> get_all_objects(dets:first(Tab), Tab, []).
%% Assuming no key matches {error, Reason}...
get_all_objects('$end_of_table', _Tab, L) -> L;
get_all_objects({error, Reason}, _Tab, _L) ->
- exit({get_all_objects, get(line), {error, Reason}});
+ exit({get_all_objects, {error, Reason}});
get_all_objects(Key, Tab, L) ->
Objs = dets:lookup(Tab, Key),
- ?line get_all_objects(dets:next(Tab, Key), Tab, Objs ++ L).
+ get_all_objects(dets:next(Tab, Key), Tab, Objs ++ L).
count_objects_quite_fast(Tab) ->
- ?line R1 = dets:match_object(Tab, '_', 1),
+ R1 = dets:match_object(Tab, '_', 1),
count_objs_1(R1, 0).
count_objs_1('$end_of_table', N) ->
@@ -4296,42 +4234,42 @@ histogram(Tab) ->
histogram(Tab, OnePercent).
histogram(Tab, OnePercent) ->
- ?line E = ets:new(histo, []),
- ?line dets:safe_fixtable(Tab, true),
- ?line Hist = histo(Tab, E, 0, OnePercent, OnePercent),
- ?line dets:safe_fixtable(Tab, false),
- ?line case Hist of
- ok ->
- ?line H = ets:tab2list(E),
- ?line true = ets:delete(E),
- sort(H);
- Error ->
- ets:delete(E),
- Error
- end.
+ E = ets:new(histo, []),
+ dets:safe_fixtable(Tab, true),
+ Hist = histo(Tab, E, 0, OnePercent, OnePercent),
+ dets:safe_fixtable(Tab, false),
+ case Hist of
+ ok ->
+ H = ets:tab2list(E),
+ true = ets:delete(E),
+ sort(H);
+ Error ->
+ ets:delete(E),
+ Error
+ end.
histo(T, E, I, One, Count) when is_number(Count), I > Count ->
io:format("."),
histo(T, E, I, One, Count+One);
histo(T, E, I, One, Count) ->
- ?line case dets:slot(T, I) of
- '$end_of_table' when is_number(Count) ->
- io:format("~n"),
- ok;
- '$end_of_table' ->
- ok;
- Objs when is_list(Objs) ->
- L = length(Objs),
- case catch ets:update_counter(E, L, 1) of
- {'EXIT', _} ->
- ets:insert(E, {L, 1});
- _ ->
- ok
- end,
- histo(T, E, I+1, One, Count);
- Error ->
- Error
- end.
+ case dets:slot(T, I) of
+ '$end_of_table' when is_number(Count) ->
+ io:format("~n"),
+ ok;
+ '$end_of_table' ->
+ ok;
+ Objs when is_list(Objs) ->
+ L = length(Objs),
+ case catch ets:update_counter(E, L, 1) of
+ {'EXIT', _} ->
+ ets:insert(E, {L, 1});
+ _ ->
+ ok
+ end,
+ histo(T, E, I+1, One, Count);
+ Error ->
+ Error
+ end.
sum_histogram(H) ->
sum_histogram(H, 0).
diff --git a/lib/stdlib/test/dict_SUITE.erl b/lib/stdlib/test/dict_SUITE.erl
index c46fc47b34..0223240479 100644
--- a/lib/stdlib/test/dict_SUITE.erl
+++ b/lib/stdlib/test/dict_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2013. 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
@@ -53,7 +53,7 @@ end_per_group(_GroupName, Config) ->
init_per_testcase(_Case, Config) ->
- ?line Dog = ?t:timetrap(?t:minutes(5)),
+ Dog = ?t:timetrap(?t:minutes(5)),
[{watchdog,Dog}|Config].
end_per_testcase(_Case, Config) ->
@@ -65,22 +65,22 @@ create(Config) when is_list(Config) ->
test_all(fun create_1/1).
create_1(M) ->
- ?line D0 = M:empty(),
- ?line [] = M:to_list(D0),
- ?line 0 = M:size(D0),
+ D0 = M(empty, []),
+ [] = M(to_list, D0),
+ 0 = M(size, D0),
D0.
store(Config) when is_list(Config) ->
test_all([{0,132},{253,258},{510,514}], fun store_1/2).
store_1(List, M) ->
- ?line D0 = M:from_list(List),
+ D0 = M(from_list, List),
%% Make sure that we get the same result by inserting
%% elements one at the time.
- ?line D1 = foldl(fun({K,V}, Dict) -> M:enter(K, V, Dict) end,
- M:empty(), List),
- ?line true = M:equal(D0, D1),
+ D1 = foldl(fun({K,V}, Dict) -> M(enter, {K,V,Dict}) end,
+ M(empty, []), List),
+ true = M(equal, {D0,D1}),
D0.
%%%
@@ -98,7 +98,7 @@ dict_mods() ->
[Orddict,Dict,Gb].
test_all(Tester) ->
- ?line Pids = [spawn_tester(M, Tester) || M <- dict_mods()],
+ Pids = [spawn_tester(M, Tester) || M <- dict_mods()],
collect_all(Pids, []).
spawn_tester(M, Tester) ->
@@ -106,7 +106,7 @@ spawn_tester(M, Tester) ->
spawn_link(fun() ->
random:seed(1, 2, 42),
S = Tester(M),
- Res = {M:size(S),lists:sort(M:to_list(S))},
+ Res = {M(size, S),lists:sort(M(to_list, S))},
Parent ! {result,self(),Res}
end).
diff --git a/lib/stdlib/test/dict_test_lib.erl b/lib/stdlib/test/dict_test_lib.erl
index 92a75dad89..e308fd0721 100644
--- a/lib/stdlib/test/dict_test_lib.erl
+++ b/lib/stdlib/test/dict_test_lib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2013. 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
@@ -17,67 +17,48 @@
%% %CopyrightEnd%
%%
--module(dict_test_lib, [Mod,Equal]).
+-module(dict_test_lib).
--export([module/0,equal/2,empty/0,size/1,to_list/1,from_list/1,
- enter/3,delete/2,lookup/2]).
+-export([new/2]).
-module() ->
- Mod.
-
-equal(X, Y) ->
- Equal(X, Y).
+new(Mod, Eq) ->
+ fun (enter, {K,V,D}) -> enter(Mod, K, V, D);
+ (empty, []) -> empty(Mod);
+ (equal, {D1,D2}) -> Eq(D1, D2);
+ (from_list, L) -> from_list(Mod, L);
+ (module, []) -> Mod;
+ (size, D) -> Mod:size(D);
+ (to_list, D) -> to_list(Mod, D)
+ end.
-empty() ->
+empty(Mod) ->
case erlang:function_exported(Mod, new, 0) of
false -> Mod:empty();
true -> Mod:new()
end.
-size(S) ->
- Mod:size(S).
-
-to_list(S) ->
- Mod:to_list(S).
+to_list(Mod, D) ->
+ Mod:to_list(D).
-from_list(S) ->
+from_list(Mod, L) ->
case erlang:function_exported(Mod, from_orddict, 1) of
false ->
- Mod:from_list(S);
+ Mod:from_list(L);
true ->
%% The gb_trees module has no from_list/1 function.
%%
%% The keys in S are not unique. To make sure
%% that we pick the same key/value pairs as
%% dict/orddict, first convert the list to an orddict.
- Orddict = orddict:from_list(S),
+ Orddict = orddict:from_list(L),
Mod:from_orddict(Orddict)
end.
%% Store new value into dictionary or update previous value in dictionary.
-enter(Key, Val, Dict) ->
+enter(Mod, Key, Val, Dict) ->
case erlang:function_exported(Mod, store, 3) of
false ->
Mod:enter(Key, Val, Dict);
true ->
Mod:store(Key, Val, Dict)
end.
-
-%% Delete an EXISTING key.
-delete(Key, Dict) ->
- case erlang:function_exported(Mod, delete, 2) of
- true -> Mod:delete(Key, Dict);
- false -> Mod:erase(Key, Dict)
- end.
-
-%% -> none | {value,Value}
-lookup(Key, Dict) ->
- case erlang:function_exported(Mod, lookup, 2) of
- false ->
- case Mod:find(Key, Dict) of
- error -> none;
- {ok,Value} -> {value,Value}
- end;
- true ->
- Mod:lookup(Key, Dict)
- end.
diff --git a/lib/stdlib/test/digraph_SUITE.erl b/lib/stdlib/test/digraph_SUITE.erl
index 1d1326d60e..ed01b32a59 100644
--- a/lib/stdlib/test/digraph_SUITE.erl
+++ b/lib/stdlib/test/digraph_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. 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
@@ -400,7 +400,7 @@ sane1(G) ->
lists:foreach(
fun(V) ->
InEs = digraph:in_edges(G, V),
- %% Nu har man *alla* inkanter f�r V
+ %% *All* in-edoges of V
lists:foreach(
fun(E) ->
case digraph:edge(G, E) of
diff --git a/lib/stdlib/test/epp_SUITE.erl b/lib/stdlib/test/epp_SUITE.erl
index f79414db49..0cbdf76270 100644
--- a/lib/stdlib/test/epp_SUITE.erl
+++ b/lib/stdlib/test/epp_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. 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
@@ -25,7 +25,7 @@
variable_1/1, otp_4870/1, otp_4871/1, otp_5362/1,
pmod/1, not_circular/1, skip_header/1, otp_6277/1, otp_7702/1,
otp_8130/1, overload_mac/1, otp_8388/1, otp_8470/1, otp_8503/1,
- otp_8562/1, otp_8665/1, otp_8911/1]).
+ otp_8562/1, otp_8665/1, otp_8911/1, otp_10302/1, otp_10820/1]).
-export([epp_parse_erl_form/2]).
@@ -67,7 +67,7 @@ all() ->
{group, variable}, otp_4870, otp_4871, otp_5362, pmod,
not_circular, skip_header, otp_6277, otp_7702, otp_8130,
overload_mac, otp_8388, otp_8470, otp_8503, otp_8562,
- otp_8665, otp_8911].
+ otp_8665, otp_8911, otp_10302, otp_10820].
groups() ->
[{upcase_mac, [], [upcase_mac_1, upcase_mac_2]},
@@ -104,6 +104,8 @@ include_local(suite) ->
include_local(Config) when is_list(Config) ->
?line DataDir = ?config(data_dir, Config),
?line File = filename:join(DataDir, "include_local.erl"),
+ FooHrl = filename:join([DataDir,"include","foo.hrl"]),
+ BarHrl = filename:join([DataDir,"include","bar.hrl"]),
%% include_local.erl includes include/foo.hrl which
%% includes bar.hrl (also in include/) without requiring
%% any additional include path, and overriding any file
@@ -111,6 +113,8 @@ include_local(Config) when is_list(Config) ->
?line {ok, List} = epp:parse_file(File, [DataDir], []),
?line {value, {attribute,_,a,{true,true}}} =
lists:keysearch(a,3,List),
+ [{File,1},{FooHrl,1},{BarHrl,1},{FooHrl,5},{File,5}] =
+ [ FileLine || {attribute,_,file,FileLine} <- List ],
ok.
%%% Here is a little reimplementation of epp:parse_file, which times out
@@ -582,12 +586,13 @@ otp_8130(suite) ->
otp_8130(Config) when is_list(Config) ->
true = os:putenv("epp_inc1", "stdlib"),
Ts = [{otp_8130_1,
- %% The scanner handles UNICODE in a special way. Hopefully
- %% temporarily.
<<"-define(M(A), ??A). "
"t() -> "
- " \"{ 34 , [ $1 , 2730 ] , \\\"34\\\" , X . a , 2730 }\" = "
- " ?M({34,\"1\\x{aaa}\",\"34\",X.a,$\\x{aaa}}), ok. ">>,
+ " L = \"{ 34 , \\\"1\\\\x{AAA}\\\" , \\\"34\\\" , X . a , $\\\\x{AAA} }\", "
+ " R = ?M({34,\"1\\x{aaa}\",\"34\",X.a,$\\x{aaa}}),"
+ " Lt = erl_scan:string(L, 1, [unicode]),"
+ " Rt = erl_scan:string(R, 1, [unicode]),"
+ " Lt = Rt, ok. ">>,
ok},
{otp_8130_2,
@@ -1236,6 +1241,13 @@ otp_8911(doc) ->
otp_8911(suite) ->
[];
otp_8911(Config) when is_list(Config) ->
+ case test_server:is_cover() of
+ true ->
+ {skip, "Testing cover, so can not run when cover is already running"};
+ false ->
+ do_otp_8911(Config)
+ end.
+do_otp_8911(Config) ->
?line {ok, CWD} = file:get_cwd(),
?line ok = file:set_cwd(?config(priv_dir, Config)),
@@ -1277,6 +1289,104 @@ otp_8665(Config) when is_list(Config) ->
?line [] = compile(Config, Cs),
ok.
+otp_10302(doc) ->
+ "OTP-10302. Unicode characters scanner/parser.";
+otp_10302(suite) ->
+ [];
+otp_10302(Config) when is_list(Config) ->
+ %% Two messages (one too many). Keeps otp_4871 happy.
+ Cs = [{otp_8562,
+ <<"%% coding: utf-8\n \n \x{E4}">>,
+ {errors,[{3,epp,cannot_parse},
+ {3,file_io_server,invalid_unicode}],[]}}
+ ],
+ [] = compile(Config, Cs),
+ Dir = ?config(priv_dir, Config),
+ File = filename:join(Dir, "otp_10302.erl"),
+ utf8 = encoding("coding: utf-8", File),
+ utf8 = encoding("coding: UTF-8", File),
+ latin1 = encoding("coding: Latin-1", File),
+ latin1 = encoding("coding: latin-1", File),
+ none = encoding_com("coding: utf-8", File),
+ none = encoding_com("\n\n%% coding: utf-8", File),
+ none = encoding_nocom("\n\n coding: utf-8", File),
+ utf8 = encoding_com("\n%% coding: utf-8", File),
+ utf8 = encoding_nocom("\n coding: utf-8", File),
+ none = encoding("coding: \nutf-8", File),
+ latin1 = encoding("Encoding : latin-1", File),
+ utf8 = encoding("ccoding: UTF-8", File),
+ utf8 = encoding("coding= utf-8", File),
+ utf8 = encoding_com(" %% coding= utf-8", File),
+ utf8 = encoding("coding = utf-8", File),
+ none = encoding("coding: utf-16 coding: utf-8", File), %first is bad
+ none = encoding("Coding: utf-8", File), %capital c
+ utf8 = encoding("-*- coding: utf-8 -*-", File),
+ utf8 = encoding("-*-coding= utf-8-*-", File),
+ utf8 = encoding("codingcoding= utf-8", File),
+ ok = prefix("coding: utf-8", File, utf8),
+
+ "coding: latin-1" = epp:encoding_to_string(latin1),
+ "coding: utf-8" = epp:encoding_to_string(utf8),
+ true = lists:member(epp:default_encoding(), [latin1, utf8]),
+
+ ok.
+
+prefix(S, File, Enc) ->
+ prefix(0, S, File, Enc).
+
+prefix(100, _S, _File, _) ->
+ ok;
+prefix(N, S, File, Enc) ->
+ Enc = encoding(lists:duplicate(N, $\s) ++ S, File),
+ prefix(N+1, S, File, Enc).
+
+encoding(Enc, File) ->
+ E = encoding_com("%% " ++ Enc, File),
+ none = encoding_com(Enc, File),
+ E = encoding_nocom(Enc, File).
+
+encoding_com(Enc, File) ->
+ B = list_to_binary(Enc),
+ E = epp:read_encoding_from_binary(B),
+ ok = file:write_file(File, Enc),
+ {ok, Fd} = file:open(File, [read]),
+ E = epp:set_encoding(Fd),
+ ok = file:close(Fd),
+ E = epp:read_encoding(File).
+
+encoding_nocom(Enc, File) ->
+ Options = [{in_comment_only, false}],
+ B = list_to_binary(Enc),
+ E = epp:read_encoding_from_binary(B, Options),
+ ok = file:write_file(File, Enc),
+ {ok, Fd} = file:open(File, [read]),
+ ok = file:close(Fd),
+ E = epp:read_encoding(File, Options).
+
+otp_10820(doc) ->
+ "OTP-10820. Unicode filenames.";
+otp_10820(suite) ->
+ [];
+otp_10820(Config) when is_list(Config) ->
+ L = [915,953,959,973,957,953,954,959,957,964],
+ Dir = ?config(priv_dir, Config),
+ File = filename:join(Dir, L++".erl"),
+ C1 = <<"%% coding: utf-8\n -module(any).">>,
+ ok = do_otp_10820(File, C1, "+pc latin1"),
+ ok = do_otp_10820(File, C1, "+pc unicode"),
+ C2 = <<"\n-module(any).">>,
+ ok = do_otp_10820(File, C2, "+pc latin1"),
+ ok = do_otp_10820(File, C2, "+pc unicode").
+
+do_otp_10820(File, C, PC) ->
+ {ok,Node} = start_node(erl_pp_helper, "+fnu " ++ PC),
+ ok = rpc:call(Node, file, write_file, [File, C]),
+ {ok,[{attribute,1,file,{File,1}},
+ {attribute,2,module,any},
+ {eof,2}]} = rpc:call(Node, epp, parse_file, [File, [],[]]),
+ true = test_server:stop_node(Node),
+ ok.
+
check(Config, Tests) ->
eval_tests(Config, fun check_test/2, Tests).
@@ -1393,3 +1503,8 @@ ln2({error,M}) ->
{error,ln2(M)};
ln2(M) ->
M.
+
+%% +fnu means a peer node has to be started; slave will not do
+start_node(Name, Xargs) ->
+ ?line PA = filename:dirname(code:which(?MODULE)),
+ test_server:start_node(Name, peer, [{args, "-pa " ++ PA ++ " " ++ Xargs}]).
diff --git a/lib/stdlib/test/erl_eval_SUITE.erl b/lib/stdlib/test/erl_eval_SUITE.erl
index b0c7d562d5..18ec17a4bf 100644
--- a/lib/stdlib/test/erl_eval_SUITE.erl
+++ b/lib/stdlib/test/erl_eval_SUITE.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. 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
@@ -37,6 +38,7 @@
otp_6977/1,
otp_7550/1,
otp_8133/1,
+ otp_10622/1,
funs/1,
try_catch/1,
eval_expr_5/1,
@@ -79,7 +81,7 @@ all() ->
pattern_expr, match_bin, guard_3, guard_4, lc,
simple_cases, unary_plus, apply_atom, otp_5269,
otp_6539, otp_6543, otp_6787, otp_6977, otp_7550,
- otp_8133, funs, try_catch, eval_expr_5, zero_width].
+ otp_8133, otp_10622, funs, try_catch, eval_expr_5, zero_width].
groups() ->
[].
@@ -216,13 +218,13 @@ guard_4(doc) ->
guard_4(suite) ->
[];
guard_4(Config) when is_list(Config) ->
- ?line check(fun() -> if {erlang,'+'}(3,a) -> true ; true -> false end end,
- "if {erlang,'+'}(3,a) -> true ; true -> false end.",
- false),
- ?line check(fun() -> if {erlang,is_integer}(3) -> true ; true -> false end
- end,
- "if {erlang,is_integer}(3) -> true ; true -> false end.",
- true),
+ check(fun() -> if erlang:'+'(3,a) -> true ; true -> false end end,
+ "if erlang:'+'(3,a) -> true ; true -> false end.",
+ false),
+ check(fun() -> if erlang:is_integer(3) -> true ; true -> false end
+ end,
+ "if erlang:is_integer(3) -> true ; true -> false end.",
+ true),
?line check(fun() -> [X || X <- [1,2,3], erlang:is_integer(X)] end,
"[X || X <- [1,2,3], erlang:is_integer(X)].",
[1,2,3]),
@@ -230,11 +232,11 @@ guard_4(Config) when is_list(Config) ->
end,
"if is_atom(is_integer(a)) -> true ; true -> false end.",
true),
- ?line check(fun() -> if {erlang,is_atom}({erlang,is_integer}(a)) -> true;
- true -> false end end,
- "if {erlang,is_atom}({erlang,is_integer}(a)) -> true; "
- "true -> false end.",
- true),
+ check(fun() -> if erlang:is_atom(erlang:is_integer(a)) -> true;
+ true -> false end end,
+ "if erlang:is_atom(erlang:is_integer(a)) -> true; "
+ "true -> false end.",
+ true),
?line check(fun() -> if is_atom(3+a) -> true ; true -> false end end,
"if is_atom(3+a) -> true ; true -> false end.",
false),
@@ -960,6 +962,7 @@ otp_8133(Config) when is_list(Config) ->
E = fun(N) ->
if
is_integer(N) -> <<N/integer>>;
+
true -> erlang:error(foo)
end
end,
@@ -980,6 +983,48 @@ otp_8133(Config) when is_list(Config) ->
ok),
ok.
+otp_10622(doc) ->
+ ["OTP-10622. Bugs."];
+otp_10622(suite) ->
+ [];
+otp_10622(Config) when is_list(Config) ->
+ check(fun() -> <<0>> = <<"\x{400}">> end,
+ "<<0>> = <<\"\\x{400}\">>. ",
+ <<0>>),
+ check(fun() -> <<"\x{aa}ff"/utf8>> = <<"\x{aa}ff"/utf8>> end,
+ "<<\"\\x{aa}ff\"/utf8>> = <<\"\\x{aa}ff\"/utf8>>. ",
+ <<"Â\xaaff">>),
+ %% The same bug as last example:
+ check(fun() -> case <<"foo"/utf8>> of
+ <<"foo"/utf8>> -> true
+ end
+ end,
+ "case <<\"foo\"/utf8>> of <<\"foo\"/utf8>> -> true end.",
+ true),
+ check(fun() -> <<"\x{400}"/utf8>> = <<"\x{400}"/utf8>> end,
+ "<<\"\\x{400}\"/utf8>> = <<\"\\x{400}\"/utf8>>. ",
+ <<208,128>>),
+ error_check("<<\"\\x{aaa}\">> = <<\"\\x{aaa}\">>.",
+ {badmatch,<<"\xaa">>}),
+
+ check(fun() -> [a || <<"\x{aaa}">> <= <<2703:16>>] end,
+ "[a || <<\"\\x{aaa}\">> <= <<2703:16>>]. ",
+ []),
+ check(fun() -> [a || <<"\x{aa}"/utf8>> <= <<"\x{aa}"/utf8>>] end,
+ "[a || <<\"\\x{aa}\"/utf8>> <= <<\"\\x{aa}\"/utf8>>]. ",
+ [a]),
+ check(fun() -> [a || <<"\x{aa}x"/utf8>> <= <<"\x{aa}y"/utf8>>] end,
+ "[a || <<\"\\x{aa}x\"/utf8>> <= <<\"\\x{aa}y\"/utf8>>]. ",
+ []),
+ check(fun() -> [a || <<"\x{aaa}">> <= <<"\x{aaa}">>] end,
+ "[a || <<\"\\x{aaa}\">> <= <<\"\\x{aaa}\">>]. ",
+ []),
+ check(fun() -> [a || <<"\x{aaa}"/utf8>> <= <<"\x{aaa}"/utf8>>] end,
+ "[a || <<\"\\x{aaa}\"/utf8>> <= <<\"\\x{aaa}\"/utf8>>]. ",
+ [a]),
+
+ ok.
+
funs(doc) ->
["Simple cases, just to cover some code."];
funs(suite) ->
@@ -1042,6 +1087,10 @@ funs(Config) when is_list(Config) ->
"begin M = lists, F = fun M:reverse/1,"
" [1,2] = F([2,1]), ok end.",
ok),
+
+ %% Test that {M,F} is not accepted as a fun.
+ error_check("{" ?MODULE_STRING ",module_info}().",
+ {badfun,{?MODULE,module_info}}),
ok.
run_many_args({S, As}) ->
@@ -1077,11 +1126,6 @@ do_funs(LFH, EFH) ->
concat(["begin F1 = fun(F,N) -> apply(", M,
",count_down,[F, N]) end, F1(F1,1000) end."]),
0, ['F1'], LFH, EFH),
- ?line check(fun() -> F1 = fun(F,N) -> {?MODULE,count_down}(F,N)
- end, F1(F1, 1000) end,
- concat(["begin F1 = fun(F,N) -> {", M,
- ",count_down}(F, N) end, F1(F1,1000) end."]),
- 0, ['F1'], LFH, EFH),
?line check(fun() -> F = fun(F,N) when N > 0 -> apply(F,[F,N-1]);
(_F,0) -> ok end,
F(F, 1000)
@@ -1113,11 +1157,11 @@ do_funs(LFH, EFH) ->
true = {2,3} == F(2) end,
"begin F = fun(X) -> A = 1+X, {X,A} end,
true = {2,3} == F(2) end.", true, ['F'], LFH, EFH),
- ?line check(fun() -> F = fun(X) -> {erlang,'+'}(X,2) end,
- true = 3 == F(1) end,
- "begin F = fun(X) -> {erlang,'+'}(X,2) end,"
- " true = 3 == F(1) end.", true, ['F'],
- LFH, EFH),
+ check(fun() -> F = fun(X) -> erlang:'+'(X,2) end,
+ true = 3 == F(1) end,
+ "begin F = fun(X) -> erlang:'+'(X,2) end,"
+ " true = 3 == F(1) end.", true, ['F'],
+ LFH, EFH),
?line check(fun() -> F = fun(X) -> byte_size(X) end,
?MODULE:do_apply(F,<<"hej">>) end,
concat(["begin F = fun(X) -> size(X) end,",
@@ -1165,24 +1209,6 @@ do_funs(LFH, EFH) ->
concat(["begin F = fun(F, N) -> [", M,
":count_down(F,N) || X <-[1]] end, F(F,2) end."]),
[[[0]]], ['F'], LFH, EFH),
-
- %% Tests for a bug found by the Dialyzer - used to crash.
- case test_server:is_native(erl_eval) of
- true ->
- %% Parameterized modules are not supported by HiPE.
- ok;
- false ->
- check(fun() -> Pmod = erl_eval_helper:new(42), Pmod:add(5) end,
- "begin Pmod = erl_eval_helper:new(42), Pmod:add(5) end.",
- 47,
- ['Pmod'], LFH, EFH),
- check(fun() -> Pmod = erl_eval_helper:new(42),
- B = Pmod:add(7), B end,
- "begin Pmod = erl_eval_helper:new(42), "
- "B = Pmod:add(7), B end.",
- 49,
- ['B','Pmod'], LFH, EFH)
- end,
ok.
count_down(F, N) when N > 0 ->
diff --git a/lib/stdlib/test/erl_eval_helper.erl b/lib/stdlib/test/erl_eval_helper.erl
deleted file mode 100644
index 6863b40108..0000000000
--- a/lib/stdlib/test/erl_eval_helper.erl
+++ /dev/null
@@ -1,28 +0,0 @@
-%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2005-2010. 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
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved online at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% %CopyrightEnd%
-%%
-
--module(erl_eval_helper, [Base]).
-
--export([add/1]).
-
-add(Arg) ->
- Base+Arg.
-
-
-
diff --git a/lib/stdlib/test/erl_expand_records_SUITE.erl b/lib/stdlib/test/erl_expand_records_SUITE.erl
index 01cdb92d7b..94b4397a9c 100644
--- a/lib/stdlib/test/erl_expand_records_SUITE.erl
+++ b/lib/stdlib/test/erl_expand_records_SUITE.erl
@@ -35,7 +35,7 @@
init_per_group/2,end_per_group/2,
init_per_testcase/2, end_per_testcase/2]).
--export([abstract_module/1, attributes/1, expr/1, guard/1,
+-export([attributes/1, expr/1, guard/1,
init/1, pattern/1, strict/1, update/1,
otp_5915/1, otp_7931/1, otp_5990/1,
otp_7078/1, otp_7101/1]).
@@ -55,7 +55,7 @@ end_per_testcase(_Case, _Config) ->
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [abstract_module, attributes, expr, guard, init,
+ [attributes, expr, guard, init,
pattern, strict, update, {group, tickets}].
groups() ->
@@ -75,40 +75,12 @@ end_per_group(_GroupName, Config) ->
Config.
-abstract_module(doc) ->
- "Compile an abstract module.";
-abstract_module(suite) -> [];
-abstract_module(Config) when is_list(Config) ->
- %% erl_expand_records does not handle abstract modules. But anyway...
- File = filename("param.erl", Config),
- Beam = filename("param.beam", Config),
- Test = <<"-module(param, [A, B]).
-
- -export([args/1]).
-
- args(C) ->
- X = local(C),
- Z = new(A, B),
- {X, Z}.
-
- local(C) ->
- module_info(C).
- ">>,
-
- ?line ok = file:write_file(File, Test),
- ?line {ok, param} = compile:file(File, [{outdir,?privdir}]),
-
- ?line ok = file:delete(File),
- ?line ok = file:delete(Beam),
- ok.
-
attributes(doc) ->
"Import module and functions.";
attributes(suite) -> [];
attributes(Config) when is_list(Config) ->
Ts = [
- <<"-import(erl_expand_records_SUITE).
- -import(lists, [append/2, reverse/1]).
+ <<"-import(lists, [append/2, reverse/1]).
-record(r, {a,b}).
@@ -157,13 +129,13 @@ expr(Config) when is_list(Config) ->
One = 1 = fun f/1(1),
2 = fun(X) -> X end(One + One),
3 = fun exprec_test:f/1(3),
- 4 = {exprec_test,f}(4),
- 5 = ''.f(5),
+ 4 = exprec_test:f(4),
+ 5 = f(5),
L = receive
{a,message,L0} ->
L0
end,
- case catch a.b.c:foo(bar) of
+ case catch a:foo(bar) of
{'EXIT', _} -> ok
end,
_ = receive %Suppress warning.
@@ -197,7 +169,7 @@ guard(suite) -> [];
guard(Config) when is_list(Config) ->
File = filename("guard.erl", Config),
Beam = filename("guard.beam", Config),
- Test = <<"-module(guard, [A, B]).
+ Test = <<"-module(guard).
-export([t/1]).
@@ -263,8 +235,7 @@ pattern(doc) ->
pattern(suite) -> [];
pattern(Config) when is_list(Config) ->
Ts = [
- <<"-import(erl_expand_records_SUITE).
- -import(lists, [append/2, reverse/1]).
+ <<"-import(lists, [append/2, reverse/1]).
-record(r, {a,b}).
@@ -292,10 +263,10 @@ pattern(Config) when is_list(Config) ->
21 = t(#r{a = #r{}}),
22 = t(2),
23 = t(#r{a = #r{}, b = b}),
- 24 = t(a.b.c),
+ 24 = t(abc),
ok.
- t(a.b.c) ->
+ t(abc) ->
24;
t($a) ->
2;
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 9f9d97b619..f8345559c4 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-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2013. 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
@@ -50,14 +50,16 @@
unsafe_vars_try/1,
guard/1, otp_4886/1, otp_4988/1, otp_5091/1, otp_5276/1, otp_5338/1,
otp_5362/1, otp_5371/1, otp_7227/1, otp_5494/1, otp_5644/1, otp_5878/1,
- otp_5917/1, otp_6585/1, otp_6885/1, export_all/1,
+ otp_5917/1, otp_6585/1, otp_6885/1, otp_10436/1,
+ export_all/1,
bif_clash/1,
behaviour_basic/1, behaviour_multiple/1,
otp_7550/1,
otp_8051/1,
format_warn/1,
on_load_successful/1, on_load_failing/1,
- too_many_arguments/1
+ too_many_arguments/1,
+ basic_errors/1,bin_syntax_errors/1
]).
% Default timetrap timeout (set in init_per_testcase).
@@ -80,10 +82,10 @@ all() ->
unsafe_vars, unsafe_vars2, unsafe_vars_try, guard,
otp_4886, otp_4988, otp_5091, otp_5276, otp_5338,
otp_5362, otp_5371, otp_7227, otp_5494, otp_5644,
- otp_5878, otp_5917, otp_6585, otp_6885, export_all,
+ otp_5878, otp_5917, otp_6585, otp_6885, otp_10436, export_all,
bif_clash, behaviour_basic, behaviour_multiple,
otp_7550, otp_8051, format_warn, {group, on_load},
- too_many_arguments].
+ too_many_arguments, basic_errors, bin_syntax_errors].
groups() ->
[{unused_vars_warn, [],
@@ -1307,44 +1309,30 @@ guard(Config) when is_list(Config) ->
foo;
t3(A) when erlang:is_record(A, {apa}) ->
foo;
- t3(A) when {erlang,is_record}(A, {apa}) ->
- foo;
t3(A) when is_record(A, {apa}, 1) ->
foo;
t3(A) when erlang:is_record(A, {apa}, 1) ->
foo;
- t3(A) when {erlang,is_record}(A, {apa}, 1) ->
- foo;
t3(A) when is_record(A, apa, []) ->
foo;
t3(A) when erlang:is_record(A, apa, []) ->
foo;
- t3(A) when {erlang,is_record}(A, apa, []) ->
- foo;
t3(A) when record(A, apa) ->
foo;
t3(A) when is_record(A, apa) ->
foo;
t3(A) when erlang:is_record(A, apa) ->
- foo;
- t3(A) when {erlang,is_record}(A, apa) ->
foo.
">>,
[warn_unused_vars, nowarn_obsolete_guard],
- {error,[{2,erl_lint,illegal_guard_expr},
- {4,erl_lint,illegal_guard_expr},
- {6,erl_lint,illegal_guard_expr},
- {8,erl_lint,illegal_guard_expr},
- {10,erl_lint,illegal_guard_expr},
- {12,erl_lint,illegal_guard_expr},
- {14,erl_lint,illegal_guard_expr},
- {16,erl_lint,illegal_guard_expr},
- {18,erl_lint,illegal_guard_expr},
- {20,erl_lint,illegal_guard_expr}],
- [{8,erl_lint,deprecated_tuple_fun},
- {14,erl_lint,deprecated_tuple_fun},
- {20,erl_lint,deprecated_tuple_fun},
- {28,erl_lint,deprecated_tuple_fun}]}},
+ {errors,[{2,erl_lint,illegal_guard_expr},
+ {4,erl_lint,illegal_guard_expr},
+ {6,erl_lint,illegal_guard_expr},
+ {8,erl_lint,illegal_guard_expr},
+ {10,erl_lint,illegal_guard_expr},
+ {12,erl_lint,illegal_guard_expr},
+ {14,erl_lint,illegal_guard_expr}],
+ []}},
{guard6,
<<"-record(apa,{a=a,b=foo:bar()}).
apa() ->
@@ -1364,7 +1352,17 @@ guard(Config) when is_list(Config) ->
(is_record(X, apa)*2)].
">>,
[],
- []}],
+ []},
+ {guard8,
+ <<"t(A) when erlang:is_foobar(A) -> ok;
+ t(A) when A ! ok -> ok;
+ t(A) when A ++ [x] -> ok."
+ >>,
+ [],
+ {errors,[{1,erl_lint,illegal_guard_expr},
+ {2,erl_lint,illegal_guard_expr},
+ {3,erl_lint,illegal_guard_expr}],[]}}
+ ],
?line [] = run(Config, Ts1),
ok.
@@ -1652,6 +1650,7 @@ otp_5276(Config) when is_list(Config) ->
-deprecated([{'_','_',never}]).
-deprecated([{{badly,formed},1}]).
-deprecated([{'_','_',next_major_release}]).
+ -deprecated([{atom_to_list,1}]).
-export([t/0]).
frutt() -> ok.
t() -> ok.
@@ -1662,8 +1661,9 @@ otp_5276(Config) when is_list(Config) ->
{3,erl_lint,{invalid_deprecated,'foo bar'}},
{5,erl_lint,{bad_deprecated,{f,'_'}}},
{8,erl_lint,{invalid_deprecated,{'_','_',never}}},
- {9,erl_lint,{invalid_deprecated,{{badly,formed},1}}}],
- [{12,erl_lint,{unused_function,{frutt,0}}}]}}],
+ {9,erl_lint,{invalid_deprecated,{{badly,formed},1}}},
+ {11,erl_lint,{bad_deprecated,{atom_to_list,1}}}],
+ [{13,erl_lint,{unused_function,{frutt,0}}}]}}],
?line [] = run(Config, Ts),
ok.
@@ -1745,7 +1745,7 @@ otp_5362(Config) when is_list(Config) ->
{otp_5362_2,
<<"-export([inline/0]).
- -import(lists.foo, [a/1,b/1]). % b/1 is not used
+ -import(lists, [a/1,b/1]). % b/1 is not used
-compile([{inline,{inl,7}}]). % undefined
-compile([{inline,[{inl,17}]}]). % undefined
@@ -1777,7 +1777,7 @@ otp_5362(Config) when is_list(Config) ->
{6,erl_lint,{bad_inline,{inl,17}}},
{11,erl_lint,{undefined_function,{fipp,0}}},
{22,erl_lint,{bad_nowarn_unused_function,{and_not_used,2}}}],
- [{3,erl_lint,{unused_import,{{b,1},'lists.foo'}}},
+ [{3,erl_lint,{unused_import,{{b,1},lists}}},
{9,erl_lint,{unused_function,{foop,0}}},
{19,erl_lint,{unused_function,{not_used,0}}},
{23,erl_lint,{unused_function,{and_not_used,1}}}]}},
@@ -1909,9 +1909,23 @@ otp_5362(Config) when is_list(Config) ->
warn_deprecated_function,
warn_bif_clash]},
{errors,
- [{2,erl_lint,disallowed_nowarn_bif_clash}],[]}}
+ [{2,erl_lint,disallowed_nowarn_bif_clash}],[]}},
- ],
+ {call_deprecated_function,
+ <<"t(X) -> erlang:hash(X, 2000).">>,
+ [],
+ {warnings,
+ [{1,erl_lint,{deprecated,{erlang,hash,2},
+ {erlang,phash2,2},"in a future release"}}]}},
+
+ {call_removed_function,
+ <<"t(X) -> regexp:match(X).">>,
+ [],
+ {warnings,
+ [{1,erl_lint,{removed,{regexp,match,1},
+ "removed in R15; use the re module instead"}}]}}
+
+ ],
?line [] = run(Config, Ts),
ok.
@@ -2200,27 +2214,9 @@ otp_5878(Config) when is_list(Config) ->
?line [] = run(Config, Ts),
Abstr = <<"-module(lint_test, [A, B]).
-
- -export([args/1]).
-
- -record(r, {a = A, b = THIS}). % A and THIS are unbound
-
- %% param:args(compile,param:new(1,2)).
-
- args(C) ->
- X = local(C),
- Z = new(A, B),
- F = fun(THIS) -> {x, A} end, % THIS unused and shadowed
- {X, Z, THIS, F, #r{}}.
-
- local(C) ->
- module_info(C).
">>,
- ?line {error,[{5,erl_lint,{unbound_var,'A'}},
- {5,erl_lint,{unbound_var,'THIS'}}],
- [{12,erl_lint,{unused_var,'THIS'}},
- {12,erl_lint,{shadowed_var,'THIS','fun'}}]}
- = run_test2(Config, Abstr, [warn_unused_record]),
+ {errors,[{1,erl_lint,pmod_unsupported}],[]} =
+ run_test2(Config, Abstr, [warn_unused_record]),
QLC1 = <<"-module(lint_test).
-include_lib(\"stdlib/include/qlc.hrl\").
@@ -2400,6 +2396,28 @@ otp_6885(Config) when is_list(Config) ->
[]} = run_test2(Config, Ts, []),
ok.
+otp_10436(doc) ->
+ "OTP-6885. Warnings for opaque types.";
+otp_10436(suite) -> [];
+otp_10436(Config) when is_list(Config) ->
+ Ts = <<"-module(otp_10436).
+ -export_type([t1/0]).
+ -opaque t1() :: {i, integer()}.
+ -opaque t2() :: {a, atom()}.
+ ">>,
+ {warnings,[{4,erl_lint,{not_exported_opaque,{t2,0}}},
+ {4,erl_lint,{unused_type,{t2,0}}}]} =
+ run_test2(Config, Ts, []),
+ Ts2 = <<"-module(otp_10436_2).
+ -export_type([t1/0, t2/0]).
+ -opaque t1() :: term().
+ -opaque t2() :: any().
+ ">>,
+ {warnings,[{3,erl_lint,{underspecified_opaque,{t1,0}}},
+ {4,erl_lint,{underspecified_opaque,{t2,0}}}]} =
+ run_test2(Config, Ts2, []),
+ ok.
+
export_all(doc) ->
"OTP-7392. Warning for export_all.";
export_all(Config) when is_list(Config) ->
@@ -2848,10 +2866,10 @@ otp_8051(doc) ->
otp_8051(Config) when is_list(Config) ->
Ts = [{otp_8051,
<<"-opaque foo() :: bar().
+ -export_type([foo/0]).
">>,
[],
- {error,[{1,erl_lint,{undefined_type,{bar,0}}}],
- [{1,erl_lint,{unused_type,{foo,0}}}]}}],
+ {errors,[{1,erl_lint,{undefined_type,{bar,0}}}],[]}}],
?line [] = run(Config, Ts),
ok.
@@ -2980,6 +2998,77 @@ too_many_arguments(Config) when is_list(Config) ->
ok.
+%% Test some basic errors to improve coverage.
+basic_errors(Config) ->
+ Ts = [{redefine_module,
+ <<"-module(redefine_module).">>,
+ [],
+ {errors,[{1,erl_lint,redefine_module}],[]}},
+
+ {attr_after_function,
+ <<"f() -> ok.
+ -attr(x).">>,
+ [],
+ {errors,[{2,erl_lint,{attribute,attr}}],[]}},
+
+ {redefine_function,
+ <<"f() -> ok.
+ f() -> ok.">>,
+ [],
+ {errors,[{2,erl_lint,{redefine_function,{f,0}}}],[]}},
+
+ {redefine_record,
+ <<"-record(r, {a}).
+ -record(r, {a}).
+ f(#r{}) -> ok.">>,
+ [],
+ {errors,[{2,erl_lint,{redefine_record,r}}],[]}},
+
+ {illegal_record_info,
+ <<"f1() -> record_info(42, record).
+ f2() -> record_info(shoe_size, record).">>,
+ [],
+ {errors,[{1,erl_lint,illegal_record_info},
+ {2,erl_lint,illegal_record_info}],[]}},
+
+ {illegal_expr,
+ <<"f() -> a:b.">>,
+ [],
+ {errors,[{1,erl_lint,illegal_expr}],[]}},
+
+ {illegal_pattern,
+ <<"f(A+B) -> ok.">>,
+ [],
+ {errors,[{1,erl_lint,illegal_pattern}],[]}}
+ ],
+ [] = run(Config, Ts),
+ ok.
+
+%% Test binary syntax errors
+bin_syntax_errors(Config) ->
+ Ts = [{bin_syntax_errors,
+ <<"t(<<X:bad_size>>) -> X;
+ t(<<_:(x ! y)/integer>>) -> ok;
+ t(<<X:all/integer>>) -> X;
+ t(<<X/bad_type>>) -> X;
+ t(<<X/unit:8>>) -> X;
+ t(<<X:7/float>>) -> X;
+ t(<< <<_:8>> >>) -> ok;
+ t(<<(x ! y):8/integer>>) -> ok.
+ ">>,
+ [],
+ {error,[{1,erl_lint,illegal_bitsize},
+ {2,erl_lint,illegal_bitsize},
+ {3,erl_lint,illegal_bitsize},
+ {4,erl_lint,{undefined_bittype,bad_type}},
+ {5,erl_lint,bittype_unit},
+ {7,erl_lint,illegal_pattern},
+ {8,erl_lint,illegal_pattern}],
+ [{6,erl_lint,{bad_bitsize,"float"}}]}}
+ ],
+ [] = run(Config, Ts),
+ ok.
+
run(Config, Tests) ->
F = fun({N,P,Ws,E}, BadL) ->
case catch run_test(Config, P, Ws) of
diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl
index 64853ca078..2b7cec87df 100644
--- a/lib/stdlib/test/erl_pp_SUITE.erl
+++ b/lib/stdlib/test/erl_pp_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2013. 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
@@ -40,15 +40,16 @@
init_per_testcase/2, end_per_testcase/2]).
-export([ func/1, call/1, recs/1, try_catch/1, if_then/1,
- receive_after/1, bits/1, head_tail/1, package/1,
+ receive_after/1, bits/1, head_tail/1,
cond1/1, block/1, case1/1, ops/1, messages/1,
old_mnemosyne_syntax/1,
- import_export/1, misc_attrs/1,
+ import_export/1, misc_attrs/1, dialyzer_attrs/1,
hook/1,
neg_indent/1,
otp_6321/1, otp_6911/1, otp_6914/1, otp_8150/1, otp_8238/1,
- otp_8473/1, otp_8522/1, otp_8567/1, otp_8664/1, otp_9147/1]).
+ otp_8473/1, otp_8522/1, otp_8567/1, otp_8664/1, otp_9147/1,
+ otp_10302/1, otp_10820/1, otp_11100/1]).
%% Internal export.
-export([ehook/6]).
@@ -74,12 +75,13 @@ all() ->
groups() ->
[{expr, [],
[func, call, recs, try_catch, if_then, receive_after,
- bits, head_tail, package, cond1, block, case1, ops,
+ bits, head_tail, cond1, block, case1, ops,
messages, old_mnemosyne_syntax]},
- {attributes, [], [misc_attrs, import_export]},
+ {attributes, [], [misc_attrs, import_export, dialyzer_attrs]},
{tickets, [],
[otp_6321, otp_6911, otp_6914, otp_8150, otp_8238,
- otp_8473, otp_8522, otp_8567, otp_8664, otp_9147]}].
+ otp_8473, otp_8522, otp_8567, otp_8664, otp_9147,
+ otp_10302, otp_10820, otp_11100]}].
init_per_suite(Config) ->
Config.
@@ -438,9 +440,6 @@ bits(Config) when is_list(Config) ->
?line ok = pp_expr(<<"<<{a,b}/binary>>">>),
?line ok = pp_expr(<<"<<{foo:bar(),b}/binary>>">>),
?line ok = pp_expr(<<"<<(foo:bar()):(foo:bar())/binary>>">>),
- ?line ok = pp_expr(<<"<<(foo.bar)/binary>>">>),
- ?line ok = pp_expr(<<"<<(foo.bar):all/binary>>">>),
- ?line ok = pp_expr(<<"<<(foo.bar):(foo.bar)/binary>>">>),
ok.
head_tail(suite) ->
@@ -462,17 +461,6 @@ head_tail(Config) when is_list(Config) ->
?line compile(Config, Ts),
ok.
-package(suite) ->
- [];
-package(Config) when is_list(Config) ->
- Ts = [{package_1,
- <<"t() -> a.b:foo().">>},
- {package_2,
- <<"t() -> .lists:sort([]).">>}
- ],
- ?line compile(Config, Ts),
- ok.
-
cond1(suite) ->
[];
cond1(Config) when is_list(Config) ->
@@ -550,29 +538,9 @@ messages(Config) when is_list(Config) ->
?line true = "\n" =:= lists:flatten(erl_pp:form({eof,0})),
ok.
-old_mnemosyne_syntax(suite) ->
- [];
old_mnemosyne_syntax(Config) when is_list(Config) ->
- %% Since we have kept the 'query' syntax and ':-' token,
+ %% Since we have kept the ':-' token,
%% better test that we can pretty print it.
- Q = {'query',6,
- {lc,6,
- {var,6,'X'},
- [{generate,6,
- {var,6,'X'},
- {call,6,{atom,6,table},[{atom,6,tab}]}},
- {match,7,
- {record_field,7,{var,7,'X'},{atom,7,foo}},
- {atom,7,bar}}]}},
- ?line "query\n"
- " [ \n" % extra space...
- " X ||\n"
- " X <- table(tab),\n"
- " X.foo = bar\n"
- " ]\n"
- "end" =
- lists:flatten(erl_pp:expr(Q)),
-
R = {rule,12,sales,2,
[{clause,12,
[{var,12,'E'},{atom,12,employee}],
@@ -614,13 +582,11 @@ misc_attrs(suite) ->
[];
misc_attrs(Config) when is_list(Config) ->
?line ok = pp_forms(<<"-module(m). ">>),
- ?line ok = pp_forms(<<"-module(m.p, [A,B]). ">>),
?line ok = pp_forms(<<"-module(m, [Aafjlksfjdlsjflsdfjlsdjflkdsfjlk,"
"Blsjfdlslfjsdf]). ">>),
?line ok = pp_forms(<<"-export([]). ">>),
?line ok = pp_forms(<<"-export([foo/2, bar/0]). ">>),
?line ok = pp_forms(<<"-export([bar/0]). ">>),
- ?line ok = pp_forms(<<"-import(.lists). ">>),
?line ok = pp_forms(<<"-import(lists, []). ">>),
?line ok = pp_forms(<<"-import(lists, [map/2]). ">>),
?line ok = pp_forms(<<"-import(lists, [map/2, foreach/2]). ">>),
@@ -631,11 +597,24 @@ misc_attrs(Config) when is_list(Config) ->
ok.
+dialyzer_attrs(suite) ->
+ [];
+dialyzer_attrs(Config) when is_list(Config) ->
+ ok = pp_forms(<<"-type foo() :: #bar{}. ">>),
+ ok = pp_forms(<<"-opaque foo() :: {bar, fun((X, [42,...]) -> X)}. ">>),
+ ok = pp_forms(<<"-spec foo(bar(), qux()) -> [T | baz(T)]. ">>),
+ ok = pp_forms(<<"-callback foo(<<_:32,_:_*4>>, T) -> T. ">>),
+ ok.
+
hook(suite) ->
[];
hook(Config) when is_list(Config) ->
+ F = fun(H) -> H end,
+ do_hook(F).
+
+do_hook(HookFun) ->
Lc = parse_expr(binary_to_list(<<"[X || X <- [1,2,3]].">>)),
- H = fun hook/4,
+ H = HookFun(fun hook/4),
Expr = {call,0,{atom,0,fff},[{foo,Lc},{foo,Lc},{foo,Lc}]},
EChars = lists:flatten(erl_pp:expr(Expr, 0, H)),
Call = {call,0,{atom,0,foo},[Lc]},
@@ -692,7 +671,7 @@ hook(Config) when is_list(Config) ->
GChars2 = erl_pp:guard(G2),
?line true = GChars =:= lists:flatten(GChars2),
- EH = {?MODULE, ehook, [foo,bar]},
+ EH = HookFun({?MODULE, ehook, [foo,bar]}),
XEChars = erl_pp:expr(Expr, -1, EH),
?line true = remove_indentation(EChars) =:= lists:flatten(XEChars),
XEChars2 = erl_pp:expr(Expr, EH),
@@ -1068,6 +1047,110 @@ otp_9147(Config) when is_list(Config) ->
string:tokens(binary_to_list(Bin), "\n")),
ok.
+otp_10302(doc) ->
+ "OTP-10302. Unicode characters scanner/parser.";
+otp_10302(suite) -> [];
+otp_10302(Config) when is_list(Config) ->
+ Ts = [{uni_1,
+ <<"t() -> <<(<<\"abc\\x{aaa}\">>):3/binary>>.">>}
+ ],
+ compile(Config, Ts),
+ ok = pp_expr(<<"$\\x{aaa}">>),
+ ok = pp_expr(<<"\"1\\x{aaa}\"">>),
+ ok = pp_expr(<<"<<<<\"hej\">>/binary>>">>),
+ ok = pp_expr(<<"<< <<\"1\\x{aaa}\">>/binary>>">>),
+
+ U = [{encoding,unicode}],
+
+ do_hook(fun(H) -> [{hook,H}] end),
+ do_hook(fun(H) -> [{hook,H}]++U end),
+
+ ok = pp_expr(<<"$\\x{aaa}">>, [{hook,fun hook/4}]),
+
+ Opts = [{hook, fun unicode_hook/4},{encoding,unicode}],
+ Lc = parse_expr("[X || X <- [\"\x{400}\",\"\xFF\"]]."),
+ Expr = {call,0,{atom,0,fff},[{foo,{foo,Lc}},{foo,{foo,Lc}}]},
+ EChars = lists:flatten(erl_pp:expr(Expr, 0, Opts)),
+ Call = {call,0,{atom,0,foo},[{call,0,{atom,0,foo},[Lc]}]},
+ Expr2 = {call,0,{atom,0,fff},[Call,Call]},
+ EChars2 = erl_pp:exprs([Expr2], U),
+ EChars = lists:flatten(EChars2),
+ [$\x{400},$\x{400}] = [C || C <- EChars, C > 255],
+
+ ok = pp_forms(<<"function() -> {\"\x{400}\",$\x{400}}. "/utf8>>, U),
+ ok = pp_forms("function() -> {\"\x{400}\",$\x{400}}. ", []),
+ ok.
+
+unicode_hook({foo,E}, I, P, H) ->
+ erl_pp:expr({call,0,{atom,0,foo},[E]}, I, P, H).
+
+otp_10820(doc) ->
+ "OTP-10820. Unicode filenames.";
+otp_10820(suite) -> [];
+otp_10820(Config) when is_list(Config) ->
+ C1 = <<"%% coding: utf-8\n -module(any).">>,
+ ok = do_otp_10820(Config, C1, "+pc latin1"),
+ ok = do_otp_10820(Config, C1, "+pc unicode"),
+ C2 = <<"-module(any).">>,
+ ok = do_otp_10820(Config, C2, "+pc latin1"),
+ ok = do_otp_10820(Config, C2, "+pc unicode").
+
+do_otp_10820(Config, C, PC) ->
+ {ok,Node} = start_node(erl_pp_helper, "+fnu " ++ PC),
+ L = [915,953,959,973,957,953,954,959,957,964],
+ FileName = filename(L++".erl", Config),
+ ok = rpc:call(Node, file, write_file, [FileName, C]),
+ {ok, _, []} = rpc:call(Node, compile, file,
+ [FileName, [return,'P',{outdir,?privdir}]]),
+ PFileName = filename(L++".P", Config),
+ {ok, Bin} = rpc:call(Node, file, read_file, [PFileName]),
+ true = test_server:stop_node(Node),
+ true = file_attr_is_string(binary_to_list(Bin)),
+ ok.
+
+file_attr_is_string("-file(\"" ++ _) -> true;
+file_attr_is_string([_ | L]) ->
+ file_attr_is_string(L).
+
+otp_11100(doc) ->
+ "OTP-11100. Fix printing of invalid forms.";
+otp_11100(suite) -> [];
+otp_11100(Config) when is_list(Config) ->
+ %% There are a few places where the added code ("options(none)")
+ %% doesn't make a difference (pp:bit_elem_type/1 is an example).
+
+ %% Cannot trigger the use of the hook function with export/import.
+ "-export([{fy,a}/b]).\n" =
+ pf({attribute,1,export,[{{fy,a},b}]}),
+ "-type foo() :: integer(INVALID-FORM:{foo,bar}:).\n" =
+ pf({attribute,1,type,{foo,{type,1,integer,[{foo,bar}]},[]}}),
+ pf({attribute,1,type,
+ {a,{type,1,range,[{integer,1,1},{foo,bar}]},[]}}),
+ "-type foo(INVALID-FORM:{foo,bar}:) :: A.\n" =
+ pf({attribute,1,type,{foo,{var,1,'A'},[{foo,bar}]}}),
+ "-type foo() :: (INVALID-FORM:{foo,bar}: :: []).\n" =
+ pf({attribute,1,type,
+ {foo,{paren_type,1,
+ [{ann_type,1,[{foo,bar},{type,1,nil,[]}]}]},
+ []}}),
+ "-type foo() :: <<_:INVALID-FORM:{foo,bar}:>>.\n" =
+ pf({attribute,1,type,
+ {foo,{type,1,binary,[{foo,bar},{integer,1,0}]},[]}}),
+ "-type foo() :: <<_:10, _:_*INVALID-FORM:{foo,bar}:>>.\n" =
+ pf({attribute,1,type,
+ {foo,{type,1,binary,[{integer,1,10},{foo,bar}]},[]}}),
+ "-type foo() :: #r{INVALID-FORM:{foo,bar}: :: integer()}.\n" =
+ pf({attribute,1,type,
+ {foo,{type,1,record,
+ [{atom,1,r},
+ {type,1,field_type,
+ [{foo,bar},{type,1,integer,[]}]}]},
+ []}}),
+ ok.
+
+pf(Form) ->
+ lists:flatten(erl_pp:form(Form,none)).
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
compile(Config, Tests) ->
@@ -1137,9 +1220,11 @@ flat_expr(Expr) ->
pp_forms(Bin) ->
pp_forms(Bin, none).
-pp_forms(Bin, Hook) ->
- PP1 = (catch parse_and_pp_forms(binary_to_list(Bin), Hook)),
- PP2 = (catch parse_and_pp_forms(PP1, Hook)),
+pp_forms(Bin, Options) when is_binary(Bin) ->
+ pp_forms(to_list(Bin, Options), Options);
+pp_forms(List, Options) when is_list(List) ->
+ PP1 = (catch parse_and_pp_forms(List, Options)),
+ PP2 = (catch parse_and_pp_forms(PP1, Options)),
case PP1 =:= PP2 of % same line numbers
true ->
test_max_line(PP1);
@@ -1147,8 +1232,8 @@ pp_forms(Bin, Hook) ->
not_ok
end.
-parse_and_pp_forms(String, Hook) ->
- lists:append(lists:map(fun(AF) -> erl_pp:form(AF, Hook)
+parse_and_pp_forms(String, Options) ->
+ lists:append(lists:map(fun(AF) -> erl_pp:form(AF, Options)
end, parse_forms(String))).
parse_forms(Chars) ->
@@ -1158,7 +1243,7 @@ parse_forms(Chars) ->
parse_forms2([], _Cont, _Line, Forms) ->
lists:reverse(Forms);
parse_forms2(String, Cont0, Line, Forms) ->
- case erl_scan:tokens(Cont0, String, Line) of
+ case erl_scan:tokens(Cont0, String, Line, [unicode]) of
{done, {ok, Tokens, EndLine}, Chars} ->
{ok, Form} = erl_parse:parse_form(Tokens),
parse_forms2(Chars, [], EndLine, [Form | Forms]);
@@ -1174,10 +1259,12 @@ pp_expr(Bin) ->
pp_expr(Bin, none).
%% Final dot is added.
-pp_expr(Bin, Hook) ->
- PP1 = (catch parse_and_pp_expr(binary_to_list(Bin), 0, Hook)),
- PPneg = (catch parse_and_pp_expr(binary_to_list(Bin), -1, Hook)),
- PP2 = (catch parse_and_pp_expr(PPneg, 0, Hook)),
+pp_expr(Bin, Options) when is_binary(Bin) ->
+ pp_expr(to_list(Bin, Options), Options);
+pp_expr(List, Options) when is_list(List) ->
+ PP1 = (catch parse_and_pp_expr(List, 0, Options)),
+ PPneg = (catch parse_and_pp_expr(List, -1, Options)),
+ PP2 = (catch parse_and_pp_expr(PPneg, 0, Options)),
if
PP1 =:= PP2 -> % same line numbers
case
@@ -1192,15 +1279,24 @@ pp_expr(Bin, Hook) ->
not_ok
end.
-parse_and_pp_expr(String, Indent, Hook) ->
+parse_and_pp_expr(String, Indent, Options) ->
StringDot = lists:flatten(String) ++ ".",
- erl_pp:expr(parse_expr(StringDot), Indent, Hook).
+ erl_pp:expr(parse_expr(StringDot), Indent, Options).
parse_expr(Chars) ->
- {ok, Tokens, _} = erl_scan:string(Chars),
+ {ok, Tokens, _} = erl_scan:string(Chars, 1, [unicode]),
{ok, [Expr]} = erl_parse:parse_exprs(Tokens),
Expr.
+to_list(Bin, Options) when is_list(Options) ->
+ case proplists:get_value(encoding, Options) of
+ unicode -> unicode:characters_to_list(Bin);
+ encoding -> binary_to_list(Bin);
+ undefined -> binary_to_list(Bin)
+ end;
+to_list(Bin, _Hook) ->
+ binary_to_list(Bin).
+
test_new_line(String) ->
case string:chr(String, $\n) of
0 -> ok;
@@ -1228,3 +1324,8 @@ filename(Name, Config) ->
fail() ->
io:format("failed~n"),
?t:fail().
+
+%% +fnu means a peer node has to be started; slave will not do
+start_node(Name, Xargs) ->
+ ?line PA = filename:dirname(code:which(?MODULE)),
+ test_server:start_node(Name, peer, [{args, "-pa " ++ PA ++ " " ++ Xargs}]).
diff --git a/lib/stdlib/test/erl_scan_SUITE.erl b/lib/stdlib/test/erl_scan_SUITE.erl
index 4298b2c701..361abbb771 100644
--- a/lib/stdlib/test/erl_scan_SUITE.erl
+++ b/lib/stdlib/test/erl_scan_SUITE.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. 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
@@ -20,7 +21,8 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2]).
--export([ error_1/1, error_2/1, iso88591/1, otp_7810/1]).
+-export([ error_1/1, error_2/1, iso88591/1, otp_7810/1, otp_10302/1,
+ otp_10990/1, otp_10992/1]).
-import(lists, [nth/2,flatten/1]).
-import(io_lib, [print/1]).
@@ -59,7 +61,7 @@ end_per_testcase(_Case, Config) ->
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [{group, error}, iso88591, otp_7810].
+ [{group, error}, iso88591, otp_7810, otp_10302, otp_10990, otp_10992].
groups() ->
[{error, [], [error_1, error_2]}].
@@ -117,13 +119,13 @@ check(String) ->
%%% (This should be useful for all format_error functions.)
check_error({error, Info, EndLine}, Module0) ->
- ?line {ErrorLine, Module, Desc} = Info,
- ?line true = (Module == Module0),
- ?line assert_type(EndLine, integer),
- ?line assert_type(ErrorLine, integer),
- ?line true = (ErrorLine =< EndLine),
- ?line String = lists:flatten(Module0:format_error(Desc)),
- ?line true = io_lib:printable_list(String).
+ {ErrorLine, Module, Desc} = Info,
+ true = (Module == Module0),
+ assert_type(EndLine, integer),
+ assert_type(ErrorLine, integer),
+ true = (ErrorLine =< EndLine),
+ String = lists:flatten(Module0:format_error(Desc)),
+ true = io_lib:printable_list(String).
iso88591(doc) -> ["Tests the support for ISO-8859-1 i.e Latin-1"];
iso88591(suite) -> [];
@@ -131,10 +133,10 @@ iso88591(Config) when is_list(Config) ->
?line ok =
case catch begin
%% Some atom and variable names
- V1s = [$�,$�,$�,$�],
- V2s = [$N,$�,$r],
- A1s = [$h,$�,$r],
- A2s = [$�,$r,$e],
+ V1s = [$Á,$á,$é,$ë],
+ V2s = [$N,$ä,$r],
+ A1s = [$h,$ä,$r],
+ A2s = [$ö,$r,$e],
%% Test parsing atom and variable characters.
{ok,Ts1,_} = erl_scan:string(V1s ++ " " ++ V2s ++
"\327" ++
@@ -196,7 +198,7 @@ otp_7810(Config) when is_list(Config) ->
reserved_words() ->
L = ['after', 'begin', 'case', 'try', 'cond', 'catch',
'andalso', 'orelse', 'end', 'fun', 'if', 'let', 'of',
- 'query', 'receive', 'when', 'bnot', 'not', 'div',
+ 'receive', 'when', 'bnot', 'not', 'div',
'rem', 'band', 'and', 'bor', 'bxor', 'bsl', 'bsr',
'or', 'xor'],
[begin
@@ -214,8 +216,8 @@ atoms() ->
?line test_string("'a b'", [{atom,1,'a b'}]),
?line test_string("a", [{atom,1,a}]),
?line test_string("a@2", [{atom,1,a@2}]),
- ?line test_string([39,65,200,39], [{atom,1,'A�'}]),
- ?line test_string("�rlig �sten", [{atom,1,�rlig},{atom,1,�sten}]),
+ ?line test_string([39,65,200,39], [{atom,1,'AÈ'}]),
+ ?line test_string("ärlig östen", [{atom,1,ärlig},{atom,1,östen}]),
?line {ok,[{atom,_,'$a'}],{1,6}} =
erl_scan:string("'$\\a'", {1,1}),
?line test("'$\\a'"),
@@ -289,7 +291,7 @@ errors() ->
?line {error,{1,erl_scan,{string,$","str"}},1} = %"
erl_scan:string("\"str"), %"
?line {error,{1,erl_scan,char},1} = erl_scan:string("$"),
- ?line test_string([34,65,200,34], [{string,1,"A�"}]),
+ ?line test_string([34,65,200,34], [{string,1,"AÈ"}]),
?line test_string("\\", [{'\\',1}]),
?line {'EXIT',_} =
(catch {foo, erl_scan:string('$\\a', {1,1})}), % type error
@@ -354,7 +356,7 @@ dots() ->
{".\n", {ok,[{dot,1}],2}},
{".%", {ok,[{dot,1}],1}},
{".\210",{ok,[{dot,1}],1}},
- {".% �h",{ok,[{dot,1}],1}},
+ {".% öh",{ok,[{dot,1}],1}},
{".%\n", {ok,[{dot,1}],2}},
{".$", {error,{1,erl_scan,char},1}},
{".$\\", {error,{1,erl_scan,char},1}},
@@ -369,7 +371,7 @@ dots() ->
?line [{column,1},{length,1},{line,1},{text,"."}] =
erl_scan:token_info(T2, [column, length, line, text]),
?line {ok,[{dot,_}=T3],{1,6}} =
- erl_scan:string(".% �h", {1,1}, text),
+ erl_scan:string(".% öh", {1,1}, text),
?line [{column,1},{length,1},{line,1},{text,"."}] =
erl_scan:token_info(T3, [column, length, line, text]),
?line {error,{{1,2},erl_scan,char},{1,3}} =
@@ -472,11 +474,11 @@ chars() ->
variables() ->
- ?line test_string(" \237_Aou�eiy��", [{var,1,'_Aou�eiy��'}]),
+ ?line test_string(" \237_Aouåeiyäö", [{var,1,'_Aouåeiyäö'}]),
?line test_string("A_b_c@", [{var,1,'A_b_c@'}]),
?line test_string("V@2", [{var,1,'V@2'}]),
- ?line test_string("ABD�", [{var,1,'ABD�'}]),
- ?line test_string("�rlig �sten", [{var,1,'�rlig'},{var,1,'�sten'}]),
+ ?line test_string("ABDÀ", [{var,1,'ABDÀ'}]),
+ ?line test_string("Ärlig Östen", [{var,1,'Ärlig'},{var,1,'Östen'}]),
ok.
eof() ->
@@ -814,62 +816,51 @@ unicode() ->
erl_scan:string([1089]),
?line {error,{{1,1},erl_scan,{illegal,character}},{1,2}} =
erl_scan:string([1089], {1,1}),
- ?line {error,{1,erl_scan,{illegal,character}},1} =
- %% ?line {error,{1,erl_scan,{illegal,atom}},1} =
- erl_scan:string("'a"++[1089]++"b'"),
- ?line {error,{{1,3},erl_scan,{illegal,character}},{1,4}} =
+ ?line {error,{1,erl_scan,{illegal,atom}},1} =
+ erl_scan:string("'a"++[1089]++"b'", 1),
+ ?line {error,{{1,1},erl_scan,{illegal,atom}},{1,6}} =
erl_scan:string("'a"++[1089]++"b'", {1,1}),
?line test("\"a"++[1089]++"b\""),
- ?line {ok,[{char,1,1}],1} = erl_scan:string([$$,$\\,$^,1089]),
+ ?line {ok,[{char,1,1}],1} =
+ erl_scan:string([$$,$\\,$^,1089], 1),
- ?line {error,{1,erl_scan,Error},1} = erl_scan:string("\"qa\x{aaa}"),
- ?line "unterminated string starting with \"qa\\x{AAA}\"" =
+ ?line {error,{1,erl_scan,Error},1} =
+ erl_scan:string("\"qa\x{aaa}", 1),
+ ?line "unterminated string starting with \"qa"++[2730]++"\"" =
erl_scan:format_error(Error),
?line {error,{{1,1},erl_scan,_},{1,11}} =
erl_scan:string("\"qa\\x{aaa}",{1,1}),
- ?line {error,{{1,4},erl_scan,{illegal,character}},{1,11}} =
+ ?line {error,{{1,1},erl_scan,{illegal,atom}},{1,12}} =
erl_scan:string("'qa\\x{aaa}'",{1,1}),
- Tags = [category, column, length, line, symbol, text],
-
- %% Workaround. No character codes greater than 255! To be changed.
- %% Note: don't remove these tests, just modify them!
-
- ?line {ok,[{integer,1,1089}],1} = erl_scan:string([$$,1089]),
- ?line {ok,[{integer,1,1089}],1} = erl_scan:string([$$,$\\,1089]),
+ ?line {ok,[{char,1,1089}],1} =
+ erl_scan:string([$$,1089], 1),
+ ?line {ok,[{char,1,1089}],1} =
+ erl_scan:string([$$,$\\,1089], 1),
Qs = "$\\x{aaa}",
- ?line {ok,[{integer,1,16#aaa}],1} = erl_scan:string(Qs),
- ?line {ok,[Q2],{1,9}} = erl_scan:string("$\\x{aaa}", {1,1}, text),
- ?line [{category,integer},{column,1},{length,8},
+ ?line {ok,[{char,1,$\x{aaa}}],1} =
+ erl_scan:string(Qs, 1),
+ ?line {ok,[Q2],{1,9}} =
+ erl_scan:string("$\\x{aaa}", {1,1}, [text]),
+ ?line [{category,char},{column,1},{length,8},
{line,1},{symbol,16#aaa},{text,Qs}] =
erl_scan:token_info(Q2),
U1 = "\"\\x{aaa}\"",
- ?line {ok,[T1,T2,T3],{1,10}} = erl_scan:string(U1, {1,1}, text),
- ?line [{category,'['},{column,1},{length,1},{line,1},
- {symbol,'['},{text,"\""}] = erl_scan:token_info(T1, Tags),
- ?line [{category,integer},{column,2},{length,7},
- {line,1},{symbol,16#aaa},{text,"\\x{aaa}"}] =
- erl_scan:token_info(T2, Tags),
- ?line [{category,']'},{column,9},{length,1},{line,1},
- {symbol,']'},{text,"\""}] = erl_scan:token_info(T3, Tags),
- ?line {ok,[{'[',1},{integer,1,16#aaa},{']',1}],1} =
- erl_scan:string(U1, 1),
+ {ok,
+ [{string,[{line,1},{column,1},{text,"\"\\x{aaa}\""}],[2730]}],
+ {1,10}} = erl_scan:string(U1, {1,1}, [text]),
+ {ok,[{string,1,[2730]}],1} = erl_scan:string(U1, 1),
U2 = "\"\\x41\\x{fff}\\x42\"",
- ?line {ok,[{'[',1},{char,1,16#41},{',',1},{integer,1,16#fff},
- {',',1},{char,1,16#42},{']',1}],1} = erl_scan:string(U2, 1),
+ {ok,[{string,1,[$\x41,$\x{fff},$\x42]}],1} = erl_scan:string(U2, 1),
U3 = "\"a\n\\x{fff}\n\"",
- ?line {ok,[{'[',1},{char,1,$a},{',',1},{char,1,$\n},
- {',',2},{integer,2,16#fff},{',',2},{char,2,$\n},
- {']',3}],3} =
- erl_scan:string(U3, 1),
+ {ok,[{string,1,[$a,$\n,$\x{fff},$\n]}],3} = erl_scan:string(U3, 1),
U4 = "\"\\^\n\\x{aaa}\\^\n\"",
- ?line {ok,[{'[',1},{char,1,$\n},{',',2},{integer,2,16#aaa},
- {',',2},{char,2,$\n},{']',3}],3} = erl_scan:string(U4, 1),
+ {ok,[{string,1,[$\n,$\x{aaa},$\n]}],3} = erl_scan:string(U4, 1),
%% Keep these tests:
?line test(Qs),
@@ -879,18 +870,15 @@ unicode() ->
?line test(U4),
Str1 = "\"ab" ++ [1089] ++ "cd\"",
- ?line {ok,[{'[',1},{char,1,$a},{',',1},{char,1,$b},{',',1},
- {integer,1,1089},{',',1},{char,1,$c},{',',1},
- {char,1,$d},{']',1}],1} = erl_scan:string(Str1),
- ?line {ok,[{'[',_},{char,_,$a},{',',_},{char,_,$b},{',',_},
- {integer,_,1089},{',',_},{char,_,$c},{',',_},
- {char,_,$d},{']',_}],{1,8}} = erl_scan:string(Str1, {1,1}),
+ {ok,[{string,1,[$a,$b,1089,$c,$d]}],1} = erl_scan:string(Str1, 1),
+ {ok,[{string,{1,1},[$a,$b,1089,$c,$d]}],{1,8}} =
+ erl_scan:string(Str1, {1,1}),
?line test(Str1),
Comment = "%% "++[1089],
- ?line {ok,[{comment,1,[$%,$%,$\s,1089]}],1} =
- erl_scan:string(Comment, 1, return),
- ?line {ok,[{comment,_,[$%,$%,$\s,1089]}],{1,5}} =
- erl_scan:string(Comment, {1,1}, return),
+ {ok,[{comment,1,[$%,$%,$\s,1089]}],1} =
+ erl_scan:string(Comment, 1, [return]),
+ {ok,[{comment,{1,1},[$%,$%,$\s,1089]}],{1,5}} =
+ erl_scan:string(Comment, {1,1}, [return]),
ok.
more_chars() ->
@@ -958,6 +946,205 @@ more_chars() ->
erl_scan:string("$\\xg", {1,1}),
ok.
+otp_10302(doc) ->
+ "OTP-10302. Unicode characters scanner/parser.";
+otp_10302(suite) ->
+ [];
+otp_10302(Config) when is_list(Config) ->
+ %% From unicode():
+ {error,{1,erl_scan,{illegal,atom}},1} =
+ erl_scan:string("'a"++[1089]++"b'", 1),
+ {error,{{1,1},erl_scan,{illegal,atom}},{1,12}} =
+ erl_scan:string("'qa\\x{aaa}'",{1,1}),
+
+ {ok,[{char,1,1089}],1} = erl_scan:string([$$,1089], 1),
+ {ok,[{char,1,1089}],1} = erl_scan:string([$$,$\\,1089],1),
+
+ Qs = "$\\x{aaa}",
+ {ok,[{char,1,2730}],1} = erl_scan:string(Qs,1),
+ {ok,[Q2],{1,9}} = erl_scan:string(Qs,{1,1},[text]),
+ [{category,char},{column,1},{length,8},
+ {line,1},{symbol,16#aaa},{text,Qs}] =
+ erl_scan:token_info(Q2),
+
+ Tags = [category, column, length, line, symbol, text],
+
+ U1 = "\"\\x{aaa}\"",
+ {ok,[T1],{1,10}} = erl_scan:string(U1, {1,1}, [text]),
+ [{category,string},{column,1},{length,9},{line,1},
+ {symbol,[16#aaa]},{text,U1}] = erl_scan:token_info(T1, Tags),
+
+ U2 = "\"\\x41\\x{fff}\\x42\"",
+ {ok,[{string,1,[65,4095,66]}],1} = erl_scan:string(U2, 1),
+
+ U3 = "\"a\n\\x{fff}\n\"",
+ {ok,[{string,1,[97,10,4095,10]}],3} = erl_scan:string(U3, 1),
+
+ U4 = "\"\\^\n\\x{aaa}\\^\n\"",
+ {ok,[{string,1,[10,2730,10]}],3} = erl_scan:string(U4, 1,[]),
+
+ Str1 = "\"ab" ++ [1089] ++ "cd\"",
+ {ok,[{string,1,[97,98,1089,99,100]}],1} =
+ erl_scan:string(Str1,1),
+ {ok,[{string,{1,1},[97,98,1089,99,100]}],{1,8}} =
+ erl_scan:string(Str1, {1,1}),
+
+ OK1 = 16#D800-1,
+ OK2 = 16#DFFF+1,
+ OK3 = 16#FFFE-1,
+ OK4 = 16#FFFF+1,
+ OKL = [OK1,OK2,OK3,OK4],
+
+ Illegal1 = 16#D800,
+ Illegal2 = 16#DFFF,
+ Illegal3 = 16#FFFE,
+ Illegal4 = 16#FFFF,
+ IllegalL = [Illegal1,Illegal2,Illegal3,Illegal4],
+
+ [{ok,[{comment,1,[$%,$%,$\s,OK]}],1} =
+ erl_scan:string("%% "++[OK], 1, [return]) ||
+ OK <- OKL],
+ {ok,[{comment,_,[$%,$%,$\s,OK1]}],{1,5}} =
+ erl_scan:string("%% "++[OK1], {1,1}, [return]),
+ [{error,{1,erl_scan,{illegal,character}},1} =
+ erl_scan:string("%% "++[Illegal], 1, [return]) ||
+ Illegal <- IllegalL],
+ {error,{{1,1},erl_scan,{illegal,character}},{1,5}} =
+ erl_scan:string("%% "++[Illegal1], {1,1}, [return]),
+
+ [{ok,[],1} = erl_scan:string("%% "++[OK], 1, []) ||
+ OK <- OKL],
+ {ok,[],{1,5}} = erl_scan:string("%% "++[OK1], {1,1}, []),
+ [{error,{1,erl_scan,{illegal,character}},1} =
+ erl_scan:string("%% "++[Illegal], 1, []) ||
+ Illegal <- IllegalL],
+ {error,{{1,1},erl_scan,{illegal,character}},{1,5}} =
+ erl_scan:string("%% "++[Illegal1], {1,1}, []),
+
+ [{ok,[{string,{1,1},[OK]}],{1,4}} =
+ erl_scan:string("\""++[OK]++"\"",{1,1}) ||
+ OK <- OKL],
+ [{error,{{1,2},erl_scan,{illegal,character}},{1,3}} =
+ erl_scan:string("\""++[OK]++"\"",{1,1}) ||
+ OK <- IllegalL],
+
+ [{error,{{1,1},erl_scan,{illegal,character}},{1,2}} =
+ erl_scan:string([Illegal],{1,1}) ||
+ Illegal <- IllegalL],
+
+ {ok,[{char,{1,1},OK1}],{1,3}} =
+ erl_scan:string([$$,OK1],{1,1}),
+ {error,{{1,1},erl_scan,{illegal,character}},{1,2}} =
+ erl_scan:string([$$,Illegal1],{1,1}),
+
+ {ok,[{char,{1,1},OK1}],{1,4}} =
+ erl_scan:string([$$,$\\,OK1],{1,1}),
+ {error,{{1,1},erl_scan,{illegal,character}},{1,4}} =
+ erl_scan:string([$$,$\\,Illegal1],{1,1}),
+
+ {ok,[{string,{1,1},[55295]}],{1,5}} =
+ erl_scan:string("\"\\"++[OK1]++"\"",{1,1}),
+ {error,{{1,2},erl_scan,{illegal,character}},{1,4}} =
+ erl_scan:string("\"\\"++[Illegal1]++"\"",{1,1}),
+
+ {ok,[{char,{1,1},OK1}],{1,10}} =
+ erl_scan:string("$\\x{D7FF}",{1,1}),
+ {error,{{1,1},erl_scan,{illegal,character}},{1,10}} =
+ erl_scan:string("$\\x{D800}",{1,1}),
+
+ %% Not erl_scan, but erl_parse.
+ {integer,0,1} = erl_parse:abstract(1),
+ Float = 3.14, {float,0,Float} = erl_parse:abstract(Float),
+ {nil,0} = erl_parse:abstract([]),
+ {bin,0,
+ [{bin_element,0,{integer,0,1},default,default},
+ {bin_element,0,{integer,0,2},default,default}]} =
+ erl_parse:abstract(<<1,2>>),
+ {cons,0,{tuple,0,[{atom,0,a}]},{atom,0,b}} =
+ erl_parse:abstract([{a} | b]),
+ {string,0,"str"} = erl_parse:abstract("str"),
+ {cons,0,
+ {integer,0,$a},
+ {cons,0,{integer,0,1024},{string,0,"c"}}} =
+ erl_parse:abstract("a"++[1024]++"c"),
+
+ Line = 17,
+ {integer,Line,1} = erl_parse:abstract(1, Line),
+ Float = 3.14, {float,Line,Float} = erl_parse:abstract(Float, Line),
+ {nil,Line} = erl_parse:abstract([], Line),
+ {bin,Line,
+ [{bin_element,Line,{integer,Line,1},default,default},
+ {bin_element,Line,{integer,Line,2},default,default}]} =
+ erl_parse:abstract(<<1,2>>, Line),
+ {cons,Line,{tuple,Line,[{atom,Line,a}]},{atom,Line,b}} =
+ erl_parse:abstract([{a} | b], Line),
+ {string,Line,"str"} = erl_parse:abstract("str", Line),
+ {cons,Line,
+ {integer,Line,$a},
+ {cons,Line,{integer,Line,1024},{string,Line,"c"}}} =
+ erl_parse:abstract("a"++[1024]++"c", Line),
+
+ Opts1 = [{line,17}],
+ {integer,Line,1} = erl_parse:abstract(1, Opts1),
+ Float = 3.14, {float,Line,Float} = erl_parse:abstract(Float, Opts1),
+ {nil,Line} = erl_parse:abstract([], Opts1),
+ {bin,Line,
+ [{bin_element,Line,{integer,Line,1},default,default},
+ {bin_element,Line,{integer,Line,2},default,default}]} =
+ erl_parse:abstract(<<1,2>>, Opts1),
+ {cons,Line,{tuple,Line,[{atom,Line,a}]},{atom,Line,b}} =
+ erl_parse:abstract([{a} | b], Opts1),
+ {string,Line,"str"} = erl_parse:abstract("str", Opts1),
+ {cons,Line,
+ {integer,Line,$a},
+ {cons,Line,{integer,Line,1024},{string,Line,"c"}}} =
+ erl_parse:abstract("a"++[1024]++"c", Opts1),
+
+ [begin
+ {integer,Line,1} = erl_parse:abstract(1, Opts2),
+ Float = 3.14, {float,Line,Float} = erl_parse:abstract(Float, Opts2),
+ {nil,Line} = erl_parse:abstract([], Opts2),
+ {bin,Line,
+ [{bin_element,Line,{integer,Line,1},default,default},
+ {bin_element,Line,{integer,Line,2},default,default}]} =
+ erl_parse:abstract(<<1,2>>, Opts2),
+ {cons,Line,{tuple,Line,[{atom,Line,a}]},{atom,Line,b}} =
+ erl_parse:abstract([{a} | b], Opts2),
+ {string,Line,"str"} = erl_parse:abstract("str", Opts2),
+ {string,Line,[97,1024,99]} =
+ erl_parse:abstract("a"++[1024]++"c", Opts2)
+ end || Opts2 <- [[{encoding,unicode},{line,Line}],
+ [{encoding,utf8},{line,Line}]]],
+
+ {cons,0,
+ {integer,0,97},
+ {cons,0,{integer,0,1024},{string,0,"c"}}} =
+ erl_parse:abstract("a"++[1024]++"c", [{encoding,latin1}]),
+ ok.
+
+otp_10990(doc) ->
+ "OTP-10990. Floating point number in input string.";
+otp_10990(suite) ->
+ [];
+otp_10990(Config) when is_list(Config) ->
+ {'EXIT',_} = (catch {foo, erl_scan:string([$",42.0,$"],1)}),
+ ok.
+
+otp_10992(doc) ->
+ "OTP-10992. List of floats to abstract format.";
+otp_10992(suite) ->
+ [];
+otp_10992(Config) when is_list(Config) ->
+ {cons,0,{float,0,42.0},{nil,0}} =
+ erl_parse:abstract([42.0], [{encoding,unicode}]),
+ {cons,0,{float,0,42.0},{nil,0}} =
+ erl_parse:abstract([42.0], [{encoding,utf8}]),
+ {cons,0,{integer,0,65},{cons,0,{float,0,42.0},{nil,0}}} =
+ erl_parse:abstract([$A,42.0], [{encoding,unicode}]),
+ {cons,0,{integer,0,65},{cons,0,{float,0,42.0},{nil,0}}} =
+ erl_parse:abstract([$A,42.0], [{encoding,utf8}]),
+ ok.
+
test_string(String, Expected) ->
{ok, Expected, _End} = erl_scan:string(String),
test(String).
diff --git a/lib/stdlib/test/escript_SUITE.erl b/lib/stdlib/test/escript_SUITE.erl
index 38c085616d..eebfec3336 100644
--- a/lib/stdlib/test/escript_SUITE.erl
+++ b/lib/stdlib/test/escript_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2007-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2007-2013. 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
@@ -26,6 +26,7 @@
errors/1,
strange_name/1,
emulator_flags/1,
+ emulator_flags_no_shebang/1,
module_script/1,
beam_script/1,
archive_script/1,
@@ -34,7 +35,8 @@
create_and_extract/1,
foldl/1,
overflow/1,
- verify_sections/3
+ verify_sections/3,
+ unicode/1
]).
-include_lib("test_server/include/test_server.hrl").
@@ -44,9 +46,10 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[basic, errors, strange_name, emulator_flags,
+ emulator_flags_no_shebang,
module_script, beam_script, archive_script, epp,
create_and_extract, foldl, overflow,
- archive_script_file_access].
+ archive_script_file_access, unicode].
groups() ->
[].
@@ -64,7 +67,7 @@ end_per_group(_GroupName, Config) ->
Config.
init_per_testcase(_Case, Config) ->
- ?line Dog = ?t:timetrap(?t:minutes(2)),
+ ?line Dog = ?t:timetrap(?t:minutes(5)),
[{watchdog,Dog}|Config].
end_per_testcase(_Case, Config) ->
@@ -149,6 +152,21 @@ emulator_flags(Config) when is_list(Config) ->
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+emulator_flags_no_shebang(Config) when is_list(Config) ->
+ Data = ?config(data_dir, Config),
+ Dir = filename:absname(Data), %Get rid of trailing slash.
+ %% Need run_with_opts, to always use "escript" explicitly
+ ?line run_with_opts(Dir, "", "emulator_flags_no_shebang -arg1 arg2 arg3",
+ [<<"main:[\"-arg1\",\"arg2\",\"arg3\"]\n"
+ "nostick:[{nostick,[]}]\n"
+ "mnesia:[{mnesia,[\"dir\",\"a/directory\"]},{mnesia,[\"debug\",\"verbose\"]}]\n"
+ "ERL_FLAGS=false\n"
+ "unknown:[]\n"
+ "ExitCode:0">>]),
+ ok.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Pick the source code from the emulator_flags script
%% Generate a new escript with a module header
@@ -597,7 +615,7 @@ archive_script_file_access(Config) when is_list(Config) ->
%% 3. If symlinks are supported, run one of the scripts via a symlink.
%%
%% This is in order to test error b) described above this test case.
- case file:read_link(Symlink2) of
+ case element(1,os:type()) =:= win32 orelse file:read_link(Symlink2) of
{ok,_} ->
run(PrivDir, "./" ++ SymlinkName2 ++ " " ++ ScriptName2,
[<<"ExitCode:0">>]);
@@ -618,7 +636,7 @@ compile_files([File | Files], SrcDir, OutDir) ->
case filename:extension(File) of
".erl" ->
AbsFile = filename:join([SrcDir, File]),
- case compile:file(AbsFile, [{outdir, OutDir}]) of
+ case compile:file(AbsFile, [{outdir, OutDir},report_errors]) of
{ok, _Mod} ->
compile_files(Files, SrcDir, OutDir);
Error ->
@@ -810,6 +828,8 @@ normalize_sections(Sections) ->
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
foldl(Config) when is_list(Config) ->
{NewFile, _FileInfo,
_EmuArg, _Source,
@@ -887,6 +907,23 @@ emulate_escript_foldl(Fun, Acc, File) ->
{error, Reason}
end.
+unicode(Config) when is_list(Config) ->
+ Data = ?config(data_dir, Config),
+ Dir = filename:absname(Data), %Get rid of trailing slash.
+ run(Dir, "unicode1",
+ [<<"escript: exception error: an error occurred when evaluating"
+ " an arithmetic expression\n in operator '/'/2\n "
+ "called as <<224,170,170>> / <<224,170,170>>\nExitCode:127">>]),
+ run(Dir, "unicode2",
+ [<<"escript: exception error: an error occurred when evaluating"
+ " an arithmetic expression\n in operator '/'/2\n "
+ "called as <<\"\xaa\">> / <<\"\xaa\">>\nExitCode:127">>]),
+ run(Dir, "unicode3", [<<"ExitCode:0">>]),
+ run(Dir, "unicode4", [<<"ExitCode:0">>]),
+ run(Dir, "unicode5", [<<"ExitCode:0">>]),
+ run(Dir, "unicode6", [<<"ExitCode:0">>]),
+ ok.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
overflow(Config) when is_list(Config) ->
diff --git a/lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl b/lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl
index b03c8ba70d..523621e4f3 100644
--- a/lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl
+++ b/lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2012. All Rights Reserved.
+%% Copyright Ericsson AB 2012-2013. 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
@@ -56,7 +56,7 @@ main([RelArchiveFile]) ->
%% If symlinks are supported on this platform...
RelSymlinkArchiveFile = "symlink_to_" ++ RelArchiveFile,
- case file:read_link(RelSymlinkArchiveFile) of
+ case element(1,os:type()) =:= win32 orelse file:read_link(RelSymlinkArchiveFile) of
{ok,_} ->
DotSlashSymlinkArchiveFile = "./" ++ RelSymlinkArchiveFile,
AbsSymlinkArchiveFile=filename:join(filename:dirname(AbsArchiveFile),
diff --git a/lib/stdlib/test/escript_SUITE_data/emulator_flags_no_shebang b/lib/stdlib/test/escript_SUITE_data/emulator_flags_no_shebang
new file mode 100644
index 0000000000..47d843ebe1
--- /dev/null
+++ b/lib/stdlib/test/escript_SUITE_data/emulator_flags_no_shebang
@@ -0,0 +1,10 @@
+%% -*- erlang -*-
+%%! -nostick -mnesia dir a/directory -mnesia debug verbose
+
+main(MainArgs) ->
+ io:format("main:~p\n",[MainArgs]),
+ ErlArgs = init:get_arguments(),
+ io:format("nostick:~p\n",[[E || E <- ErlArgs, element(1, E) =:= nostick]]),
+ io:format("mnesia:~p\n", [[E || E <- ErlArgs, element(1, E) =:= mnesia]]),
+ io:format("ERL_FLAGS=~p\n", [os:getenv("ERL_FLAGS")]),
+ io:format("unknown:~p\n",[[E || E <- ErlArgs, element(1, E) =:= unknown]]).
diff --git a/lib/stdlib/test/escript_SUITE_data/unicode1 b/lib/stdlib/test/escript_SUITE_data/unicode1
new file mode 100755
index 0000000000..351bb785e5
--- /dev/null
+++ b/lib/stdlib/test/escript_SUITE_data/unicode1
@@ -0,0 +1,14 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+
+-export([main/1]).
+
+main(_) ->
+ ok = io:setopts([{encoding,unicode}]),
+ _D = erlang:system_flag(backtrace_depth, 0),
+ A = <<"\x{aaa}"/utf8>>,
+ S = lists:flatten(io_lib:format("~p/~p.", [A, A])),
+ {ok, Ts, _} = erl_scan:string(S, 1, [unicode]),
+ {ok, Es} = erl_parse:parse_exprs(Ts),
+ B = erl_eval:new_bindings(),
+ erl_eval:exprs(Es, B).
diff --git a/lib/stdlib/test/escript_SUITE_data/unicode2 b/lib/stdlib/test/escript_SUITE_data/unicode2
new file mode 100755
index 0000000000..495188f6f0
--- /dev/null
+++ b/lib/stdlib/test/escript_SUITE_data/unicode2
@@ -0,0 +1,14 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+
+-export([main/1]).
+
+main(_) ->
+ ok = io:setopts([{encoding,latin1}]),
+ _D = erlang:system_flag(backtrace_depth, 0),
+ A = <<"\x{aa}">>,
+ S = lists:flatten(io_lib:format("~p/~p.", [A, A])),
+ {ok, Ts, _} = erl_scan:string(S, 1, [unicode]),
+ {ok, Es} = erl_parse:parse_exprs(Ts),
+ B = erl_eval:new_bindings(),
+ erl_eval:exprs(Es, B).
diff --git a/lib/stdlib/test/escript_SUITE_data/unicode3 b/lib/stdlib/test/escript_SUITE_data/unicode3
new file mode 100755
index 0000000000..0702ecf309
--- /dev/null
+++ b/lib/stdlib/test/escript_SUITE_data/unicode3
@@ -0,0 +1,13 @@
+#!/usr/bin/env escript
+%% -*- erlang; coding: latin-1 -*-
+
+-export([main/1]).
+
+main(_) ->
+ ok = io:setopts([{encoding,unicode}]),
+ Bin1 = <<"örn_Ѐ שלום-שלום+של 日本語">>,
+
+ L = [246,114,110,95,1024,32,1513,1500,1493,1501,45,1513,1500,1493,
+ 1501,43,1513,1500,32,26085,26412,35486],
+ L = unicode:characters_to_list(Bin1, utf8),
+ ok.
diff --git a/lib/stdlib/test/escript_SUITE_data/unicode4 b/lib/stdlib/test/escript_SUITE_data/unicode4
new file mode 100755
index 0000000000..a7563a613a
--- /dev/null
+++ b/lib/stdlib/test/escript_SUITE_data/unicode4
@@ -0,0 +1,12 @@
+#!/usr/bin/env escript
+%% -*- erlang; encoding:utf-8 -*-
+
+-export([main/1]).
+
+main(_) ->
+ ok = io:setopts([{encoding,unicode}]),
+ Bin1 = <<"örn_Ѐ שלום-שלום+של 日本語">>,
+ L = [246,114,110,95,1024,32,1513,1500,1493,1501,45,1513,1500,1493,
+ 1501,43,1513,1500,32,26085,26412,35486],
+ L = unicode:characters_to_list(Bin1, utf8),
+ ok.
diff --git a/lib/stdlib/test/escript_SUITE_data/unicode5 b/lib/stdlib/test/escript_SUITE_data/unicode5
new file mode 100755
index 0000000000..e95da3361d
--- /dev/null
+++ b/lib/stdlib/test/escript_SUITE_data/unicode5
@@ -0,0 +1,12 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+-export([main/1]).
+%% -*- encoding:latin-1 -*-
+
+main(_) ->
+ ok = io:setopts([{encoding,unicode}]),
+ Bin1 = <<"örn_Ѐ שלום-שלום+של 日本語">>,
+ L = [246,114,110,95,1024,32,1513,1500,1493,1501,45,1513,1500,1493,
+ 1501,43,1513,1500,32,26085,26412,35486],
+ L = unicode:characters_to_list(Bin1, utf8),
+ ok.
diff --git a/lib/stdlib/test/escript_SUITE_data/unicode6 b/lib/stdlib/test/escript_SUITE_data/unicode6
new file mode 100755
index 0000000000..8027a2a08c
--- /dev/null
+++ b/lib/stdlib/test/escript_SUITE_data/unicode6
@@ -0,0 +1,13 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+%%! +pc unicode
+-export([main/1]).
+%% -*- encoding:utf-8 -*-
+
+main(_) ->
+ ok = io:setopts([{encoding,unicode}]),
+ Bin1 = <<"örn_Ѐ שלום-שלום+של 日本語">>,
+ L = [246,114,110,95,1024,32,1513,1500,1493,1501,45,1513,1500,1493,
+ 1501,43,1513,1500,32,26085,26412,35486],
+ L = unicode:characters_to_list(Bin1, utf8),
+ ok.
diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl
index 95f10b1df3..2b29566942 100644
--- a/lib/stdlib/test/ets_SUITE.erl
+++ b/lib/stdlib/test/ets_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. 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
@@ -75,6 +75,7 @@
-export([otp_9932/1]).
-export([otp_9423/1]).
-export([otp_10182/1]).
+-export([memory_check_summary/1]).
-export([init_per_testcase/2, end_per_testcase/2]).
%% Convenience for manual testing
@@ -96,7 +97,7 @@
misc1_do/1, safe_fixtable_do/1, info_do/1, dups_do/1, heavy_lookup_do/1,
heavy_lookup_element_do/1, member_do/1, otp_5340_do/1, otp_7665_do/1, meta_wb_do/1,
do_heavy_concurrent/1, tab2file2_do/2, exit_large_table_owner_do/2,
- types_do/1, sleeper/0, rpc_externals/0, memory_do/1,
+ types_do/1, sleeper/0, memory_do/1,
ms_tracee_dummy/1, ms_tracee_dummy/2, ms_tracee_dummy/3, ms_tracee_dummy/4
]).
@@ -149,7 +150,9 @@ all() ->
give_away, setopts, bad_table, types,
otp_10182,
otp_9932,
- otp_9423].
+ otp_9423,
+
+ memory_check_summary]. % MUST BE LAST
groups() ->
[{new, [],
@@ -185,7 +188,8 @@ init_per_suite(Config) ->
end_per_suite(_Config) ->
stop_spawn_logger(),
- catch erts_debug:set_internal_state(available_internal_state, false).
+ catch erts_debug:set_internal_state(available_internal_state, false),
+ ok.
init_per_group(_GroupName, Config) ->
Config.
@@ -193,6 +197,26 @@ init_per_group(_GroupName, Config) ->
end_per_group(_GroupName, Config) ->
Config.
+%% Test that we did not have "too many" failed verify_etsmem()'s
+%% in the test suite.
+%% verify_etsmem() may give a low number of false positives
+%% as concurrent activities, such as lingering processes
+%% from earlier test suites, may do unrelated ets (de)allocations.
+memory_check_summary(_Config) ->
+ case whereis(ets_test_spawn_logger) of
+ undefined ->
+ ?t:fail("No spawn logger exist");
+ _ ->
+ ets_test_spawn_logger ! {self(), get_failed_memchecks},
+ receive {get_failed_memchecks, FailedMemchecks} -> ok end,
+ io:format("Failed memchecks: ~p\n",[FailedMemchecks]),
+ if FailedMemchecks > 3 ->
+ ct:fail("Too many failed (~p) memchecks", [FailedMemchecks]);
+ true ->
+ ok
+ end
+ end.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2170,20 +2194,29 @@ heir_do(Opts) ->
?line undefined = ets:info(foo),
%% When heir dies and pid reused before founder dies
- NextPidIx = erts_debug:get_internal_state(next_pid),
- {Founder4,MrefF4} = my_spawn_monitor(fun()->heir_founder(Master,"The dying heir",Opts)end),
- {Heir4,MrefH4} = my_spawn_monitor(fun()->heir_heir(Founder4)end),
- Founder4 ! {go, Heir4},
- ?line {'DOWN', MrefH4, process, Heir4, normal} = receive_any(),
- erts_debug:set_internal_state(next_pid, NextPidIx),
- {Heir4,MrefH4_B} = spawn_monitor_with_pid(Heir4,
- fun()-> ?line die_please = receive_any() end),
- Founder4 ! die_please,
- ?line {'DOWN', MrefF4, process, Founder4, normal} = receive_any(),
- Heir4 ! die_please,
- ?line {'DOWN', MrefH4_B, process, Heir4, normal} = receive_any(),
- ?line undefined = ets:info(foo),
-
+ repeat_while(fun() ->
+ NextPidIx = erts_debug:get_internal_state(next_pid),
+ {Founder4,MrefF4} = my_spawn_monitor(fun()->heir_founder(Master,"The dying heir",Opts)end),
+ {Heir4,MrefH4} = my_spawn_monitor(fun()->heir_heir(Founder4)end),
+ Founder4 ! {go, Heir4},
+ ?line {'DOWN', MrefH4, process, Heir4, normal} = receive_any(),
+ erts_debug:set_internal_state(next_pid, NextPidIx),
+ DoppelGanger = spawn_monitor_with_pid(Heir4,
+ fun()-> ?line die_please = receive_any() end),
+ Founder4 ! die_please,
+ ?line {'DOWN', MrefF4, process, Founder4, normal} = receive_any(),
+ case DoppelGanger of
+ {Heir4,MrefH4_B} ->
+ Heir4 ! die_please,
+ ?line {'DOWN', MrefH4_B, process, Heir4, normal} = receive_any(),
+ ?line undefined = ets:info(foo),
+ false;
+ failed ->
+ io:format("Failed to spawn process with pid ~p\n", [Heir4]),
+ true % try again
+ end
+ end),
+
?line verify_etsmem(EtsMem).
heir_founder(Master, HeirData, Opts) ->
@@ -3209,6 +3242,7 @@ delete_large_tab_1(Name, Flags, Data, Fix) ->
end
end,
0),
+ SchedTracerMon = monitor(process, SchedTracer),
?line Loopers = start_loopers(erlang:system_info(schedulers),
Prio,
fun (_) -> erlang:yield() end,
@@ -3228,12 +3262,14 @@ delete_large_tab_1(Name, Flags, Data, Fix) ->
N >= 5 -> ?line ok;
true -> ?line ?t:fail()
end
- end.
+ end,
+ receive {'DOWN',SchedTracerMon,process,SchedTracer,_} -> ok end,
+ ok.
delete_large_named_table(doc) ->
"Delete a large name table and try to create a new table with the same name in another process.";
delete_large_named_table(Config) when is_list(Config) ->
- ?line Data = [{erlang:phash2(I, 16#ffffff),I} || I <- lists:seq(1, 500000)],
+ ?line Data = [{erlang:phash2(I, 16#ffffff),I} || I <- lists:seq(1, 200000)],
?line EtsMem = etsmem(),
repeat_for_opts(fun(Opts) -> delete_large_named_table_do(Opts,Data) end),
?line verify_etsmem(EtsMem),
@@ -3255,16 +3291,16 @@ delete_large_named_table_1(Name, Flags, Data, Fix) ->
?line lists:foreach(fun({K,_}) -> ets:delete(Tab, K) end, Data)
end,
Parent = self(),
- Pid = my_spawn_link(fun() ->
- receive
- {trace,Parent,call,_} ->
- ets_new(Name, [named_table])
- end
- end),
- ?line erlang:trace(self(), true, [call,{tracer,Pid}]),
- ?line erlang:trace_pattern({ets,delete,1}, true, [global]),
- ?line erlang:yield(), true = ets:delete(Tab),
- ?line erlang:trace_pattern({ets,delete,1}, false, [global]),
+ {Pid, MRef} = my_spawn_opt(fun() ->
+ receive
+ ets_new ->
+ ets_new(Name, [named_table])
+ end
+ end,
+ [link, monitor]),
+ true = ets:delete(Tab),
+ Pid ! ets_new,
+ receive {'DOWN',MRef,process,Pid,_} -> ok end,
ok.
evil_delete(doc) ->
@@ -4208,21 +4244,13 @@ heavy_lookup_element(Config) when is_list(Config) ->
repeat_for_opts(heavy_lookup_element_do).
heavy_lookup_element_do(Opts) ->
- ?line EtsMem = etsmem(),
- ?line Tab = ets_new(foobar_table, [set, protected, {keypos, 2} | Opts]),
- ?line ok = fill_tab2(Tab, 0, 7000),
- case os:type() of
- vxworks ->
- ?line ?t:do_times(5, ?MODULE, do_lookup_element,
- [Tab, 6999, 1]);
- % lookup ALL elements 5 times.
- _ ->
- ?line ?t:do_times(50, ?MODULE, do_lookup_element,
- [Tab, 6999, 1])
- % lookup ALL elements 50 times.
- end,
- ?line true = ets:delete(Tab),
- ?line verify_etsmem(EtsMem).
+ EtsMem = etsmem(),
+ Tab = ets_new(foobar_table, [set, protected, {keypos, 2} | Opts]),
+ ok = fill_tab2(Tab, 0, 7000),
+ % lookup ALL elements 50 times
+ ?t:do_times(50, ?MODULE, do_lookup_element, [Tab, 6999, 1]),
+ true = ets:delete(Tab),
+ verify_etsmem(EtsMem).
do_lookup_element(_Tab, 0, _) -> ok;
do_lookup_element(Tab, N, M) ->
@@ -5598,17 +5626,25 @@ etsmem() ->
MemInfo ->
CS = lists:foldl(
fun ({instance, _, L}, Acc) ->
- {value,{_,SBMBCS}} = lists:keysearch(sbmbcs, 1, L),
- {value,{_,MBCS}} = lists:keysearch(mbcs, 1, L),
- {value,{_,SBCS}} = lists:keysearch(sbcs, 1, L),
- [SBMBCS,MBCS,SBCS | Acc]
+ {value,{mbcs,MBCS}} = lists:keysearch(mbcs, 1, L),
+ {value,{sbcs,SBCS}} = lists:keysearch(sbcs, 1, L),
+ NewAcc = [MBCS, SBCS | Acc],
+ case lists:keysearch(mbcs_pool, 1, L) of
+ {value,{mbcs_pool, MBCS_POOL}} ->
+ [MBCS_POOL|NewAcc];
+ _ -> NewAcc
+ end
end,
[],
MemInfo),
lists:foldl(
fun(L, {Bl0,BlSz0}) ->
- {value,{_,Bl,_,_}} = lists:keysearch(blocks, 1, L),
- {value,{_,BlSz,_,_}} = lists:keysearch(blocks_size, 1, L),
+ {value,BlTup} = lists:keysearch(blocks, 1, L),
+ blocks = element(1, BlTup),
+ Bl = element(2, BlTup),
+ {value,BlSzTup} = lists:keysearch(blocks_size, 1, L),
+ blocks_size = element(1, BlSzTup),
+ BlSz = element(2, BlSzTup),
{Bl0+Bl,BlSz0+BlSz}
end, {0,0}, CS)
end},
@@ -5631,7 +5667,8 @@ verify_etsmem({MemInfo,AllTabs}) ->
io:format("Actual: ~p", [MemInfo2]),
io:format("Changed tables before: ~p\n",[AllTabs -- AllTabs2]),
io:format("Changed tables after: ~p\n", [AllTabs2 -- AllTabs]),
- ?t:fail()
+ ets_test_spawn_logger ! failed_memcheck,
+ {comment, "Failed memory check"}
end.
@@ -5653,10 +5690,10 @@ stop_loopers(Loopers) ->
looper(Fun, State) ->
looper(Fun, Fun(State)).
-spawn_logger(Procs) ->
+spawn_logger(Procs, FailedMemchecks) ->
receive
{new_test_proc, Proc} ->
- spawn_logger([Proc|Procs]);
+ spawn_logger([Proc|Procs], FailedMemchecks);
{sync_test_procs, Kill, From} ->
lists:foreach(fun (Proc) when From == Proc ->
ok;
@@ -5679,7 +5716,14 @@ spawn_logger(Procs) ->
end
end, Procs),
From ! test_procs_synced,
- spawn_logger([From])
+ spawn_logger([From], FailedMemchecks);
+
+ failed_memcheck ->
+ spawn_logger(Procs, FailedMemchecks+1);
+
+ {Pid, get_failed_memchecks} ->
+ Pid ! {get_failed_memchecks, FailedMemchecks},
+ spawn_logger(Procs, FailedMemchecks)
end.
pid_status(Pid) ->
@@ -5695,7 +5739,7 @@ start_spawn_logger() ->
case whereis(ets_test_spawn_logger) of
Pid when is_pid(Pid) -> true;
_ -> register(ets_test_spawn_logger,
- spawn_opt(fun () -> spawn_logger([]) end,
+ spawn_opt(fun () -> spawn_logger([], 0) end,
[{priority, max}]))
end.
@@ -5706,8 +5750,7 @@ start_spawn_logger() ->
stop_spawn_logger() ->
Mon = erlang:monitor(process, ets_test_spawn_logger),
(catch exit(whereis(ets_test_spawn_logger), kill)),
- receive {'DOWN', Mon, _, _, _} -> ok end,
- ok.
+ receive {'DOWN', Mon, _, _, _} -> ok end.
wait_for_test_procs() ->
wait_for_test_procs(false).
@@ -5795,25 +5838,20 @@ receive_any_spinning(Loops, N, Tries) when N>0 ->
spawn_monitor_with_pid(Pid, Fun) when is_pid(Pid) ->
- spawn_monitor_with_pid(Pid, Fun, 1, 10).
+ spawn_monitor_with_pid(Pid, Fun, 10).
-spawn_monitor_with_pid(Pid, Fun, N, M) when N > M*10 ->
- spawn_monitor_with_pid(Pid, Fun, N, M*10);
-spawn_monitor_with_pid(Pid, Fun, N, M) ->
- ?line false = is_process_alive(Pid),
+spawn_monitor_with_pid(_, _, 0) ->
+ failed;
+spawn_monitor_with_pid(Pid, Fun, N) ->
case my_spawn(fun()-> case self() of
Pid -> Fun();
_ -> die
end
end) of
- Pid ->
+ Pid ->
{Pid, erlang:monitor(process, Pid)};
- Other ->
- case N rem M of
- 0 -> io:format("Failed ~p times to get pid ~p (current = ~p)\n",[N,Pid,Other]);
- _ -> ok
- end,
- spawn_monitor_with_pid(Pid,Fun,N+1,M)
+ _Other ->
+ spawn_monitor_with_pid(Pid,Fun,N-1)
end.
@@ -5993,33 +6031,103 @@ make_ext_ref() ->
init_externals() ->
case get(externals) of
undefined ->
- SysDistSz = ets:info(sys_dist,size),
- ?line Pa = filename:dirname(code:which(?MODULE)),
- ?line {ok, Node} = test_server:start_node(plopp, slave, [{args, " -pa " ++ Pa}]),
- ?line Res = case rpc:call(Node, ?MODULE, rpc_externals, []) of
- {badrpc, {'EXIT', E}} ->
- test_server:fail({rpcresult, E});
- R -> R
- end,
- ?line test_server:stop_node(Node),
-
- %% Wait for table 'sys_dist' to stabilize
- repeat_while(fun() ->
- case ets:info(sys_dist,size) of
- SysDistSz -> false;
- Sz ->
- io:format("Waiting for sys_dist to revert size from ~p to size ~p\n",
- [Sz, SysDistSz]),
- receive after 1000 -> true end
- end
- end),
+ OtherNode = {gurka@sallad, 1},
+ Res = {mk_pid(OtherNode, 7645, 8123),
+ mk_port(OtherNode, 187489773),
+ mk_ref(OtherNode, [262143, 1293964255, 3291964278])},
put(externals, Res);
{_,_,_} -> ok
end.
-rpc_externals() ->
- {self(), make_port(), make_ref()}.
+%%
+%% Node container constructor functions
+%%
+
+-define(VERSION_MAGIC, 131).
+-define(PORT_EXT, 102).
+-define(PID_EXT, 103).
+-define(NEW_REFERENCE_EXT, 114).
+
+uint32_be(Uint) when is_integer(Uint), 0 =< Uint, Uint < 1 bsl 32 ->
+ [(Uint bsr 24) band 16#ff,
+ (Uint bsr 16) band 16#ff,
+ (Uint bsr 8) band 16#ff,
+ Uint band 16#ff];
+uint32_be(Uint) ->
+ exit({badarg, uint32_be, [Uint]}).
+
+uint16_be(Uint) when is_integer(Uint), 0 =< Uint, Uint < 1 bsl 16 ->
+ [(Uint bsr 8) band 16#ff,
+ Uint band 16#ff];
+uint16_be(Uint) ->
+ exit({badarg, uint16_be, [Uint]}).
+
+uint8(Uint) when is_integer(Uint), 0 =< Uint, Uint < 1 bsl 8 ->
+ Uint band 16#ff;
+uint8(Uint) ->
+ exit({badarg, uint8, [Uint]}).
+
+mk_pid({NodeName, Creation}, Number, Serial) when is_atom(NodeName) ->
+ <<?VERSION_MAGIC, NodeNameExt/binary>> = term_to_binary(NodeName),
+ mk_pid({NodeNameExt, Creation}, Number, Serial);
+mk_pid({NodeNameExt, Creation}, Number, Serial) ->
+ case catch binary_to_term(list_to_binary([?VERSION_MAGIC,
+ ?PID_EXT,
+ NodeNameExt,
+ uint32_be(Number),
+ uint32_be(Serial),
+ uint8(Creation)])) of
+ Pid when is_pid(Pid) ->
+ Pid;
+ {'EXIT', {badarg, _}} ->
+ exit({badarg, mk_pid, [{NodeNameExt, Creation}, Number, Serial]});
+ Other ->
+ exit({unexpected_binary_to_term_result, Other})
+ end.
+
+mk_port({NodeName, Creation}, Number) when is_atom(NodeName) ->
+ <<?VERSION_MAGIC, NodeNameExt/binary>> = term_to_binary(NodeName),
+ mk_port({NodeNameExt, Creation}, Number);
+mk_port({NodeNameExt, Creation}, Number) ->
+ case catch binary_to_term(list_to_binary([?VERSION_MAGIC,
+ ?PORT_EXT,
+ NodeNameExt,
+ uint32_be(Number),
+ uint8(Creation)])) of
+ Port when is_port(Port) ->
+ Port;
+ {'EXIT', {badarg, _}} ->
+ exit({badarg, mk_port, [{NodeNameExt, Creation}, Number]});
+ Other ->
+ exit({unexpected_binary_to_term_result, Other})
+ end.
+
+mk_ref({NodeName, Creation}, Numbers) when is_atom(NodeName),
+ is_integer(Creation),
+ is_list(Numbers) ->
+ <<?VERSION_MAGIC, NodeNameExt/binary>> = term_to_binary(NodeName),
+ mk_ref({NodeNameExt, Creation}, Numbers);
+mk_ref({NodeNameExt, Creation}, Numbers) when is_binary(NodeNameExt),
+ is_integer(Creation),
+ is_list(Numbers) ->
+ case catch binary_to_term(list_to_binary([?VERSION_MAGIC,
+ ?NEW_REFERENCE_EXT,
+ uint16_be(length(Numbers)),
+ NodeNameExt,
+ uint8(Creation),
+ lists:map(fun (N) ->
+ uint32_be(N)
+ end,
+ Numbers)])) of
+ Ref when is_reference(Ref) ->
+ Ref;
+ {'EXIT', {badarg, _}} ->
+ exit({badarg, mk_ref, [{NodeNameExt, Creation}, Numbers]});
+ Other ->
+ exit({unexpected_binary_to_term_result, Other})
+ end.
+
make_sub_binary(Bin) when is_binary(Bin) ->
{_,B} = split_binary(list_to_binary([0,1,3,Bin]), 3),
@@ -6048,11 +6156,18 @@ repeat_for_opts(F, OptGenList) ->
repeat_for_opts(F, OptGenList, []).
repeat_for_opts(F, [], Acc) ->
- lists:map(fun(Opts) ->
- OptList = lists:filter(fun(E) -> E =/= void end, Opts),
- io:format("Calling with options ~p\n",[OptList]),
- F(OptList)
- end, Acc);
+ lists:foldl(fun(Opts, RV_Acc) ->
+ OptList = lists:filter(fun(E) -> E =/= void end, Opts),
+ io:format("Calling with options ~p\n",[OptList]),
+ RV = F(OptList),
+ case RV_Acc of
+ {comment,_} -> RV_Acc;
+ _ -> case RV of
+ {comment,_} -> RV;
+ _ -> [RV | RV_Acc]
+ end
+ end
+ end, [], Acc);
repeat_for_opts(F, [OptList | Tail], []) when is_list(OptList) ->
repeat_for_opts(F, Tail, [[Opt] || Opt <- OptList]);
repeat_for_opts(F, [OptList | Tail], AccList) when is_list(OptList) ->
diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl
index 1de639a166..4a67d68428 100644
--- a/lib/stdlib/test/filelib_SUITE.erl
+++ b/lib/stdlib/test/filelib_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2013. 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
@@ -65,19 +65,26 @@ wildcard_one(Config) when is_list(Config) ->
?line {ok,OldCwd} = file:get_cwd(),
?line Dir = filename:join(?config(priv_dir, Config), "wildcard_one"),
?line ok = file:make_dir(Dir),
+ do_wildcard_1(Dir,
+ fun(Wc) ->
+ filelib:wildcard(Wc, Dir, erl_prim_loader)
+ end),
?line file:set_cwd(Dir),
- ?line do_wildcard_1(Dir, fun(Wc) -> filelib:wildcard(Wc) end),
+ do_wildcard_1(Dir,
+ fun(Wc) ->
+ L = filelib:wildcard(Wc),
+ L = filelib:wildcard(Wc, erl_prim_loader),
+ L = filelib:wildcard(Wc, "."),
+ L = filelib:wildcard(Wc, Dir)
+ end),
?line file:set_cwd(OldCwd),
?line ok = file:del_dir(Dir),
ok.
wildcard_two(Config) when is_list(Config) ->
?line Dir = filename:join(?config(priv_dir, Config), "wildcard_two"),
- ?line DirB = unicode:characters_to_binary(Dir, file:native_name_encoding()),
?line ok = file:make_dir(Dir),
?line do_wildcard_1(Dir, fun(Wc) -> io:format("~p~n",[{Wc,Dir, X = filelib:wildcard(Wc, Dir)}]),X end),
- ?line do_wildcard_1(Dir, fun(Wc) -> io:format("~p~n",[{Wc,DirB, X = filelib:wildcard(Wc, DirB)}]),
- [unicode:characters_to_list(Y,file:native_name_encoding()) || Y <- X] end),
?line do_wildcard_1(Dir, fun(Wc) -> filelib:wildcard(Wc, Dir++"/") end),
case os:type() of
{win32,_} ->
@@ -130,6 +137,9 @@ do_wildcard_2(Dir, Wcf) ->
?line ["abc","abcdef"] = Wcf("a*{def,}"),
?line ["abc","abcdef"] = Wcf("a*{,def}"),
+ %% Constant wildcard.
+ ["abcdef"] = Wcf("abcdef"),
+
%% Negative tests.
?line [] = Wcf("b*"),
?line [] = Wcf("bufflig"),
@@ -157,6 +167,8 @@ do_wildcard_4(Dir, Wcf) ->
All = ["a-","aA","aB","aC","a[","a]"],
?line Files = mkfiles(lists:reverse(All), Dir),
?line All = Wcf("a[][A-C-]"),
+ ["a-"] = Wcf("a[-]"),
+ ["a["] = Wcf("a["),
?line del(Files),
do_wildcard_5(Dir, Wcf).
@@ -173,11 +185,84 @@ do_wildcard_5(Dir, Wcf) ->
?line ["blurf/nisse"] = Wcf("*/nisse"),
?line [] = Wcf("mountain/*"),
?line [] = Wcf("xa/gurka"),
+ ["blurf/nisse"] = Wcf("blurf/nisse"),
%% Cleanup
?line del(Files),
- ?line foreach(fun(D) -> ok = file:del_dir(filename:join(Dir, D)) end, Dirs).
+ ?line foreach(fun(D) -> ok = file:del_dir(filename:join(Dir, D)) end, Dirs),
+ do_wildcard_6(Dir, Wcf).
+
+do_wildcard_6(Dir, Wcf) ->
+ ok = file:make_dir(filename:join(Dir, "xbin")),
+ All = ["xbin/a.x","xbin/b.x","xbin/c.x"],
+ Files = mkfiles(All, Dir),
+ All = Wcf("xbin/*.x"),
+ All = Wcf("xbin/*"),
+ ["xbin"] = Wcf("*"),
+ All = Wcf("*/*"),
+ del(Files),
+ ok = file:del_dir(filename:join(Dir, "xbin")),
+ do_wildcard_7(Dir, Wcf).
+
+do_wildcard_7(Dir, Wcf) ->
+ Dirs = ["blurf","xa","yyy"],
+ SubDirs = ["blurf/nisse"],
+ foreach(fun(D) ->
+ ok = file:make_dir(filename:join(Dir, D))
+ end, Dirs ++ SubDirs),
+ All = ["blurf/nisse/baz","xa/arne","xa/kalle","yyy/arne"],
+ Files = mkfiles(lists:reverse(All), Dir),
+
+ %% Test.
+ Listing = Wcf("**"),
+ ["blurf","blurf/nisse","blurf/nisse/baz",
+ "xa","xa/arne","xa/kalle","yyy","yyy/arne"] = Listing,
+ Listing = Wcf("**/*"),
+ ["xa/arne","yyy/arne"] = Wcf("**/arne"),
+ ["blurf/nisse"] = Wcf("**/nisse"),
+ [] = Wcf("mountain/**"),
+
+ %% Cleanup
+ del(Files),
+ foreach(fun(D) ->
+ ok = file:del_dir(filename:join(Dir, D))
+ end, SubDirs ++ Dirs),
+ do_wildcard_8(Dir, Wcf).
+
+do_wildcard_8(Dir, Wcf) ->
+ Dirs0 = ["blurf"],
+ Dirs1 = ["blurf/nisse"],
+ Dirs2 = ["blurf/nisse/a", "blurf/nisse/b"],
+ foreach(fun(D) ->
+ ok = file:make_dir(filename:join(Dir, D))
+ end, Dirs0 ++ Dirs1 ++ Dirs2),
+ All = ["blurf/nisse/a/1.txt", "blurf/nisse/b/2.txt", "blurf/nisse/b/3.txt"],
+ Files = mkfiles(lists:reverse(All), Dir),
+ %% Test.
+ All = Wcf("**/blurf/**/*.txt"),
+
+ %% Cleanup
+ del(Files),
+ foreach(fun(D) ->
+ ok = file:del_dir(filename:join(Dir, D))
+ end, Dirs2 ++ Dirs1 ++ Dirs0),
+ do_wildcard_9(Dir, Wcf).
+
+do_wildcard_9(Dir, Wcf) ->
+ Dirs0 = ["lib","lib/app","lib/app/ebin"],
+ Dirs = [filename:join(Dir, D) || D <- Dirs0],
+ [ok = file:make_dir(D) || D <- Dirs],
+ Files0 = [filename:join("lib/app/ebin", F++".bar") ||
+ F <- ["abc","foo","foobar"]],
+ Files = [filename:join(Dir, F) || F <- Files0],
+ [ok = file:write_file(F, <<"some content\n">>) || F <- Files],
+ Files0 = Wcf("lib/app/ebin/*.bar"),
+
+ %% Cleanup.
+ del(Files),
+ [ok = file:del_dir(D) || D <- lists:reverse(Dirs)],
+ ok.
fold_files(Config) when is_list(Config) ->
diff --git a/lib/stdlib/test/filename_SUITE.erl b/lib/stdlib/test/filename_SUITE.erl
index 8817f5a55b..232df6a13f 100644
--- a/lib/stdlib/test/filename_SUITE.erl
+++ b/lib/stdlib/test/filename_SUITE.erl
@@ -112,19 +112,6 @@ absname(Config) when is_list(Config) ->
?line "/erlang/src" = filename:absname(["/erl",'a','ng',"/",'s',"rc"]),
?line "/erlang/src" = filename:absname("/erlang///src"),
?line "/file_sorter.erl" = filename:absname([file_sorter|'.erl']),
- ok;
- vxworks ->
- Test_dir = ?config(priv_dir, Config),
- Test1 = Test_dir ++ "/foo",
- Test2 = Test_dir ++ "/ebin",
- ?line ok = file:set_cwd(Test_dir),
- ?line Test1 = filename:absname(foo),
- ?line Test1= filename:absname("foo"),
- ?line Test2 = filename:absname("foo/../ebin"),
- ?line "/erlang" = filename:absname("/erlang"),
- ?line "/erlang/src" = filename:absname("/erlang/src"),
- ?line "/erlang/src" = filename:absname(["/erlan",'g/s',"rc"]),
- ?line "/erlang/src" = filename:absname("/erlang///src"),
ok
end.
@@ -179,15 +166,6 @@ absname_2(Config) when is_list(Config) ->
?line "/erlang" = filename:absname("/erlang", "/"),
?line "/erlang/src" = filename:absname("/erlang/src", "/"),
?line "/erlang/src" = filename:absname("/erlang///src", "/"),
- ok;
- vxworks ->
- ?line "/usr/foo" = filename:absname(foo, "/usr"),
- ?line "/usr/foo" = filename:absname("foo", "/usr"),
- ?line "/usr/ebin" = filename:absname("../ebin", "/usr"),
- ?line "/usr/ebin" = filename:absname("../ebin", "/usr/src"),
- ?line "/erlang" = filename:absname("/erlang", "/usr"),
- ?line "/erlang/src" = filename:absname("/erlang/src", "/usr"),
- ?line "/erlang/src" = filename:absname("/erlang///src", "/usr"),
ok
end.
@@ -213,11 +191,7 @@ basename_1(Config) when is_list(Config) ->
?line "foo" = filename:basename("A:foo");
{unix, _} ->
?line "strange\\but\\true" =
- filename:basename("strange\\but\\true");
- vxworks ->
- ?line "foo" = filename:basename(["usr\\foo\\"]),
- ?line "foo" = filename:basename("elrond:usr\\foo\\"),
- ?line "foo" = filename:basename("disk:/foo")
+ filename:basename("strange\\but\\true")
end,
?line test_server:timetrap_cancel(Dog),
ok.
@@ -249,15 +223,7 @@ basename_2(Config) when is_list(Config) ->
?line "strange\\but\\true" =
filename:basename("strange\\but\\true.erl", ".erl"),
?line "strange\\but\\true" =
- filename:basename("strange\\but\\true", ".erl");
- vxworks ->
- ?line "foo" = filename:basename("net:foo", ".erl"),
- ?line "foo.erl" = filename:basename("net:\\usr\\foo.erl",
- ".hrl"),
- ?line "foo.erl" =
- filename:basename("/disk0:\\usr.hrl\\foo.erl",
- ".hrl"),
- ?line "foo" = filename:basename("/home\\usr\\foo", ".hrl")
+ filename:basename("strange\\but\\true", ".erl")
end,
?line test_server:timetrap_cancel(Dog),
ok.
@@ -267,37 +233,25 @@ basename_2(Config) when is_list(Config) ->
dirname(Config) when is_list(Config) ->
case os:type() of
{win32,_} ->
- ?line "A:/usr" = filename:dirname("A:/usr/foo.erl"),
- ?line "A:usr" = filename:dirname("A:usr/foo.erl"),
- ?line "/usr" = filename:dirname("\\usr\\foo.erl"),
- ?line "/" = filename:dirname("\\usr"),
- ?line "A:" = filename:dirname("A:");
- vxworks ->
- ?line "net:/usr" = filename:dirname("net:/usr/foo.erl"),
- ?line "/disk0:/usr" = filename:dirname("/disk0:/usr/foo.erl"),
- ?line "/usr" = filename:dirname("\\usr\\foo.erl"),
- ?line "/usr" = filename:dirname("\\usr"),
- ?line "net:" = filename:dirname("net:");
+ "A:/usr" = filename:dirname("A:/usr/foo.erl"),
+ "A:usr" = filename:dirname("A:usr/foo.erl"),
+ "/usr" = filename:dirname("\\usr\\foo.erl"),
+ "/" = filename:dirname("\\usr"),
+ "A:" = filename:dirname("A:");
_ -> true
end,
- ?line "usr" = filename:dirname("usr///foo.erl"),
- ?line "." = filename:dirname("foo.erl"),
- ?line "." = filename:dirname("."),
- ?line "usr" = filename:dirname('usr/foo.erl'),
- ?line "usr" = filename:dirname(['usr','/foo.erl']),
- ?line "usr" = filename:dirname(['us','r/foo.erl']),
- ?line "usr" = filename:dirname(['usr/','/foo.erl']),
- ?line "usr" = filename:dirname(['usr/','foo.erl']),
- ?line "usr" = filename:dirname(['usr/'|'foo.erl']),
- ?line "usr" = filename:dirname(['usr/f','oo.erl']),
- case os:type() of
- vxworks ->
- ?line "/" = filename:dirname("/"),
- ?line "/usr" = filename:dirname("/usr");
- _ ->
- ?line "/" = filename:dirname("/"),
- ?line "/" = filename:dirname("/usr")
- end,
+ "usr" = filename:dirname("usr///foo.erl"),
+ "." = filename:dirname("foo.erl"),
+ "." = filename:dirname("."),
+ "usr" = filename:dirname('usr/foo.erl'),
+ "usr" = filename:dirname(['usr','/foo.erl']),
+ "usr" = filename:dirname(['us','r/foo.erl']),
+ "usr" = filename:dirname(['usr/','/foo.erl']),
+ "usr" = filename:dirname(['usr/','foo.erl']),
+ "usr" = filename:dirname(['usr/'|'foo.erl']),
+ "usr" = filename:dirname(['usr/f','oo.erl']),
+ "/" = filename:dirname("/"),
+ "/" = filename:dirname("/usr"),
ok.
@@ -319,12 +273,6 @@ extension(Config) when is_list(Config) ->
filename:extension("A:/usr.bar/foo.nisse.erl"),
?line "" = filename:extension("A:/usr.bar/foo"),
ok;
- vxworks ->
- ?line "" = filename:extension("/disk0:\\usr\\foo"),
- ?line ".erl" =
- filename:extension("net:/usr.bar/foo.nisse.erl"),
- ?line "" = filename:extension("net:/usr.bar/foo"),
- ok;
_ -> ok
end.
@@ -369,25 +317,6 @@ join(Config) when is_list(Config) ->
filename:join(["A:","C:usr","foo.erl"]),
?line "d:/foo" = filename:join([$D, $:, $/, []], "foo"),
ok;
- vxworks ->
- ?line "Net:" = filename:join(["Net:/"]),
- ?line "net:" = filename:join(["net:\\"]),
- ?line "net:/abc" = filename:join(["net:/", "abc"]),
- ?line "net:/abc" = filename:join(["net:", "abc"]),
- ?line "a/b/c/d/e/f/g" =
- filename:join(["a//b\\c//\\/\\d/\\e/f\\g"]),
- ?line "net:/usr/foo.erl" =
- filename:join(["net:","usr","foo.erl"]),
- ?line "/usr/foo.erl" =
- filename:join(["net:","/usr","foo.erl"]),
- ?line "/target:usr" = filename:join("net:","/target:usr"),
- ?line "kernel:/usr" = filename:join("net:", "kernel:/usr"),
- ?line "foo:/usr/foo.erl" =
- filename:join(["A:","foo:/usr","foo.erl"]),
- ?line "/disk0:usr/foo.erl" =
- filename:join(["kalle:","/disk0:usr","foo.erl"]),
- ?line "D:/foo" = filename:join([$D, $:, $/, []], "foo"),
- ok;
{unix, _} ->
ok
end.
@@ -406,10 +335,6 @@ pathtype(Config) when is_list(Config) ->
{unix, _} ->
?line absolute = filename:pathtype("/"),
?line absolute = filename:pathtype("/usr/local/bin"),
- ok;
- vxworks ->
- ?line absolute = filename:pathtype("/usr/local/bin"),
- ?line absolute = filename:pathtype("net:usr/local/bin"),
ok
end.
@@ -424,12 +349,7 @@ rootname(Config) when is_list(Config) ->
ok.
split(Config) when is_list(Config) ->
- case os:type() of
- vxworks ->
- ?line ["/usr","local","bin"] = filename:split("/usr/local/bin");
- _ ->
- ?line ["/","usr","local","bin"] = filename:split("/usr/local/bin")
- end,
+ ?line ["/","usr","local","bin"] = filename:split("/usr/local/bin"),
?line ["foo","bar"]= filename:split("foo/bar"),
?line ["foo", "bar", "hello"]= filename:split("foo////bar//hello"),
?line ["foo", "bar", "hello"]= filename:split(["foo//",'//bar//h',"ello"]),
@@ -447,18 +367,6 @@ split(Config) when is_list(Config) ->
?line ["a:","msdev","include"] =
filename:split("a:msdev\\include"),
ok;
- vxworks ->
- ?line ["net:","msdev","include"] =
- filename:split("net:/msdev/include"),
- ?line ["Target:","msdev","include"] =
- filename:split("Target:/msdev/include"),
- ?line ["msdev","include"] =
- filename:split("msdev\\include"),
- ?line ["/disk0:","msdev","include"] =
- filename:split("/disk0:\\msdev\\include"),
- ?line ["a:","msdev","include"] =
- filename:split("a:msdev\\include"),
- ok;
_ ->
ok
end.
@@ -657,56 +565,38 @@ basename_bin_2(Config) when is_list(Config) ->
dirname_bin(Config) when is_list(Config) ->
case os:type() of
{win32,_} ->
- ?line <<"A:/usr">> = filename:dirname(<<"A:/usr/foo.erl">>),
- ?line <<"A:usr">> = filename:dirname(<<"A:usr/foo.erl">>),
- ?line <<"/usr">> = filename:dirname(<<"\\usr\\foo.erl">>),
- ?line <<"/">> = filename:dirname(<<"\\usr">>),
- ?line <<"A:">> = filename:dirname(<<"A:">>);
- vxworks ->
- ?line <<"net:/usr">> = filename:dirname(<<"net:/usr/foo.erl">>),
- ?line <<"/disk0:/usr">> = filename:dirname(<<"/disk0:/usr/foo.erl">>),
- ?line <<"/usr">> = filename:dirname(<<"\\usr\\foo.erl">>),
- ?line <<"/usr">> = filename:dirname(<<"\\usr">>),
- ?line <<"net:">> = filename:dirname(<<"net:">>);
+ <<"A:/usr">> = filename:dirname(<<"A:/usr/foo.erl">>),
+ <<"A:usr">> = filename:dirname(<<"A:usr/foo.erl">>),
+ <<"/usr">> = filename:dirname(<<"\\usr\\foo.erl">>),
+ <<"/">> = filename:dirname(<<"\\usr">>),
+ <<"A:">> = filename:dirname(<<"A:">>);
_ -> true
end,
- ?line <<"usr">> = filename:dirname(<<"usr///foo.erl">>),
- ?line <<".">> = filename:dirname(<<"foo.erl">>),
- ?line <<".">> = filename:dirname(<<".">>),
- case os:type() of
- vxworks ->
- ?line <<"/">> = filename:dirname(<<"/">>),
- ?line <<"/usr">> = filename:dirname(<<"/usr">>);
- _ ->
- ?line <<"/">> = filename:dirname(<<"/">>),
- ?line <<"/">> = filename:dirname(<<"/usr">>)
- end,
+ <<"usr">> = filename:dirname(<<"usr///foo.erl">>),
+ <<".">> = filename:dirname(<<"foo.erl">>),
+ <<".">> = filename:dirname(<<".">>),
+ <<"/">> = filename:dirname(<<"/">>),
+ <<"/">> = filename:dirname(<<"/usr">>),
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
extension_bin(Config) when is_list(Config) ->
- ?line <<".erl">> = filename:extension(<<"A:/usr/foo.erl">>),
- ?line <<".erl">> = filename:extension(<<"A:/usr/foo.nisse.erl">>),
- ?line <<".erl">> = filename:extension(<<"A:/usr.bar/foo.nisse.erl">>),
- ?line <<"">> = filename:extension(<<"A:/usr.bar/foo">>),
- ?line <<"">> = filename:extension(<<"A:/usr/foo">>),
- ?line case os:type() of
- {win32, _} ->
- ?line <<"">> = filename:extension(<<"A:\\usr\\foo">>),
- ?line <<".erl">> =
- filename:extension(<<"A:/usr.bar/foo.nisse.erl">>),
- ?line <<"">> = filename:extension(<<"A:/usr.bar/foo">>),
- ok;
- vxworks ->
- ?line <<"">> = filename:extension(<<"/disk0:\\usr\\foo">>),
- ?line <<".erl">> =
- filename:extension(<<"net:/usr.bar/foo.nisse.erl">>),
- ?line <<"">> = filename:extension(<<"net:/usr.bar/foo">>),
- ok;
- _ -> ok
- end.
+ <<".erl">> = filename:extension(<<"A:/usr/foo.erl">>),
+ <<".erl">> = filename:extension(<<"A:/usr/foo.nisse.erl">>),
+ <<".erl">> = filename:extension(<<"A:/usr.bar/foo.nisse.erl">>),
+ <<"">> = filename:extension(<<"A:/usr.bar/foo">>),
+ <<"">> = filename:extension(<<"A:/usr/foo">>),
+ case os:type() of
+ {win32, _} ->
+ ?line <<"">> = filename:extension(<<"A:\\usr\\foo">>),
+ ?line <<".erl">> =
+ filename:extension(<<"A:/usr.bar/foo.nisse.erl">>),
+ ?line <<"">> = filename:extension(<<"A:/usr.bar/foo">>),
+ ok;
+ _ -> ok
+ end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -754,50 +644,45 @@ join_bin(Config) when is_list(Config) ->
end.
pathtype_bin(Config) when is_list(Config) ->
- ?line relative = filename:pathtype(<<"..">>),
- ?line relative = filename:pathtype(<<"foo">>),
- ?line relative = filename:pathtype(<<"foo/bar">>),
- ?line relative = filename:pathtype('foo/bar'),
+ relative = filename:pathtype(<<"..">>),
+ relative = filename:pathtype(<<"foo">>),
+ relative = filename:pathtype(<<"foo/bar">>),
+ relative = filename:pathtype('foo/bar'),
case os:type() of
{win32, _} ->
- ?line volumerelative = filename:pathtype(<<"/usr/local/bin">>),
- ?line volumerelative = filename:pathtype(<<"A:usr/local/bin">>),
+ volumerelative = filename:pathtype(<<"/usr/local/bin">>),
+ volumerelative = filename:pathtype(<<"A:usr/local/bin">>),
ok;
{unix, _} ->
- ?line absolute = filename:pathtype(<<"/">>),
- ?line absolute = filename:pathtype(<<"/usr/local/bin">>),
+ absolute = filename:pathtype(<<"/">>),
+ absolute = filename:pathtype(<<"/usr/local/bin">>),
ok
end.
rootname_bin(Config) when is_list(Config) ->
- ?line <<"/jam.src/kalle">> = filename:rootname(<<"/jam.src/kalle">>),
- ?line <<"/jam.src/foo">> = filename:rootname(<<"/jam.src/foo.erl">>),
- ?line <<"/jam.src/foo">> = filename:rootname(<<"/jam.src/foo.erl">>, <<".erl">>),
- ?line <<"/jam.src/foo.jam">> = filename:rootname(<<"/jam.src/foo.jam">>, <<".erl">>),
- ?line <<"/jam.src/foo.jam">> = filename:rootname(["/jam.sr",'c/foo.j',"am"],<<".erl">>),
- ?line <<"/jam.src/foo.jam">> = filename:rootname(["/jam.sr",'c/foo.j'|am],<<".erl">>),
+ <<"/jam.src/kalle">> = filename:rootname(<<"/jam.src/kalle">>),
+ <<"/jam.src/foo">> = filename:rootname(<<"/jam.src/foo.erl">>),
+ <<"/jam.src/foo">> = filename:rootname(<<"/jam.src/foo.erl">>, <<".erl">>),
+ <<"/jam.src/foo.jam">> = filename:rootname(<<"/jam.src/foo.jam">>, <<".erl">>),
+ <<"/jam.src/foo.jam">> = filename:rootname(["/jam.sr",'c/foo.j',"am"],<<".erl">>),
+ <<"/jam.src/foo.jam">> = filename:rootname(["/jam.sr",'c/foo.j'|am],<<".erl">>),
ok.
split_bin(Config) when is_list(Config) ->
- case os:type() of
- vxworks ->
- ?line [<<"/usr">>,<<"local">>,<<"bin">>] = filename:split(<<"/usr/local/bin">>);
- _ ->
- ?line [<<"/">>,<<"usr">>,<<"local">>,<<"bin">>] = filename:split(<<"/usr/local/bin">>)
- end,
- ?line [<<"foo">>,<<"bar">>]= filename:split(<<"foo/bar">>),
- ?line [<<"foo">>, <<"bar">>, <<"hello">>]= filename:split(<<"foo////bar//hello">>),
+ [<<"/">>,<<"usr">>,<<"local">>,<<"bin">>] = filename:split(<<"/usr/local/bin">>),
+ [<<"foo">>,<<"bar">>]= filename:split(<<"foo/bar">>),
+ [<<"foo">>, <<"bar">>, <<"hello">>]= filename:split(<<"foo////bar//hello">>),
case os:type() of
{win32,_} ->
- ?line [<<"a:/">>,<<"msdev">>,<<"include">>] =
+ [<<"a:/">>,<<"msdev">>,<<"include">>] =
filename:split(<<"a:/msdev/include">>),
- ?line [<<"a:/">>,<<"msdev">>,<<"include">>] =
+ [<<"a:/">>,<<"msdev">>,<<"include">>] =
filename:split(<<"A:/msdev/include">>),
- ?line [<<"msdev">>,<<"include">>] =
+ [<<"msdev">>,<<"include">>] =
filename:split(<<"msdev\\include">>),
- ?line [<<"a:/">>,<<"msdev">>,<<"include">>] =
+ [<<"a:/">>,<<"msdev">>,<<"include">>] =
filename:split(<<"a:\\msdev\\include">>),
- ?line [<<"a:">>,<<"msdev">>,<<"include">>] =
+ [<<"a:">>,<<"msdev">>,<<"include">>] =
filename:split(<<"a:msdev\\include">>),
ok;
_ ->
@@ -814,4 +699,3 @@ t_nativename_bin(Config) when is_list(Config) ->
?line <<"/usr/tmp/arne">> =
filename:nativename(<<"/usr/tmp//arne/">>)
end.
-
diff --git a/lib/stdlib/test/gen_event_SUITE.erl b/lib/stdlib/test/gen_event_SUITE.erl
index 5c51e12e35..5819ef3890 100644
--- a/lib/stdlib/test/gen_event_SUITE.erl
+++ b/lib/stdlib/test/gen_event_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. 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
@@ -26,13 +26,14 @@
delete_handler/1, swap_handler/1, swap_sup_handler/1,
notify/1, sync_notify/1, call/1, info/1, hibernate/1,
call_format_status/1, call_format_status_anon/1,
- error_format_status/1]).
+ error_format_status/1, get_state/1, replace_state/1]).
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[start, {group, test_all}, hibernate,
- call_format_status, call_format_status_anon, error_format_status].
+ call_format_status, call_format_status_anon, error_format_status,
+ get_state, replace_state].
groups() ->
[{test_all, [],
@@ -956,3 +957,45 @@ error_format_status(Config) when is_list(Config) ->
?line ok = gen_event:stop(Pid),
process_flag(trap_exit, OldFl),
ok.
+
+get_state(suite) ->
+ [];
+get_state(doc) ->
+ ["Test that sys:get_state/1,2 return the gen_event state"];
+get_state(Config) when is_list(Config) ->
+ {ok, Pid} = gen_event:start({local, my_dummy_handler}),
+ State1 = self(),
+ ok = gen_event:add_handler(my_dummy_handler, dummy1_h, [State1]),
+ [{dummy1_h,false,State1}] = sys:get_state(Pid),
+ [{dummy1_h,false,State1}] = sys:get_state(Pid, 5000),
+ State2 = {?MODULE, self()},
+ ok = gen_event:add_handler(my_dummy_handler, {dummy1_h,id}, [State2]),
+ Result1 = sys:get_state(Pid),
+ [{dummy1_h,false,State1},{dummy1_h,id,State2}] = lists:sort(Result1),
+ Result2 = sys:get_state(Pid, 5000),
+ [{dummy1_h,false,State1},{dummy1_h,id,State2}] = lists:sort(Result2),
+ ok = gen_event:stop(Pid),
+ ok.
+
+replace_state(suite) ->
+ [];
+replace_state(doc) ->
+ ["Test that replace_state/2,3 replace the gen_event state"];
+replace_state(Config) when is_list(Config) ->
+ {ok, Pid} = gen_event:start({local, my_dummy_handler}),
+ State1 = self(),
+ ok = gen_event:add_handler(my_dummy_handler, dummy1_h, [State1]),
+ [{dummy1_h,false,State1}] = sys:get_state(Pid),
+ NState1 = "replaced",
+ Replace1 = fun({dummy1_h,false,_}=S) -> setelement(3,S,NState1) end,
+ [{dummy1_h,false,NState1}] = sys:replace_state(Pid, Replace1),
+ [{dummy1_h,false,NState1}] = sys:get_state(Pid),
+ NState2 = "replaced again",
+ Replace2 = fun({dummy1_h,false,_}=S) -> setelement(3,S,NState2) end,
+ [{dummy1_h,false,NState2}] = sys:replace_state(Pid, Replace2, 5000),
+ [{dummy1_h,false,NState2}] = sys:get_state(Pid),
+ %% verify no change in state if replace function crashes
+ Replace3 = fun(_) -> exit(fail) end,
+ [{dummy1_h,false,NState2}] = sys:replace_state(Pid, Replace3),
+ [{dummy1_h,false,NState2}] = sys:get_state(Pid),
+ ok.
diff --git a/lib/stdlib/test/gen_fsm_SUITE.erl b/lib/stdlib/test/gen_fsm_SUITE.erl
index bdb4ea65b5..fd15838b7d 100644
--- a/lib/stdlib/test/gen_fsm_SUITE.erl
+++ b/lib/stdlib/test/gen_fsm_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. 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
@@ -31,7 +31,7 @@
-export([shutdown/1]).
--export([ sys1/1, call_format_status/1, error_format_status/1]).
+-export([ sys1/1, call_format_status/1, error_format_status/1, get_state/1, replace_state/1]).
-export([hibernate/1,hiber_idle/3,hiber_wakeup/3,hiber_idle/2,hiber_wakeup/2]).
@@ -66,7 +66,7 @@ groups() ->
start8, start9, start10, start11, start12]},
{abnormal, [], [abnormal1, abnormal2]},
{sys, [],
- [sys1, call_format_status, error_format_status]}].
+ [sys1, call_format_status, error_format_status, get_state, replace_state]}].
init_per_suite(Config) ->
Config.
@@ -281,21 +281,12 @@ start12(Config) when is_list(Config) ->
%% Check that time outs in calls work
abnormal1(suite) -> [];
abnormal1(Config) when is_list(Config) ->
- ?line {ok, _Pid} =
- gen_fsm:start({local, my_fsm}, gen_fsm_SUITE, [], []),
+ {ok, _Pid} = gen_fsm:start({local, my_fsm}, gen_fsm_SUITE, [], []),
%% timeout call.
- case os:type() of
- vxworks ->
- %% timeout call for VxWorks must be in 16ms increments.
- ?line delayed = gen_fsm:sync_send_event(my_fsm, {delayed_answer,1}, 17),
- ?line {'EXIT',{timeout,_}} =
- (catch gen_fsm:sync_send_event(my_fsm, {delayed_answer,17}, 1));
- _ ->
- ?line delayed = gen_fsm:sync_send_event(my_fsm, {delayed_answer,1}, 100),
- ?line {'EXIT',{timeout,_}} =
- (catch gen_fsm:sync_send_event(my_fsm, {delayed_answer,10}, 1))
- end,
+ delayed = gen_fsm:sync_send_event(my_fsm, {delayed_answer,1}, 100),
+ {'EXIT',{timeout,_}} =
+ (catch gen_fsm:sync_send_event(my_fsm, {delayed_answer,10}, 1)),
test_server:messages_get(),
ok.
@@ -422,6 +413,40 @@ error_format_status(Config) when is_list(Config) ->
process_flag(trap_exit, OldFl),
ok.
+get_state(Config) when is_list(Config) ->
+ State = self(),
+ {ok, Pid} = gen_fsm:start(?MODULE, {state_data, State}, []),
+ {idle, State} = sys:get_state(Pid),
+ {idle, State} = sys:get_state(Pid, 5000),
+ stop_it(Pid),
+
+ %% check that get_state can handle a name being an atom (pid is
+ %% already checked by the previous test)
+ {ok, Pid2} = gen_fsm:start({local, gfsm}, gen_fsm_SUITE, {state_data, State}, []),
+ {idle, State} = sys:get_state(gfsm),
+ {idle, State} = sys:get_state(gfsm, 5000),
+ stop_it(Pid2),
+ ok.
+
+replace_state(Config) when is_list(Config) ->
+ State = self(),
+ {ok, Pid} = gen_fsm:start(?MODULE, {state_data, State}, []),
+ {idle, State} = sys:get_state(Pid),
+ NState1 = "replaced",
+ Replace1 = fun({StateName, _}) -> {StateName, NState1} end,
+ {idle, NState1} = sys:replace_state(Pid, Replace1),
+ {idle, NState1} = sys:get_state(Pid),
+ NState2 = "replaced again",
+ Replace2 = fun({idle, _}) -> {state0, NState2} end,
+ {state0, NState2} = sys:replace_state(Pid, Replace2, 5000),
+ {state0, NState2} = sys:get_state(Pid),
+ %% verify no change in state if replace function crashes
+ Replace3 = fun(_) -> error(fail) end,
+ {state0, NState2} = sys:replace_state(Pid, Replace3),
+ {state0, NState2} = sys:get_state(Pid),
+ stop_it(Pid),
+ ok.
+
%% Hibernation
hibernate(suite) -> [];
hibernate(Config) when is_list(Config) ->
diff --git a/lib/stdlib/test/gen_server_SUITE.erl b/lib/stdlib/test/gen_server_SUITE.erl
index c930d90e1c..a360a0809b 100644
--- a/lib/stdlib/test/gen_server_SUITE.erl
+++ b/lib/stdlib/test/gen_server_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. 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
@@ -32,7 +32,7 @@
spec_init_local_registered_parent/1,
spec_init_global_registered_parent/1,
otp_5854/1, hibernate/1, otp_7669/1, call_format_status/1,
- error_format_status/1, call_with_huge_message_queue/1
+ error_format_status/1, get_state/1, replace_state/1, call_with_huge_message_queue/1
]).
% spawn export
@@ -57,6 +57,7 @@ all() ->
spec_init_local_registered_parent,
spec_init_global_registered_parent, otp_5854, hibernate,
otp_7669, call_format_status, error_format_status,
+ get_state, replace_state,
call_with_huge_message_queue].
groups() ->
@@ -231,14 +232,6 @@ start(Config) when is_list(Config) ->
end,
test_server:messages_get(),
- %% Must wait for all error messages before going to next test.
- %% (otherwise it interferes too much with real time characteristics).
- case os:type() of
- vxworks ->
- receive after 5000 -> ok end;
- _ ->
- ok
- end,
process_flag(trap_exit, OldFl),
ok.
@@ -1041,21 +1034,77 @@ error_format_status(Config) when is_list(Config) ->
process_flag(trap_exit, OldFl),
ok.
+%% Verify that sys:get_state correctly returns gen_server state
+%%
+get_state(suite) ->
+ [];
+get_state(doc) ->
+ ["Test that sys:get_state/1,2 return the gen_server state"];
+get_state(Config) when is_list(Config) ->
+ State = self(),
+ {ok, _Pid} = gen_server:start_link({local, get_state},
+ ?MODULE, {state,State}, []),
+ State = sys:get_state(get_state),
+ State = sys:get_state(get_state, 5000),
+ {ok, Pid} = gen_server:start_link(?MODULE, {state,State}, []),
+ State = sys:get_state(Pid),
+ State = sys:get_state(Pid, 5000),
+ ok.
+
+%% Verify that sys:replace_state correctly replaces gen_server state
+%%
+replace_state(suite) ->
+ [];
+replace_state(doc) ->
+ ["Test that sys:replace_state/1,2 replace the gen_server state"];
+replace_state(Config) when is_list(Config) ->
+ State = self(),
+ {ok, _Pid} = gen_server:start_link({local, replace_state},
+ ?MODULE, {state,State}, []),
+ State = sys:get_state(replace_state),
+ NState1 = "replaced",
+ Replace1 = fun(_) -> NState1 end,
+ NState1 = sys:replace_state(replace_state, Replace1),
+ NState1 = sys:get_state(replace_state),
+ {ok, Pid} = gen_server:start_link(?MODULE, {state,NState1}, []),
+ NState1 = sys:get_state(Pid),
+ Suffix = " again",
+ NState2 = NState1 ++ Suffix,
+ Replace2 = fun(S) -> S ++ Suffix end,
+ NState2 = sys:replace_state(Pid, Replace2, 5000),
+ NState2 = sys:get_state(Pid, 5000),
+ %% verify no change in state if replace function crashes
+ Replace3 = fun(_) -> throw(fail) end,
+ NState2 = sys:replace_state(Pid, Replace3),
+ NState2 = sys:get_state(Pid, 5000),
+ ok.
+
%% Test that the time for a huge message queue is not
%% significantly slower than with an empty message queue.
call_with_huge_message_queue(Config) when is_list(Config) ->
+ case test_server:is_native(gen) of
+ true ->
+ {skip,
+ "gen is native - huge message queue optimization "
+ "is not implemented"};
+ false ->
+ do_call_with_huge_message_queue()
+ end.
+
+do_call_with_huge_message_queue() ->
?line Pid = spawn_link(fun echo_loop/0),
- ?line {Time,ok} = tc(fun() -> calls(10, Pid) end),
+ ?line {Time,ok} = tc(fun() -> calls(10000, Pid) end),
?line [self() ! {msg,N} || N <- lists:seq(1, 500000)],
erlang:garbage_collect(),
- ?line {NewTime,ok} = tc(fun() -> calls(10, Pid) end),
+ ?line {NewTime,ok} = tc(fun() -> calls(10000, Pid) end),
io:format("Time for empty message queue: ~p", [Time]),
io:format("Time for huge message queue: ~p", [NewTime]),
+ IsCover = test_server:is_cover(),
case (NewTime+1) / (Time+1) of
- Q when Q < 10 ->
+ Q when Q < 10; IsCover ->
ok;
Q ->
io:format("Q = ~p", [Q]),
diff --git a/lib/stdlib/test/id_transform_SUITE.erl b/lib/stdlib/test/id_transform_SUITE.erl
index e1972a100e..ee97ffe7b3 100644
--- a/lib/stdlib/test/id_transform_SUITE.erl
+++ b/lib/stdlib/test/id_transform_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2003-2012. 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
@@ -26,7 +26,7 @@
id_transform/1]).
-export([check/2,check2/1,g/0,f/1,t/1,t1/1,t2/1,t3/1,t4/1,
- t5/1,t6/1,apa/1,new_fun/0]).
+ t5/1,apa/1,new_fun/0]).
% Serves as test...
-hej(hopp).
@@ -61,7 +61,7 @@ id_transform(Config) when is_list(Config) ->
?line {module,erl_id_trans}=code:load_binary(erl_id_trans,File,Bin),
?line case test_server:purify_is_running() of
false ->
- Dog = ?t:timetrap(?t:hours(1)),
+ Dog = ct:timetrap(?t:hours(1)),
?line Res = run_in_test_suite(),
?t:timetrap_cancel(Dog),
Res;
@@ -388,8 +388,6 @@ t3(A) when is_tuple(A) or is_tuple(A) ->
is_tuple;
t3(A) when record(A, apa) ->
foo;
-t3(A) when {erlang,is_record}(A, apa) ->
- foo;
t3(A) when erlang:is_record(A, apa) ->
foo;
t3(A) when is_record(A, apa) ->
@@ -397,13 +395,10 @@ t3(A) when is_record(A, apa) ->
t3(A) when record({apa}, apa) ->
{A,foo}.
-t4(_) when {erlang,is_record}({apa}, apa) ->
- foo.
-
-t5(A) when erlang:is_record({apa}, apa) ->
+t4(A) when erlang:is_record({apa}, apa) ->
{A,foo}.
-t6(A) when is_record({apa}, apa) ->
+t5(A) when is_record({apa}, apa) ->
{A,foo}.
-record(apa2,{a=a,b=foo:bar()}).
diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl
index bb02a879c2..9f828c6d2d 100644
--- a/lib/stdlib/test/io_SUITE.erl
+++ b/lib/stdlib/test/io_SUITE.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1999-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2013. 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
@@ -27,7 +28,12 @@
otp_6282/1, otp_6354/1, otp_6495/1, otp_6517/1, otp_6502/1,
manpage/1, otp_6708/1, otp_7084/1, otp_7421/1,
io_lib_collect_line_3_wb/1, cr_whitespace_in_string/1,
- io_fread_newlines/1, otp_8989/1, io_lib_fread_literal/1]).
+ io_fread_newlines/1, otp_8989/1, io_lib_fread_literal/1,
+ printable_range/1,
+ io_lib_print_binary_depth_one/1, otp_10302/1, otp_10755/1,
+ otp_10836/1]).
+
+-export([pretty/2]).
%-define(debug, true).
@@ -62,7 +68,9 @@ all() ->
otp_6282, otp_6354, otp_6495, otp_6517, otp_6502,
manpage, otp_6708, otp_7084, otp_7421,
io_lib_collect_line_3_wb, cr_whitespace_in_string,
- io_fread_newlines, otp_8989, io_lib_fread_literal].
+ io_fread_newlines, otp_8989, io_lib_fread_literal,
+ printable_range,
+ io_lib_print_binary_depth_one, otp_10302, otp_10755, otp_10836].
groups() ->
[].
@@ -892,7 +900,7 @@ otp_6354(Config) when is_list(Config) ->
?line "\"\\b\\t\\n\\v\\f\\r\\e\250\"" =
p([8,9,10,11,12,13,27,168], 1, 40, -1),
% ?line "\"\\b\\t\\n\"\n \"\\v\\f\\r\"\n \"\\e\250\"" =
- ?line "\"\\b\\t\\n\\v\\f\\r\\e�\"" =
+ ?line "\"\\b\\t\\n\\v\\f\\r\\e¨\"" =
p([8,9,10,11,12,13,27,168], 1, 10, -1),
?line "\"\\b\\t\\n\\v\\f\\r\\e\250\"" =
p([8,9,10,11,12,13,27,168], 1, 40, 100),
@@ -2021,3 +2029,188 @@ io_lib_fread_literal(Suite) when is_list(Suite) ->
?line {done,{error,{fread,input}},_} = io_lib:fread(C2, eof, " d"),
?line {done,{ok,[]},[]} = io_lib:fread(C2, "d\n", " d"),
ok.
+
+
+printable_range(doc) ->
+ "Check that the printable range set by the user actually works";
+printable_range(Suite) when is_list(Suite) ->
+ Pa = filename:dirname(code:which(?MODULE)),
+ {ok, UNode} = test_server:start_node(printable_range_unicode, slave,
+ [{args, " +pc unicode -pa " ++ Pa}]),
+ {ok, LNode} = test_server:start_node(printable_range_latin1, slave,
+ [{args, " +pc latin1 -pa " ++ Pa}]),
+ {ok, DNode} = test_server:start_node(printable_range_default, slave,
+ [{args, " -pa " ++ Pa}]),
+ unicode = rpc:call(UNode,io,printable_range,[]),
+ latin1 = rpc:call(LNode,io,printable_range,[]),
+ latin1 = rpc:call(DNode,io,printable_range,[]),
+ test_server:stop_node(UNode),
+ test_server:stop_node(LNode),
+ {ok, UNode} = test_server:start_node(printable_range_unicode, slave,
+ [{args, " +pcunicode -pa " ++ Pa}]),
+ {ok, LNode} = test_server:start_node(printable_range_latin1, slave,
+ [{args, " +pclatin1 -pa " ++ Pa}]),
+ unicode = rpc:call(UNode,io,printable_range,[]),
+ latin1 = rpc:call(LNode,io,printable_range,[]),
+ {error, _} = test_server:start_node(printable_range_unnicode, slave,
+ [{args, " +pcunnicode -pa " ++ Pa}]),
+ PrettyOptions = [{column,1},
+ {line_length,109},
+ {depth,30},
+ {max_chars,60},
+ {record_print_fun,
+ fun(_,_) -> no end},
+ {encoding,unicode}],
+ 1025 = lists:max(lists:flatten(rpc:call(UNode,io_lib_pretty,print,
+ [{hello, [1024,1025]},
+ PrettyOptions]))),
+ 125 = lists:max(lists:flatten(rpc:call(LNode,io_lib_pretty,print,
+ [{hello, [1024,1025]},
+ PrettyOptions]))),
+ 125 = lists:max(lists:flatten(rpc:call(DNode,io_lib_pretty,print,
+ [{hello, [1024,1025]},
+ PrettyOptions]))),
+ 1025 = lists:max(lists:flatten(rpc:call(UNode,io_lib_pretty,print,
+ [{hello, <<1024/utf8,1025/utf8>>},
+ PrettyOptions]))),
+ 125 = lists:max(lists:flatten(rpc:call(LNode,io_lib_pretty,print,
+ [{hello, <<1024/utf8,1025/utf8>>},
+ PrettyOptions]))),
+ 125 = lists:max(lists:flatten(rpc:call(DNode,io_lib_pretty,print,
+ [{hello, <<1024/utf8,1025/utf8>>},
+ PrettyOptions]))),
+
+ 1025 = lists:max(lists:flatten(rpc:call(UNode,io_lib,format,
+ ["~tp",[{hello, [1024,1025]}]]))),
+ 125 = lists:max(lists:flatten(rpc:call(LNode,io_lib,format,
+ ["~tp",[{hello, [1024,1025]}]]))),
+ 125 = lists:max(lists:flatten(rpc:call(DNode,io_lib,format,
+ ["~tp",[{hello, [1024,1025]}]]))),
+ 1025 = lists:max(lists:flatten(rpc:call(UNode,io_lib,format,
+ ["~tp",
+ [{hello,
+ <<1024/utf8,1025/utf8>>}]]))),
+ 125 = lists:max(lists:flatten(rpc:call(LNode,io_lib,format,
+ ["~tp",
+ [{hello,
+ <<1024/utf8,1025/utf8>>}]]))),
+ 125 = lists:max(lists:flatten(rpc:call(DNode,io_lib,format,
+ ["~tp",
+ [{hello,
+ <<1024/utf8,1025/utf8>>}]]))),
+ test_server:stop_node(UNode),
+ test_server:stop_node(LNode),
+ test_server:stop_node(DNode),
+ ok.
+
+io_lib_print_binary_depth_one(doc) ->
+ "Test binaries printed with a depth of one behave correctly";
+io_lib_print_binary_depth_one(Suite) when is_list(Suite) ->
+ ?line "<<>>" = fmt("~W", [<<>>, 1]),
+ ?line "<<>>" = fmt("~P", [<<>>, 1]),
+ ?line "<<...>>" = fmt("~W", [<<1>>, 1]),
+ ?line "<<...>>" = fmt("~P", [<<1>>, 1]),
+ ?line "<<...>>" = fmt("~W", [<<1:7>>, 1]),
+ ?line "<<...>>" = fmt("~P", [<<1:7>>, 1]),
+ ok.
+
+otp_10302(doc) ->
+ "OTP-10302. Unicode";
+otp_10302(Suite) when is_list(Suite) ->
+ Pa = filename:dirname(code:which(?MODULE)),
+ {ok, UNode} = test_server:start_node(printable_range_unicode, slave,
+ [{args, " +pc unicode -pa " ++ Pa}]),
+ {ok, LNode} = test_server:start_node(printable_range_latin1, slave,
+ [{args, " +pc latin1 -pa " ++ Pa}]),
+ "\"\x{400}\"" = rpc:call(UNode,?MODULE,pretty,["\x{400}", -1]),
+ "<<\"\x{400}\"/utf8>>" = rpc:call(UNode,?MODULE,pretty,
+ [<<"\x{400}"/utf8>>, -1]),
+
+ "<<\"\x{400}foo\"/utf8>>" = rpc:call(UNode,?MODULE,pretty,
+ [<<"\x{400}foo"/utf8>>, 2]),
+ "[1024]" = rpc:call(LNode,?MODULE,pretty,["\x{400}", -1]),
+ "<<208,128>>" = rpc:call(LNode,?MODULE,pretty,[<<"\x{400}"/utf8>>, -1]),
+
+ "<<208,...>>" = rpc:call(LNode,?MODULE,pretty,[<<"\x{400}foo"/utf8>>, 2]),
+ test_server:stop_node(UNode),
+ test_server:stop_node(LNode),
+
+ "<<\"äppl\"/utf8>>" = pretty(<<"äppl"/utf8>>, 2),
+ "<<\"äppl\"/utf8...>>" = pretty(<<"äpple"/utf8>>, 2),
+ "<<\"apel\">>" = pretty(<<"apel">>, 2),
+ "<<\"apel\"...>>" = pretty(<<"apelsin">>, 2),
+ "<<\"äppl\">>" = fmt("~tp", [<<"äppl">>]),
+ "<<\"äppl\"...>>" = fmt("~tP", [<<"äpple">>, 2]),
+ "<<0,0,0,0,0,0,1,0>>" = fmt("~p", [<<256:64/unsigned-integer>>]),
+ "<<0,0,0,0,0,0,1,0>>" = fmt("~tp", [<<256:64/unsigned-integer>>]),
+
+ Chars = lists:seq(0, 512), % just a few...
+ [] = [C || C <- Chars, S <- io_lib:write_char_as_latin1(C),
+ not is_latin1(S)],
+ L1 = [S || C <- Chars, S <- io_lib:write_char(C),
+ not is_latin1(S)],
+ L1 = lists:seq(256, 512),
+
+ [] = [C || C <- Chars, S <- io_lib:write_string_as_latin1([C]),
+ not is_latin1(S)],
+ L2 = [S || C <- Chars, S <- io_lib:write_string([C]),
+ not is_latin1(S)],
+ L2 = lists:seq(256, 512),
+
+ ok.
+
+pretty(Term, Depth) when is_integer(Depth) ->
+ Opts = [{column, 1}, {line_length, 20},
+ {depth, Depth}, {max_chars, 60},
+ {encoding, unicode}],
+ pretty(Term, Opts);
+pretty(Term, Opts) when is_list(Opts) ->
+ R = io_lib_pretty:print(Term, Opts),
+ lists:flatten(io_lib:format("~ts", [R])).
+
+is_latin1(S) ->
+ S >= 0 andalso S =< 255.
+
+otp_10836(doc) ->
+ "OTP-10836. ~ts extended to latin1";
+otp_10836(Suite) when is_list(Suite) ->
+ S = io_lib:format("~ts", [[<<"äpple"/utf8>>, <<"äpple">>]]),
+ "äppleäpple" = lists:flatten(S),
+ ok.
+
+otp_10755(doc) ->
+ "OTP-10755. The 'l' modifier";
+otp_10755(Suite) when is_list(Suite) ->
+ S = "string",
+ "\"string\"" = fmt("~p", [S]),
+ "[115,116,114,105,110,103]" = fmt("~lp", [S]),
+ "\"string\"" = fmt("~P", [S, 2]),
+ "[115|...]" = fmt("~lP", [S, 2]),
+ {'EXIT',{badarg,_}} = (catch fmt("~ltp", [S])),
+ {'EXIT',{badarg,_}} = (catch fmt("~tlp", [S])),
+ {'EXIT',{badarg,_}} = (catch fmt("~ltP", [S])),
+ {'EXIT',{badarg,_}} = (catch fmt("~tlP", [S])),
+ Text =
+ "-module(l_mod).\n"
+ "-export([t/0]).\n"
+ "t() ->\n"
+ " S = \"string\",\n"
+ " io:format(\"~ltp\", [S]),\n"
+ " io:format(\"~tlp\", [S]),\n"
+ " io:format(\"~ltP\", [S, 1]),\n"
+ " io:format(\"~tlP\", [S, 1]).\n",
+ {ok,l_mod,[{_File,Ws}]} = compile_file("l_mod.erl", Text, Suite),
+ ["format string invalid (invalid control ~lt)",
+ "format string invalid (invalid control ~tl)",
+ "format string invalid (invalid control ~lt)",
+ "format string invalid (invalid control ~tl)"] =
+ [lists:flatten(M:format_error(E)) || {_L,M,E} <- Ws],
+ ok.
+
+compile_file(File, Text, Config) ->
+ PrivDir = ?privdir(Config),
+ Fname = filename:join(PrivDir, File),
+ ok = file:write_file(Fname, Text),
+ try compile:file(Fname, [return])
+ after ok %file:delete(Fname)
+ end.
diff --git a/lib/stdlib/test/io_proto_SUITE.erl b/lib/stdlib/test/io_proto_SUITE.erl
index 17e69f7c1c..76a8109a8d 100644
--- a/lib/stdlib/test/io_proto_SUITE.erl
+++ b/lib/stdlib/test/io_proto_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. 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
@@ -147,8 +147,7 @@ unicode_prompt(Config) when is_list(Config) ->
%% And one with oldshell
?line rtnode([{putline,""},
{putline, "2."},
- {getline_re, ".*2."},
- {getline, "2"},
+ {getline_re, ".*2$"},
{putline, "shell:prompt_func({io_proto_SUITE,uprompt})."},
{getline_re, ".*default"},
{putline, "io:get_line('')."},
@@ -263,8 +262,7 @@ setopts_getopts(Config) when is_list(Config) ->
%% And one with oldshell
?line rtnode([{putline,""},
{putline, "2."},
- {getline_re, ".*2."},
- {getline, "2"},
+ {getline_re, ".*2$"},
{putline, "lists:keyfind(binary,1,io:getopts())."},
{getline_re, ".*{binary,false}"},
{putline, "io:get_line('')."},
@@ -467,8 +465,7 @@ unicode_options(Config) when is_list(Config) ->
end,
?line rtnode([{putline,""},
{putline, "2."},
- {getline_re, ".*2."},
- {getline, "2"},
+ {getline_re, ".*2$"},
{putline, "lists:keyfind(encoding,1,io:getopts())."},
{getline_re, ".*{encoding,latin1}"},
{putline, "io:format(\"~ts~n\",[[1024]])."},
@@ -701,8 +698,7 @@ binary_options(Config) when is_list(Config) ->
old ->
ok;
new ->
- ?line rtnode([{putline,""},
- {putline, "2."},
+ ?line rtnode([{putline, "2."},
{getline, "2"},
{putline, "lists:keyfind(binary,1,io:getopts())."},
{getline, "{binary,false}"},
@@ -716,14 +712,12 @@ binary_options(Config) when is_list(Config) ->
{getline, "<<\"hej\\n\">>"},
{putline, "io:get_line('')."},
{putline, binary_to_list(<<"\345\344\366"/utf8>>)},
- {getline, "<<\""++binary_to_list(unicode:characters_to_binary(<<"\345\344\366"/utf8>>,latin1,utf8))++"\\n\">>"}
+ {getline, "<<\""++binary_to_list(<<"\345\344\366"/utf8>>)++"\\n\"/utf8>>"}
],[])
end,
%% And one with oldshell
- ?line rtnode([{putline,""},
- {putline, "2."},
- {getline_re, ".*2."},
- {getline, "2"},
+ ?line rtnode([{putline, "2."},
+ {getline_re, ".*2$"},
{putline, "lists:keyfind(binary,1,io:getopts())."},
{getline_re, ".*{binary,false}"},
{putline, "io:get_line('')."},
@@ -736,7 +730,7 @@ binary_options(Config) when is_list(Config) ->
{getline_re, ".*<<\"hej\\\\n\">>"},
{putline, "io:get_line('')."},
{putline, binary_to_list(<<"\345\344\366"/utf8>>)},
- {getline_re, ".*<<\""++binary_to_list(unicode:characters_to_binary(<<"\345\344\366"/utf8>>,latin1,utf8))++"\\\\n\">>"}
+ {getline_re, ".*<<\""++binary_to_list(<<"\345\344\366"/utf8>>)++"\\\\n\"/utf8>>"}
],[],[],"-oldshell"),
ok.
@@ -935,8 +929,8 @@ bc_with_r12_gl_1(_Config,Machine) ->
TestDataLine1BinUtf = unicode:characters_to_binary(TestDataLine1),
TestDataLine1BinLatin = list_to_binary(TestDataLine1),
- N2List = create_nodename(),
- MyNodeList = atom_to_list(node()),
+ {ok,N2List} = create_nodename(),
+ MyNodeList = atom2list(node()),
register(io_proto_suite,self()),
AM1 = spawn(?MODULE,Machine,
[MyNodeList, "io_proto_suite", N2List]),
@@ -1182,8 +1176,8 @@ read_modes_gl_1(_Config,Machine) ->
TestDataLine1BinUtf = unicode:characters_to_binary(TestDataLine1),
TestDataLine1BinLatin = list_to_binary(TestDataLine1),
- N2List = create_nodename(),
- MyNodeList = atom_to_list(node()),
+ {ok,N2List} = create_nodename(),
+ MyNodeList = atom2list(node()),
register(io_proto_suite,self()),
AM1 = spawn(?MODULE,Machine,
[MyNodeList, "io_proto_suite", N2List]),
@@ -1609,7 +1603,7 @@ create_nodename(X) ->
case file:read_file_info(filename:join(["/tmp",NN])) of
{error,enoent} ->
Host = lists:nth(2,string:tokens(atom_to_list(node()),"@")),
- NN++"@"++Host;
+ {ok,NN++"@"++Host};
_ ->
create_nodename(X+1)
end.
@@ -1784,8 +1778,8 @@ get_default_shell() ->
{putline, "whereis(user_drv)."},
{getline, "undefined"}],[]),
old
- catch E:R ->
- ?dbg({E,R}),
+ catch _E:_R ->
+ ?dbg({_E,_R}),
new
end.
@@ -1925,6 +1919,9 @@ from(H, [H | T]) -> T;
from(H, [_ | T]) -> from(H, T);
from(_, []) -> [].
+atom2list(A) ->
+ lists:flatten(io_lib:format("~w", [A])).
+
chomp([]) ->
[];
chomp([$\n]) ->
diff --git a/lib/stdlib/test/lists_SUITE.erl b/lib/stdlib/test/lists_SUITE.erl
index b56f0b39d8..92253ef5b9 100644
--- a/lib/stdlib/test/lists_SUITE.erl
+++ b/lib/stdlib/test/lists_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2013. 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
@@ -2532,8 +2532,8 @@ otp_5939(Config) when is_list(Config) ->
?line [] = lists:filter(Pred, []),
?line {'EXIT', _} = (catch lists:partition(func, [])),
?line {[],[]} = lists:partition(Pred, []),
- ?line {'EXIT', _} = (catch lists:zf(func, [])),
- ?line [] = lists:zf(Fun1, []),
+ ?line {'EXIT', _} = (catch lists:filtermap(func, [])),
+ ?line [] = lists:filtermap(Fun1, []),
?line {'EXIT', _} = (catch lists:foreach(func, [])),
?line ok = lists:foreach(Fun1, []),
?line {'EXIT', _} = (catch lists:mapfoldl(func, [], [])),
diff --git a/lib/stdlib/test/proc_lib_SUITE.erl b/lib/stdlib/test/proc_lib_SUITE.erl
index c95089117c..8dca69bac4 100644
--- a/lib/stdlib/test/proc_lib_SUITE.erl
+++ b/lib/stdlib/test/proc_lib_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. 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
@@ -28,7 +28,7 @@
crash/1, sync_start_nolink/1, sync_start_link/1,
spawn_opt/1, sp1/0, sp2/0, sp3/1, sp4/2, sp5/1,
hibernate/1]).
--export([ otp_6345/1]).
+-export([ otp_6345/1, init_dont_hang/1]).
-export([hib_loop/1, awaken/1]).
@@ -36,7 +36,7 @@
handle_event/2, handle_call/2, handle_info/2,
terminate/2]).
--export([otp_6345_init/1]).
+-export([otp_6345_init/1, init_dont_hang_init/1]).
-ifdef(STANDALONE).
@@ -52,7 +52,7 @@ all() ->
{group, tickets}].
groups() ->
- [{tickets, [], [otp_6345]},
+ [{tickets, [], [otp_6345, init_dont_hang]},
{sync_start, [], [sync_start_nolink, sync_start_link]}].
init_per_suite(Config) ->
@@ -343,6 +343,29 @@ otp_6345_loop() ->
otp_6345_loop()
end.
+%% OTP-9803
+init_dont_hang(suite) ->
+ [];
+init_dont_hang(doc) ->
+ ["Check that proc_lib:start don't hang if spawned process crashes before proc_lib:init_ack/2"];
+init_dont_hang(Config) when is_list(Config) ->
+ %% Start should behave as start_link
+ process_flag(trap_exit, true),
+ StartLinkRes = proc_lib:start_link(?MODULE, init_dont_hang_init, [self()]),
+ try
+ StartLinkRes = proc_lib:start(?MODULE, init_dont_hang_init, [self()], 1000),
+ StartLinkRes = proc_lib:start(?MODULE, init_dont_hang_init, [self()], 1000, []),
+ ok
+ catch _:Error ->
+ io:format("Error ~p /= ~p ~n",[erlang:get_stacktrace(), StartLinkRes]),
+ exit(Error)
+ end.
+
+init_dont_hang_init(Parent) ->
+ 1 = 2.
+
+
+
%%-----------------------------------------------------------------
%% The error_logger handler used.
%%-----------------------------------------------------------------
diff --git a/lib/stdlib/test/qlc_SUITE.erl b/lib/stdlib/test/qlc_SUITE.erl
index 192268f90e..a9ea78a58b 100644
--- a/lib/stdlib/test/qlc_SUITE.erl
+++ b/lib/stdlib/test/qlc_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2013. 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
@@ -2969,15 +2969,6 @@ lookup1(Config) when is_list(Config) ->
[3] = lookup_keys(Q)
end, [{1,a},{3,3}])">>,
- {cres,
- <<"A = 3,
- etsc(fun(E) ->
- Q = qlc:q([X || X <- ets:table(E), A =:= {erlang,element}(1, X)]),
- [{3,3}] = qlc:e(Q),
- [3] = lookup_keys(Q)
- end, [{1,a},{3,3}])">>,
- {warnings,[{3,erl_lint,deprecated_tuple_fun}]}},
-
<<"etsc(fun(E) ->
A = 3,
Q = qlc:q([X || X <- ets:table(E),
@@ -3442,14 +3433,6 @@ lookup2(Config) when is_list(Config) ->
[r] = lookup_keys(Q)
end, [{keypos,1}], [#r{}])">>,
{cres,
- <<"etsc(fun(E) ->
- Q = qlc:q([element(1, X) || X <- ets:table(E),
- {erlang,is_record}(X, r, 2)]),
- [r] = qlc:e(Q),
- [r] = lookup_keys(Q)
- end, [{keypos,1}], [#r{}])">>,
- {warnings,[{4,erl_lint,deprecated_tuple_fun}]}},
- {cres,
<<"etsc(fun(E) ->
Q = qlc:q([element(1, X) || X <- ets:table(E),
record(X, r)]),
@@ -3468,15 +3451,7 @@ lookup2(Config) when is_list(Config) ->
is_record(X, r)]),
[r] = qlc:e(Q),
[r] = lookup_keys(Q)
- end, [{keypos,1}], [#r{}])">>,
- {cres,
- <<"etsc(fun(E) ->
- Q = qlc:q([element(1, X) || X <- ets:table(E),
- {erlang,is_record}(X, r)]),
- [r] = qlc:e(Q),
- [r] = lookup_keys(Q)
- end, [{keypos,1}], [#r{}])">>,
- {warnings,[{4,erl_lint,deprecated_tuple_fun}]}}
+ end, [{keypos,1}], [#r{}])">>
],
?line run(Config, <<"-record(r, {a}).\n">>, TsR),
@@ -6087,21 +6062,6 @@ otp_6673(Config) when is_list(Config) ->
],
?line run(Config, Ts_RT),
- %% Ulf Wiger provided a patch that makes QLC work with packages:
- Dir = filename:join(?privdir, "p"),
- ?line ok = filelib:ensure_dir(filename:join(Dir, ".")),
- File = filename:join(Dir, "p.erl"),
- ?line ok = file:write_file(File,
- <<"-module(p.p).\n"
- "-export([q/0]).\n"
- "-include_lib(\"stdlib/include/qlc.hrl\").\n"
- "q() ->\n"
- " .qlc:q([X || X <- [1,2]]).">>),
- ?line {ok, 'p.p'} = compile:file(File, [{outdir,Dir}]),
- ?line code:purge('p.p'),
- ?line {module, 'p.p'} = code:load_abs(filename:rootname(File), 'p.p'),
- ?line [1,2] = qlc:e(p.p:q()),
-
ok.
otp_6964(doc) ->
@@ -6703,7 +6663,7 @@ otp_7714(Config) when is_list(Config) ->
{A,I1} <- ets:table(E1),
{B,I2} <- ets:table(E2),
I1 =:= I2],{join,merge}),
- [{a,1},{a,2},{a,3}] = qlc:e(Q),
+ [{a,1},{a,2},{a,3}] = lists:sort(qlc:e(Q)),
ets:delete(E1),
ets:delete(E2)">>],
?line run(Config, Ts).
@@ -6768,7 +6728,7 @@ otp_6674(Config) when is_list(Config) ->
[{join,lookup}]}}],
[]} = qlc:info(Q, {format,debug}),
{0,1,0,0} = join_info(Q),
- [{1.0,1},{2,2}] = qlc:e(Q),
+ [{1.0,1},{2,2}] = lists:sort(qlc:e(Q)),
ets:delete(E1),
ets:delete(E2)">>,
<<"E1 = ets:new(join, [ordered_set]),
diff --git a/lib/stdlib/test/qlc_SUITE_data/join_info_compat.erl b/lib/stdlib/test/qlc_SUITE_data/join_info_compat.erl
index e0db132c47..a631b9dbcf 100644
--- a/lib/stdlib/test/qlc_SUITE_data/join_info_compat.erl
+++ b/lib/stdlib/test/qlc_SUITE_data/join_info_compat.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2013. 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
@@ -515,7 +516,7 @@ create_handle() ->
$.:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$N:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
@@ -523,16 +524,16 @@ create_handle() ->
$-:8/integer-unit:1-unsigned-big,
$):8/integer-unit:1-unsigned-big,
$-:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $È:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
$M:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ä:8/integer-unit:1-unsigned-big,
+ $Ê:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ê:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
@@ -541,19 +542,19 @@ create_handle() ->
$\026:8/integer-unit:1-unsigned-big,
$%:8/integer-unit:1-unsigned-big,
$r:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¥:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
$F:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ :8/integer-unit:1-unsigned-big,
+ $ð:8/integer-unit:1-unsigned-big,
$":8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $³:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $þ:8/integer-unit:1-unsigned-big,
+ $Ì:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big>>,
+ $É:8/integer-unit:1-unsigned-big>>,
<<$\203:8/integer-unit:1-unsigned-big,
$P:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
@@ -562,7 +563,7 @@ create_handle() ->
$<:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$N:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
@@ -570,16 +571,16 @@ create_handle() ->
$-:8/integer-unit:1-unsigned-big,
$):8/integer-unit:1-unsigned-big,
$-:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $È:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
$M:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ä:8/integer-unit:1-unsigned-big,
+ $Ê:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Î:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
@@ -588,22 +589,22 @@ create_handle() ->
$\026:8/integer-unit:1-unsigned-big,
$%:8/integer-unit:1-unsigned-big,
$r:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¥:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
$::8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¡:8/integer-unit:1-unsigned-big,
+ $ð:8/integer-unit:1-unsigned-big,
$":8/integer-unit:1-unsigned-big,
$P:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ñ:8/integer-unit:1-unsigned-big,
$Y:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ª:8/integer-unit:1-unsigned-big,
$9:8/integer-unit:1-unsigned-big,
$\r:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big>>,
+ $ý:8/integer-unit:1-unsigned-big>>,
<<$\203:8/integer-unit:1-unsigned-big,
$P:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
@@ -612,51 +613,51 @@ create_handle() ->
$I:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$M:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ê:8/integer-unit:1-unsigned-big,
$/:8/integer-unit:1-unsigned-big,
$H:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ä:8/integer-unit:1-unsigned-big,
$N:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¶:8/integer-unit:1-unsigned-big,
+ $µ:8/integer-unit:1-unsigned-big,
+ $²:8/integer-unit:1-unsigned-big,
+ $Í:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$\006:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ò:8/integer-unit:1-unsigned-big,
$e:8/integer-unit:1-unsigned-big,
$\211:8/integer-unit:1-unsigned-big,
$E:8/integer-unit:1-unsigned-big,
$\s:8/integer-unit:1-unsigned-big,
$>:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $£:8/integer-unit:1-unsigned-big,
$\023:8/integer-unit:1-unsigned-big,
$\210:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ç:8/integer-unit:1-unsigned-big,
$\232:8/integer-unit:1-unsigned-big,
$\226:8/integer-unit:1-unsigned-big,
$\223:8/integer-unit:1-unsigned-big,
$\237:8/integer-unit:1-unsigned-big,
$X:8/integer-unit:1-unsigned-big,
$\222:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $È:8/integer-unit:1-unsigned-big,
$\235:8/integer-unit:1-unsigned-big,
$l:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¨:8/integer-unit:1-unsigned-big,
$g:8/integer-unit:1-unsigned-big,
$i:8/integer-unit:1-unsigned-big,
$d:8/integer-unit:1-unsigned-big,
$\200:8/integer-unit:1-unsigned-big,
$\001:8/integer-unit:1-unsigned-big,
$R:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $µ:8/integer-unit:1-unsigned-big,
$\r:8/integer-unit:1-unsigned-big,
$\214:8/integer-unit:1-unsigned-big,
$\030:8/integer-unit:1-unsigned-big,
@@ -664,7 +665,7 @@ create_handle() ->
$\000:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$c:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ö:8/integer-unit:1-unsigned-big,
$\017:8/integer-unit:1-unsigned-big,
$=:8/integer-unit:1-unsigned-big>>,
<<$\203:8/integer-unit:1-unsigned-big,
@@ -708,24 +709,24 @@ create_handle() ->
$*:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$M:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ê:8/integer-unit:1-unsigned-big,
$/:8/integer-unit:1-unsigned-big,
$H:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ä:8/integer-unit:1-unsigned-big,
$\005:8/integer-unit:1-unsigned-big,
$R:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¶:8/integer-unit:1-unsigned-big,
+ $¶:8/integer-unit:1-unsigned-big,
$\031:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ì:8/integer-unit:1-unsigned-big,
$):8/integer-unit:1-unsigned-big,
$\f:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ì:8/integer-unit:1-unsigned-big,
$e:8/integer-unit:1-unsigned-big,
$\211:8/integer-unit:1-unsigned-big,
$E:8/integer-unit:1-unsigned-big,
@@ -737,7 +738,7 @@ create_handle() ->
$/:8/integer-unit:1-unsigned-big,
$\022:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ì:8/integer-unit:1-unsigned-big,
$\205:8/integer-unit:1-unsigned-big,
$\t:8/integer-unit:1-unsigned-big,
$\216:8/integer-unit:1-unsigned-big>>,
@@ -749,33 +750,33 @@ create_handle() ->
$j:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Î:8/integer-unit:1-unsigned-big,
+ $Ï:8/integer-unit:1-unsigned-big,
$+:8/integer-unit:1-unsigned-big,
$N:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ú:8/integer-unit:1-unsigned-big,
+ $ÿ:8/integer-unit:1-unsigned-big,
+ $ÿ:8/integer-unit:1-unsigned-big,
+ $ÿ:8/integer-unit:1-unsigned-big,
+ $·:8/integer-unit:1-unsigned-big,
$\f:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $æ:8/integer-unit:1-unsigned-big,
$\024:8/integer-unit:1-unsigned-big,
$\006:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ö:8/integer-unit:1-unsigned-big,
$\222:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ò:8/integer-unit:1-unsigned-big,
$\202:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ô:8/integer-unit:1-unsigned-big,
$D:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $®:8/integer-unit:1-unsigned-big,
$\034:8/integer-unit:1-unsigned-big,
$\006:8/integer-unit:1-unsigned-big,
$\006:8/integer-unit:1-unsigned-big,
@@ -791,7 +792,7 @@ create_handle() ->
$W:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
$\003:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $£:8/integer-unit:1-unsigned-big,
$\023:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
$/:8/integer-unit:1-unsigned-big,
@@ -800,18 +801,18 @@ create_handle() ->
$\027:8/integer-unit:1-unsigned-big,
$\237:8/integer-unit:1-unsigned-big,
$\205:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¤:8/integer-unit:1-unsigned-big,
$\227:8/integer-unit:1-unsigned-big,
$\007:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¤:8/integer-unit:1-unsigned-big,
$\227:8/integer-unit:1-unsigned-big,
$\021:8/integer-unit:1-unsigned-big,
$.:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ï:8/integer-unit:1-unsigned-big,
$\003:8/integer-unit:1-unsigned-big,
$\224:8/integer-unit:1-unsigned-big,
$\217:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ì:8/integer-unit:1-unsigned-big,
$\002:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\203:8/integer-unit:1-unsigned-big,
@@ -1398,7 +1399,7 @@ lookup_handle() ->
$.:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$N:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
@@ -1406,16 +1407,16 @@ lookup_handle() ->
$-:8/integer-unit:1-unsigned-big,
$):8/integer-unit:1-unsigned-big,
$-:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $È:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
$M:8/integer-unit:1-unsigned-big,
$\024:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ì:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ê:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
@@ -1424,19 +1425,19 @@ lookup_handle() ->
$\026:8/integer-unit:1-unsigned-big,
$%:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¦:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
$F:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ :8/integer-unit:1-unsigned-big,
+ $ð:8/integer-unit:1-unsigned-big,
$":8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $³:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\206:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big>>,
+ $Þ:8/integer-unit:1-unsigned-big>>,
<<$\203:8/integer-unit:1-unsigned-big,
$P:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
@@ -1445,7 +1446,7 @@ lookup_handle() ->
$.:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$N:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
@@ -1453,16 +1454,16 @@ lookup_handle() ->
$-:8/integer-unit:1-unsigned-big,
$):8/integer-unit:1-unsigned-big,
$-:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $È:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
$M:8/integer-unit:1-unsigned-big,
$\024:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ì:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ê:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
@@ -1471,19 +1472,19 @@ lookup_handle() ->
$\026:8/integer-unit:1-unsigned-big,
$%:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¦:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
$0:8/integer-unit:1-unsigned-big,
$F:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ :8/integer-unit:1-unsigned-big,
+ $ð:8/integer-unit:1-unsigned-big,
+ $â:8/integer-unit:1-unsigned-big,
+ $³:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\222:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big>>,
+ $ä:8/integer-unit:1-unsigned-big>>,
<<$\203:8/integer-unit:1-unsigned-big,
$h:8/integer-unit:1-unsigned-big,
$\003:8/integer-unit:1-unsigned-big,
@@ -1525,25 +1526,25 @@ lookup_handle() ->
$+:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$M:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ê:8/integer-unit:1-unsigned-big,
$/:8/integer-unit:1-unsigned-big,
$H:8/integer-unit:1-unsigned-big,
$\024:8/integer-unit:1-unsigned-big,
$N:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¶:8/integer-unit:1-unsigned-big,
+ $µ:8/integer-unit:1-unsigned-big,
+ $²:8/integer-unit:1-unsigned-big,
+ $Í:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$\006:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ò:8/integer-unit:1-unsigned-big,
$e:8/integer-unit:1-unsigned-big,
$\211:8/integer-unit:1-unsigned-big,
$E:8/integer-unit:1-unsigned-big,
@@ -1555,10 +1556,10 @@ lookup_handle() ->
$/:8/integer-unit:1-unsigned-big,
$\022:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $×:8/integer-unit:1-unsigned-big,
$\227:8/integer-unit:1-unsigned-big,
$\t:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big>>,
+ $Û:8/integer-unit:1-unsigned-big>>,
<<$\203:8/integer-unit:1-unsigned-big,
$P:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
@@ -1567,33 +1568,33 @@ lookup_handle() ->
$\\:8/integer-unit:1-unsigned-big,
$x:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ë:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
$a:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Î:8/integer-unit:1-unsigned-big,
+ $Ï:8/integer-unit:1-unsigned-big,
$+:8/integer-unit:1-unsigned-big,
$N:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $ú:8/integer-unit:1-unsigned-big,
+ $ÿ:8/integer-unit:1-unsigned-big,
+ $ÿ:8/integer-unit:1-unsigned-big,
+ $ÿ:8/integer-unit:1-unsigned-big,
+ $û:8/integer-unit:1-unsigned-big,
$\f:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $æ:8/integer-unit:1-unsigned-big,
$\024:8/integer-unit:1-unsigned-big,
$\006:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ö:8/integer-unit:1-unsigned-big,
$\222:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ò:8/integer-unit:1-unsigned-big,
$\202:8/integer-unit:1-unsigned-big,
$\234:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ô:8/integer-unit:1-unsigned-big,
$D:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Á:8/integer-unit:1-unsigned-big,
$\034:8/integer-unit:1-unsigned-big,
$\006:8/integer-unit:1-unsigned-big,
$\006:8/integer-unit:1-unsigned-big,
@@ -1605,7 +1606,7 @@ lookup_handle() ->
$Y:8/integer-unit:1-unsigned-big,
$b:8/integer-unit:1-unsigned-big,
$Q:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $¢:8/integer-unit:1-unsigned-big,
$`:8/integer-unit:1-unsigned-big,
$\n:8/integer-unit:1-unsigned-big,
$\003:8/integer-unit:1-unsigned-big,
@@ -1616,7 +1617,7 @@ lookup_handle() ->
$>:8/integer-unit:1-unsigned-big,
$\v:8/integer-unit:1-unsigned-big,
$I:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $µ:8/integer-unit:1-unsigned-big,
$\020:8/integer-unit:1-unsigned-big,
$H:8/integer-unit:1-unsigned-big,
$5:8/integer-unit:1-unsigned-big,
@@ -1630,7 +1631,7 @@ lookup_handle() ->
$\005:8/integer-unit:1-unsigned-big,
$\000:8/integer-unit:1-unsigned-big,
$\024:8/integer-unit:1-unsigned-big,
- $�:8/integer-unit:1-unsigned-big,
+ $Ù:8/integer-unit:1-unsigned-big,
$\031:8/integer-unit:1-unsigned-big,
$M:8/integer-unit:1-unsigned-big>>}
end,
diff --git a/lib/stdlib/test/re_SUITE.erl b/lib/stdlib/test/re_SUITE.erl
index a542745e67..500f5fadb9 100644
--- a/lib/stdlib/test/re_SUITE.erl
+++ b/lib/stdlib/test/re_SUITE.erl
@@ -1,3 +1,4 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
@@ -291,10 +292,10 @@ global_capture(Config) when is_list(Config) ->
?line match = re:run("ABCabcdABCabcdA","a(?<FOO>bcd)",[global,{capture,none,index}]),
?line match = re:run("ABCabcdABCabcdA","a(?<FOO>bcd)",[global,{capture,none,binary}]),
?line match = re:run("ABCabcdABCabcdA","a(?<FOO>bcd)",[global,{capture,none,list}]),
- ?line {match,[[<<195,133,98,99,100>>,<<"bcd">>],[<<"abcd">>,<<"bcd">>]]} = re:run("ABC�bcdABCabcdA",".(?<FOO>bcd)",[global,{capture,all,binary},unicode]),
- ?line {match,[["�bcd","bcd"],["abcd","bcd"]]} = re:run(<<"ABC",8#303,8#205,"bcdABCabcdA">>,".(?<FOO>bcd)",[global,{capture,all,list},unicode]),
- ?line {match,[["�bcd","bcd"],["abcd","bcd"]]} = re:run("ABC�bcdABCabcdA",".(?<FOO>bcd)",[global,{capture,all,list},unicode]),
- ?line {match,[[{3,5},{5,3}],[{11,4},{12,3}]]} = re:run("ABC�bcdABCabcdA",".(?<FOO>bcd)",[global,{capture,all,index},unicode]),
+ ?line {match,[[<<195,133,98,99,100>>,<<"bcd">>],[<<"abcd">>,<<"bcd">>]]} = re:run("ABCÅbcdABCabcdA",".(?<FOO>bcd)",[global,{capture,all,binary},unicode]),
+ ?line {match,[["Åbcd","bcd"],["abcd","bcd"]]} = re:run(<<"ABC",8#303,8#205,"bcdABCabcdA">>,".(?<FOO>bcd)",[global,{capture,all,list},unicode]),
+ ?line {match,[["Åbcd","bcd"],["abcd","bcd"]]} = re:run("ABCÅbcdABCabcdA",".(?<FOO>bcd)",[global,{capture,all,list},unicode]),
+ ?line {match,[[{3,5},{5,3}],[{11,4},{12,3}]]} = re:run("ABCÅbcdABCabcdA",".(?<FOO>bcd)",[global,{capture,all,index},unicode]),
?t:timetrap_cancel(Dog),
ok.
@@ -314,20 +315,26 @@ replace_return(Config) when is_list(Config) ->
Dog = ?t:timetrap(?t:minutes(3)),
?line {'EXIT',{badarg,_}} = (catch re:replace("na","(a","")),
?line <<"nasse">> = re:replace(<<"nisse">>,"i","a",[{return,binary}]),
- ?line <<"ABC�XABCXA">> = re:replace("ABC\305abcdABCabcdA","a(?<FOO>bcd)","X",[global,{return,binary}]),
+ ?line <<"ABCÅXABCXA">> = re:replace("ABC\305abcdABCabcdA","a(?<FOO>bcd)","X",[global,{return,binary}]),
- ?line [<<"ABC�">>,
+ ?line [<<"ABCÅ">>,
<<"X">>,
<<"ABC">>,
<<"X">> |
<<"A">> ] =
- re:replace("ABC�abcdABCabcdA","a(?<FOO>bcd)","X",[global,{return,iodata}]),
- ?line "ABC�XABCXA" = re:replace("ABC�abcdABCabcdA","a(?<FOO>bcd)","X",[global,{return,list},unicode]),
- ?line <<65,66,67,195,133,88,65,66,67,88,65>> = re:replace("ABC�abcdABCabcdA","a(?<FOO>bcd)","X",[global,{return,binary},unicode]),
- ?line <<65,66,67,195,133,88,65,66,67,97,98,99,100,65>> = re:replace("ABC�abcdABCabcdA","a(?<FOO>bcd)","X",[{return,binary},unicode]),
+ re:replace("ABCÅabcdABCabcdA","a(?<FOO>bcd)","X",[global,{return,iodata}]),
+ ?line "ABCÅXABCXA" = re:replace("ABCÅabcdABCabcdA","a(?<FOO>bcd)","X",[global,{return,list},unicode]),
+ ?line <<65,66,67,195,133,88,65,66,67,88,65>> = re:replace("ABCÅabcdABCabcdA","a(?<FOO>bcd)","X",[global,{return,binary},unicode]),
+ ?line <<65,66,67,195,133,88,65,66,67,97,98,99,100,65>> = re:replace("ABCÅabcdABCabcdA","a(?<FOO>bcd)","X",[{return,binary},unicode]),
?line <<"iXk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\9X",[{return,binary}]),
?line <<"jXk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\10X",[{return,binary}]),
?line <<"Xk">> = re:replace("abcdefghijk","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\11X",[{return,binary}]),
+ ?line <<"9X1">> = re:replace("12345678901","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\g9X",[{return,binary}]),
+ ?line <<"0X1">> = re:replace("12345678901","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\g10X",[{return,binary}]),
+ ?line <<"X1">> = re:replace("12345678901","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\g11X",[{return,binary}]),
+ ?line <<"971">> = re:replace("12345678901","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\g{9}7",[{return,binary}]),
+ ?line <<"071">> = re:replace("12345678901","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\g{10}7",[{return,binary}]),
+ ?line <<"71">> = re:replace("12345678901","(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)","\\g{11}7",[{return,binary}]),
?line "a\x{400}bcX" = re:replace("a\x{400}bcd","d","X",[global,{return,list},unicode]),
?line <<"a",208,128,"bcX">> = re:replace("a\x{400}bcd","d","X",[global,{return,binary},unicode]),
?line "a\x{400}bcd" = re:replace("a\x{400}bcd","Z","X",[global,{return,list},unicode]),
diff --git a/lib/stdlib/test/re_testoutput1_replacement_test.erl b/lib/stdlib/test/re_testoutput1_replacement_test.erl
index 69cb140e0d..8f8d8762ad 100644
--- a/lib/stdlib/test/re_testoutput1_replacement_test.erl
+++ b/lib/stdlib/test/re_testoutput1_replacement_test.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2012. 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
@@ -274,10 +275,10 @@ run() ->
?line <<"dthing">> = iolist_to_binary(re:replace("dthing","^[^]cde]","y\\1I&MoqRPG&GQa\\1l",[global])),
?line <<"ething">> = iolist_to_binary(re:replace("ething","^[^]cde]","AsxwUn\\1GqkWNdgRJk",[])),
?line <<"ething">> = iolist_to_binary(re:replace("ething","^[^]cde]","AsxwUn\\1GqkWNdgRJk",[global])),
-?line <<"RornKmOnaFr�tWgtW">> = iolist_to_binary(re:replace("�","^\\�","R\\1o\\1r\\1nKmOnaFr&tWgtW",[])),
-?line <<"RornKmOnaFr�tWgtW">> = iolist_to_binary(re:replace("�","^\\�","R\\1o\\1r\\1nKmOnaFr&tWgtW",[global])),
-?line <<"ufbmbfOYuK�wf�E�dx">> = iolist_to_binary(re:replace("�","^�","ufbmbfOYuK&wf&E&\\1dx",[])),
-?line <<"ufbmbfOYuK�wf�E�dx">> = iolist_to_binary(re:replace("�","^�","ufbmbfOYuK&wf&E&\\1dx",[global])),
+?line <<"RornKmOnaFrtWgtW">> = iolist_to_binary(re:replace("","^\\","R\\1o\\1r\\1nKmOnaFr&tWgtW",[])),
+?line <<"RornKmOnaFrtWgtW">> = iolist_to_binary(re:replace("","^\\","R\\1o\\1r\\1nKmOnaFr&tWgtW",[global])),
+?line <<"ufbmbfOYuKÿwfÿEÿdx">> = iolist_to_binary(re:replace("ÿ","^ÿ","ufbmbfOYuK&wf&E&\\1dx",[])),
+?line <<"ufbmbfOYuKÿwfÿEÿdx">> = iolist_to_binary(re:replace("ÿ","^ÿ","ufbmbfOYuK&wf&E&\\1dx",[global])),
?line <<"oAdJme0jw">> = iolist_to_binary(re:replace("0","^[0-9]+$","oAdJme\\1&jw",[])),
?line <<"oAdJme0jw">> = iolist_to_binary(re:replace("0","^[0-9]+$","oAdJme\\1&jw",[global])),
?line <<"1aoKN">> = iolist_to_binary(re:replace("1","^[0-9]+$","&aoKN",[])),
@@ -14972,10 +14973,10 @@ def">> = iolist_to_binary(re:replace("abc
def","abc$","M",[global])),
?line <<"abcWCabcSYXGPjRugTabcVGabcSX">> = iolist_to_binary(re:replace("abcS","(abc)\\123","\\1WC&YXGPjRugT\\1VG&X",[])),
?line <<"abcWCabcSYXGPjRugTabcVGabcSX">> = iolist_to_binary(re:replace("abcS","(abc)\\123","\\1WC&YXGPjRugT\\1VG&X",[global])),
-?line <<"fabc�Uabc�UmiqabceCsabcabc�">> = iolist_to_binary(re:replace("abc�","(abc)\\223","f&U&Umiq\\1eCs\\1&",[])),
-?line <<"fabc�Uabc�UmiqabceCsabcabc�">> = iolist_to_binary(re:replace("abc�","(abc)\\223","f&U&Umiq\\1eCs\\1&",[global])),
-?line <<"JRFabcxnbabc�Vkabc�fWigQMuaY">> = iolist_to_binary(re:replace("abc�","(abc)\\323","JRF\\1xnb&Vk&fWigQMuaY",[])),
-?line <<"JRFabcxnbabc�Vkabc�fWigQMuaY">> = iolist_to_binary(re:replace("abc�","(abc)\\323","JRF\\1xnb&Vk&fWigQMuaY",[global])),
+?line <<"fabc“Uabc“UmiqabceCsabcabc“">> = iolist_to_binary(re:replace("abc“","(abc)\\223","f&U&Umiq\\1eCs\\1&",[])),
+?line <<"fabc“Uabc“UmiqabceCsabcabc“">> = iolist_to_binary(re:replace("abc“","(abc)\\223","f&U&Umiq\\1eCs\\1&",[global])),
+?line <<"JRFabcxnbabcÓVkabcÓfWigQMuaY">> = iolist_to_binary(re:replace("abcÓ","(abc)\\323","JRF\\1xnb&Vk&fWigQMuaY",[])),
+?line <<"JRFabcxnbabcÓVkabcÓfWigQMuaY">> = iolist_to_binary(re:replace("abcÓ","(abc)\\323","JRF\\1xnb&Vk&fWigQMuaY",[global])),
?line <<"vgabc@QQ">> = iolist_to_binary(re:replace("abc@","(abc)\\100","vg&QQ",[])),
?line <<"vgabc@QQ">> = iolist_to_binary(re:replace("abc@","(abc)\\100","vg&QQ",[global])),
?line <<"abc@OkvNytabc@abcabc@a">> = iolist_to_binary(re:replace("abc@","(abc)\\100","&OkvNyt&\\1&a",[])),
@@ -18343,24 +18344,24 @@ xb","(?!^)x","\\1tysI\\1v\\1BVwx\\1FOWG\\1&C",[multiline,
?line <<"cY">> = iolist_to_binary(re:replace("M","\\M","cY\\1",[global])),
?line <<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa">> = iolist_to_binary(re:replace("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","(a+)*b","yWOTIFhIX\\1H",[])),
?line <<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa">> = iolist_to_binary(re:replace("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","(a+)*b","yWOTIFhIX\\1H",[global])),
-?line <<"NREGularsRREGularWEYrVRr">> = iolist_to_binary(re:replace("REGular","(?i)reg(?:ul(?:[a�]|ae)r|ex)","N&\\1sR&WEYrVRr",[])),
-?line <<"NREGularsRREGularWEYrVRr">> = iolist_to_binary(re:replace("REGular","(?i)reg(?:ul(?:[a�]|ae)r|ex)","N&\\1sR&WEYrVRr",[global])),
-?line <<"G">> = iolist_to_binary(re:replace("regulaer","(?i)reg(?:ul(?:[a�]|ae)r|ex)","G",[])),
-?line <<"G">> = iolist_to_binary(re:replace("regulaer","(?i)reg(?:ul(?:[a�]|ae)r|ex)","G",[global])),
-?line <<"PSsXtwlmy">> = iolist_to_binary(re:replace("Regex","(?i)reg(?:ul(?:[a�]|ae)r|ex)","PSsXtwlmy",[])),
-?line <<"PSsXtwlmy">> = iolist_to_binary(re:replace("Regex","(?i)reg(?:ul(?:[a�]|ae)r|ex)","PSsXtwlmy",[global])),
-?line <<"regul�rmiYTi">> = iolist_to_binary(re:replace("regul�r","(?i)reg(?:ul(?:[a�]|ae)r|ex)","&miYTi\\1\\1",[])),
-?line <<"regul�rmiYTi">> = iolist_to_binary(re:replace("regul�r","(?i)reg(?:ul(?:[a�]|ae)r|ex)","&miYTi\\1\\1",[global])),
-?line <<"W�����rxh�����yUoaLOIegmSA">> = iolist_to_binary(re:replace("�����","����[�-��-�]+","W&rxh&yUoaL\\1OIegmS\\1A",[])),
-?line <<"W�����rxh�����yUoaLOIegmSA">> = iolist_to_binary(re:replace("�����","����[�-��-�]+","W&rxh&yUoaL\\1OIegmS\\1A",[global])),
-?line <<"F�����gnWPyHeh�����tXTQ">> = iolist_to_binary(re:replace("�����","����[�-��-�]+","F&gnWPyHe\\1h&tXTQ",[])),
-?line <<"F�����gnWPyHeh�����tXTQ">> = iolist_to_binary(re:replace("�����","����[�-��-�]+","F&gnWPyHe\\1h&tXTQ",[global])),
-?line <<"sHerHnAhAdx">> = iolist_to_binary(re:replace("�����","����[�-��-�]+","sHer\\1HnA\\1h\\1Adx",[])),
-?line <<"sHerHnAhAdx">> = iolist_to_binary(re:replace("�����","����[�-��-�]+","sHer\\1HnA\\1h\\1Adx",[global])),
-?line <<"trobAQoU�����n">> = iolist_to_binary(re:replace("�����","����[�-��-�]+","tr\\1obAQoU&n",[])),
-?line <<"trobAQoU�����n">> = iolist_to_binary(re:replace("�����","����[�-��-�]+","tr\\1obAQoU&n",[global])),
-?line <<"�XAZSd">> = iolist_to_binary(re:replace("�XAZXB","(?<=Z)X.","Sd",[])),
-?line <<"�XAZSd">> = iolist_to_binary(re:replace("�XAZXB","(?<=Z)X.","Sd",[global])),
+?line <<"NREGularsRREGularWEYrVRr">> = iolist_to_binary(re:replace("REGular","(?i)reg(?:ul(?:[aä]|ae)r|ex)","N&\\1sR&WEYrVRr",[])),
+?line <<"NREGularsRREGularWEYrVRr">> = iolist_to_binary(re:replace("REGular","(?i)reg(?:ul(?:[aä]|ae)r|ex)","N&\\1sR&WEYrVRr",[global])),
+?line <<"G">> = iolist_to_binary(re:replace("regulaer","(?i)reg(?:ul(?:[aä]|ae)r|ex)","G",[])),
+?line <<"G">> = iolist_to_binary(re:replace("regulaer","(?i)reg(?:ul(?:[aä]|ae)r|ex)","G",[global])),
+?line <<"PSsXtwlmy">> = iolist_to_binary(re:replace("Regex","(?i)reg(?:ul(?:[aä]|ae)r|ex)","PSsXtwlmy",[])),
+?line <<"PSsXtwlmy">> = iolist_to_binary(re:replace("Regex","(?i)reg(?:ul(?:[aä]|ae)r|ex)","PSsXtwlmy",[global])),
+?line <<"regulärmiYTi">> = iolist_to_binary(re:replace("regulär","(?i)reg(?:ul(?:[aä]|ae)r|ex)","&miYTi\\1\\1",[])),
+?line <<"regulärmiYTi">> = iolist_to_binary(re:replace("regulär","(?i)reg(?:ul(?:[aä]|ae)r|ex)","&miYTi\\1\\1",[global])),
+?line <<"WÅæåäàrxhÅæåäàyUoaLOIegmSA">> = iolist_to_binary(re:replace("Åæåäà","Åæåä[à-ÿÀ-ß]+","W&rxh&yUoaL\\1OIegmS\\1A",[])),
+?line <<"WÅæåäàrxhÅæåäàyUoaLOIegmSA">> = iolist_to_binary(re:replace("Åæåäà","Åæåä[à-ÿÀ-ß]+","W&rxh&yUoaL\\1OIegmS\\1A",[global])),
+?line <<"FÅæåäÿgnWPyHehÅæåäÿtXTQ">> = iolist_to_binary(re:replace("Åæåäÿ","Åæåä[à-ÿÀ-ß]+","F&gnWPyHe\\1h&tXTQ",[])),
+?line <<"FÅæåäÿgnWPyHehÅæåäÿtXTQ">> = iolist_to_binary(re:replace("Åæåäÿ","Åæåä[à-ÿÀ-ß]+","F&gnWPyHe\\1h&tXTQ",[global])),
+?line <<"sHerHnAhAdx">> = iolist_to_binary(re:replace("ÅæåäÀ","Åæåä[à-ÿÀ-ß]+","sHer\\1HnA\\1h\\1Adx",[])),
+?line <<"sHerHnAhAdx">> = iolist_to_binary(re:replace("ÅæåäÀ","Åæåä[à-ÿÀ-ß]+","sHer\\1HnA\\1h\\1Adx",[global])),
+?line <<"trobAQoUÅæåäßn">> = iolist_to_binary(re:replace("Åæåäß","Åæåä[à-ÿÀ-ß]+","tr\\1obAQoU&n",[])),
+?line <<"trobAQoUÅæåäßn">> = iolist_to_binary(re:replace("Åæåäß","Åæåä[à-ÿÀ-ß]+","tr\\1obAQoU&n",[global])),
+?line <<"„XAZSd">> = iolist_to_binary(re:replace("„XAZXB","(?<=Z)X.","Sd",[])),
+?line <<"„XAZSd">> = iolist_to_binary(re:replace("„XAZXB","(?<=Z)X.","Sd",[global])),
?line <<"A">> = iolist_to_binary(re:replace("ab cd defg","ab cd (?x) de fg","\\1A\\1",[])),
?line <<"A">> = iolist_to_binary(re:replace("ab cd defg","ab cd (?x) de fg","\\1A\\1",[global])),
?line <<"fab cddefgLdtKCtPab cddefgxvVUHDah">> = iolist_to_binary(re:replace("ab cddefg","ab cd(?x) de fg","f&LdtKC\\1\\1tP&xvVUHDah",[])),
diff --git a/lib/stdlib/test/re_testoutput1_split_test.erl b/lib/stdlib/test/re_testoutput1_split_test.erl
index e86a04b008..4fc85b95c0 100644
--- a/lib/stdlib/test/re_testoutput1_split_test.erl
+++ b/lib/stdlib/test/re_testoutput1_split_test.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2012. 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
@@ -524,14 +525,14 @@ run() ->
?line <<"ething">> = iolist_to_binary(join(re:split("ething","^[^]cde]",[{parts,
2}]))),
?line <<"ething">> = iolist_to_binary(join(re:split("ething","^[^]cde]",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("�","^\\�",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("�","^\\�",[{parts,
+?line <<"">> = iolist_to_binary(join(re:split("","^\\",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("","^\\",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("�","^\\�",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("�","^�",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("�","^�",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("","^\\",[]))),
+?line <<"">> = iolist_to_binary(join(re:split("ÿ","^ÿ",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("ÿ","^ÿ",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("�","^�",[]))),
+?line <<":">> = iolist_to_binary(join(re:split("ÿ","^ÿ",[]))),
?line <<"">> = iolist_to_binary(join(re:split("0","^[0-9]+$",[trim]))),
?line <<":">> = iolist_to_binary(join(re:split("0","^[0-9]+$",[{parts,
2}]))),
@@ -22879,14 +22880,14 @@ def","abc$",[]))),
?line <<":abc:">> = iolist_to_binary(join(re:split("abcS","(abc)\\123",[{parts,
2}]))),
?line <<":abc:">> = iolist_to_binary(join(re:split("abcS","(abc)\\123",[]))),
-?line <<":abc">> = iolist_to_binary(join(re:split("abc�","(abc)\\223",[trim]))),
-?line <<":abc:">> = iolist_to_binary(join(re:split("abc�","(abc)\\223",[{parts,
+?line <<":abc">> = iolist_to_binary(join(re:split("abc“","(abc)\\223",[trim]))),
+?line <<":abc:">> = iolist_to_binary(join(re:split("abc“","(abc)\\223",[{parts,
2}]))),
-?line <<":abc:">> = iolist_to_binary(join(re:split("abc�","(abc)\\223",[]))),
-?line <<":abc">> = iolist_to_binary(join(re:split("abc�","(abc)\\323",[trim]))),
-?line <<":abc:">> = iolist_to_binary(join(re:split("abc�","(abc)\\323",[{parts,
+?line <<":abc:">> = iolist_to_binary(join(re:split("abc“","(abc)\\223",[]))),
+?line <<":abc">> = iolist_to_binary(join(re:split("abcÓ","(abc)\\323",[trim]))),
+?line <<":abc:">> = iolist_to_binary(join(re:split("abcÓ","(abc)\\323",[{parts,
2}]))),
-?line <<":abc:">> = iolist_to_binary(join(re:split("abc�","(abc)\\323",[]))),
+?line <<":abc:">> = iolist_to_binary(join(re:split("abcÓ","(abc)\\323",[]))),
?line <<":abc">> = iolist_to_binary(join(re:split("abc@","(abc)\\100",[trim]))),
?line <<":abc:">> = iolist_to_binary(join(re:split("abc@","(abc)\\100",[{parts,
2}]))),
@@ -28929,42 +28930,42 @@ xb","(?!^)x",[multiline]))),
?line <<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa">> = iolist_to_binary(join(re:split("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","(a+)*b",[{parts,
2}]))),
?line <<"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa">> = iolist_to_binary(join(re:split("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","(a+)*b",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("REGular","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("REGular","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[{parts,
+?line <<"">> = iolist_to_binary(join(re:split("REGular","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("REGular","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("REGular","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("regulaer","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("regulaer","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("REGular","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[]))),
+?line <<"">> = iolist_to_binary(join(re:split("regulaer","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("regulaer","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("regulaer","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("Regex","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("Regex","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("regulaer","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[]))),
+?line <<"">> = iolist_to_binary(join(re:split("Regex","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("Regex","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("Regex","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("regul�r","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("regul�r","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("Regex","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[]))),
+?line <<"">> = iolist_to_binary(join(re:split("regulär","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("regulär","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("regul�r","(?i)reg(?:ul(?:[a�]|ae)r|ex)",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("regulär","(?i)reg(?:ul(?:[aä]|ae)r|ex)",[]))),
+?line <<"">> = iolist_to_binary(join(re:split("Åæåäà","Åæåä[à-ÿÀ-ß]+",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("Åæåäà","Åæåä[à-ÿÀ-ß]+",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("Åæåäà","Åæåä[à-ÿÀ-ß]+",[]))),
+?line <<"">> = iolist_to_binary(join(re:split("Åæåäÿ","Åæåä[à-ÿÀ-ß]+",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("Åæåäÿ","Åæåä[à-ÿÀ-ß]+",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("Åæåäÿ","Åæåä[à-ÿÀ-ß]+",[]))),
+?line <<"">> = iolist_to_binary(join(re:split("ÅæåäÀ","Åæåä[à-ÿÀ-ß]+",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("ÅæåäÀ","Åæåä[à-ÿÀ-ß]+",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[]))),
-?line <<"">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[trim]))),
-?line <<":">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("ÅæåäÀ","Åæåä[à-ÿÀ-ß]+",[]))),
+?line <<"">> = iolist_to_binary(join(re:split("Åæåäß","Åæåä[à-ÿÀ-ß]+",[trim]))),
+?line <<":">> = iolist_to_binary(join(re:split("Åæåäß","Åæåä[à-ÿÀ-ß]+",[{parts,
2}]))),
-?line <<":">> = iolist_to_binary(join(re:split("�����","����[�-��-�]+",[]))),
-?line <<"�XAZ">> = iolist_to_binary(join(re:split("�XAZXB","(?<=Z)X.",[trim]))),
-?line <<"�XAZ:">> = iolist_to_binary(join(re:split("�XAZXB","(?<=Z)X.",[{parts,
+?line <<":">> = iolist_to_binary(join(re:split("Åæåäß","Åæåä[à-ÿÀ-ß]+",[]))),
+?line <<"„XAZ">> = iolist_to_binary(join(re:split("„XAZXB","(?<=Z)X.",[trim]))),
+?line <<"„XAZ:">> = iolist_to_binary(join(re:split("„XAZXB","(?<=Z)X.",[{parts,
2}]))),
-?line <<"�XAZ:">> = iolist_to_binary(join(re:split("�XAZXB","(?<=Z)X.",[]))),
+?line <<"„XAZ:">> = iolist_to_binary(join(re:split("„XAZXB","(?<=Z)X.",[]))),
?line <<"">> = iolist_to_binary(join(re:split("ab cd defg","ab cd (?x) de fg",[trim]))),
?line <<":">> = iolist_to_binary(join(re:split("ab cd defg","ab cd (?x) de fg",[{parts,
2}]))),
diff --git a/lib/stdlib/test/sets_SUITE.erl b/lib/stdlib/test/sets_SUITE.erl
index f284276bd7..c0cf1fc7e8 100644
--- a/lib/stdlib/test/sets_SUITE.erl
+++ b/lib/stdlib/test/sets_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2013. 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
@@ -35,7 +35,7 @@
-import(lists, [foldl/3,reverse/1]).
init_per_testcase(_Case, Config) ->
- ?line Dog = ?t:timetrap(?t:minutes(5)),
+ Dog = ?t:timetrap(?t:minutes(5)),
[{watchdog,Dog}|Config].
end_per_testcase(_Case, Config) ->
@@ -70,65 +70,65 @@ create(Config) when is_list(Config) ->
test_all(fun create_1/1).
create_1(M) ->
- ?line S0 = M:empty(),
- ?line [] = M:to_list(S0),
- ?line 0 = M:size(S0),
- ?line true = M:is_empty(S0),
+ S0 = M(empty, []),
+ [] = M(to_list, S0),
+ 0 = M(size, S0),
+ true = M(is_empty, S0),
E = make_ref(),
- ?line One = M:singleton(E),
- ?line 1 = M:size(One),
- ?line false = M:is_empty(One),
- [E] = M:to_list(One),
+ One = M(singleton, E),
+ 1 = M(size, One),
+ false = M(is_empty, One),
+ [E] = M(to_list, One),
S0.
add_element(Config) when is_list(Config) ->
test_all([{0,132},{253,258},{510,514}], fun add_element_1/2).
add_element_1(List, M) ->
- ?line S = M:from_list(List),
- ?line SortedSet = lists:usort(List),
- ?line SortedSet = lists:sort(M:to_list(S)),
+ S = M(from_list, List),
+ SortedSet = lists:usort(List),
+ SortedSet = lists:sort(M(to_list, S)),
%% Make sure that we get the same result by inserting
%% elements one at the time.
- ?line S2 = foldl(fun(El, Set) -> M:add_element(El, Set) end,
- M:empty(), List),
- ?line true = M:equal(S, S2),
+ S2 = foldl(fun(El, Set) -> M(add_element, {El,Set}) end,
+ M(empty, []), List),
+ true = M(equal, {S,S2}),
%% Insert elements, randomly delete inserted elements,
%% and re-inserted all deleted elements at the end.
- ?line S3 = add_element_del(List, M, M:empty(), [], []),
- ?line true = M:equal(S2, S3),
- ?line true = M:equal(S, S3),
+ S3 = add_element_del(List, M, M(empty, []), [], []),
+ true = M(equal, {S2,S3}),
+ true = M(equal, {S,S3}),
S.
add_element_del([H|T], M, S, Del, []) ->
- add_element_del(T, M, M:add_element(H, S), Del, [H]);
+ add_element_del(T, M, M(add_element, {H,S}), Del, [H]);
add_element_del([H|T], M, S0, Del, Inserted) ->
- S1 = M:add_element(H, S0),
+ S1 = M(add_element, {H,S0}),
case random:uniform(3) of
1 ->
OldEl = lists:nth(random:uniform(length(Inserted)), Inserted),
- S = M:del_element(OldEl, S1),
+ S = M(del_element, {OldEl,S1}),
add_element_del(T, M, S, [OldEl|Del], [H|Inserted]);
_ ->
add_element_del(T, M, S1, Del, [H|Inserted])
end;
add_element_del([], M, S, Del, _) ->
- M:union(S, M:from_list(Del)).
+ M(union, {S,M(from_list, Del)}).
del_element(Config) when is_list(Config) ->
test_all([{0,132},{253,258},{510,514},{1022,1026}], fun del_element_1/2).
del_element_1(List, M) ->
- ?line S0 = M:from_list(List),
- ?line Empty = foldl(fun(El, Set) -> M:del_element(El, Set) end, S0, List),
- ?line Empty = M:empty(),
- ?line M:is_empty(Empty),
- ?line S1 = foldl(fun(El, Set) ->
- M:add_element(El, Set)
- end, S0, reverse(List)),
- ?line true = M:equal(S0, S1),
+ S0 = M(from_list, List),
+ Empty = foldl(fun(El, Set) -> M(del_element, {El,Set}) end, S0, List),
+ Empty = M(empty, []),
+ true = M(is_empty, Empty),
+ S1 = foldl(fun(El, Set) ->
+ M(add_element, {El,Set})
+ end, S0, reverse(List)),
+ true = M(equal, {S0,S1}),
S1.
subtract(Config) when is_list(Config) ->
@@ -138,23 +138,23 @@ subtract(Config) when is_list(Config) ->
test_all([{2,69},{126,130},{253,258},511,512,{1023,1030}], fun subtract_1/2).
subtract_empty(M) ->
- ?line Empty = M:empty(),
- ?line true = M:is_empty(M:subtract(Empty, Empty)),
- M:subtract(Empty, Empty).
+ Empty = M(empty, []),
+ true = M(is_empty, M(subtract, {Empty,Empty})),
+ M(subtract, {Empty,Empty}).
subtract_1(List, M) ->
- ?line S0 = M:from_list(List),
- ?line Empty = M:empty(),
+ S0 = M(from_list, List),
+ Empty = M(empty, []),
%% Trivial cases.
- ?line true = M:is_empty(M:subtract(Empty, S0)),
- ?line true = M:equal(S0, M:subtract(S0, Empty)),
+ true = M(is_empty, M(subtract, {Empty,S0})),
+ true = M(equal, {S0,M(subtract, {S0,Empty})}),
%% Not so trivial.
- ?line subtract_check(List, mutate_some(remove_some(List, 0.4)), M),
- ?line subtract_check(List, rnd_list(length(List) div 2 + 5), M),
- ?line subtract_check(List, rnd_list(length(List) div 7 + 9), M),
- ?line subtract_check(List, mutate_some(List), M).
+ subtract_check(List, mutate_some(remove_some(List, 0.4)), M),
+ subtract_check(List, rnd_list(length(List) div 2 + 5), M),
+ subtract_check(List, rnd_list(length(List) div 7 + 9), M),
+ subtract_check(List, mutate_some(List), M).
subtract_check(A, B, M) ->
one_subtract_check(B, A, M),
@@ -163,12 +163,12 @@ subtract_check(A, B, M) ->
one_subtract_check(A, B, M) ->
ASorted = lists:usort(A),
BSorted = lists:usort(B),
- ASet = M:from_list(A),
- BSet = M:from_list(B),
- DiffSet = M:subtract(ASet, BSet),
+ ASet = M(from_list, A),
+ BSet = M(from_list, B),
+ DiffSet = M(subtract, {ASet,BSet}),
Diff = ASorted -- BSorted,
- true = M:equal(DiffSet, M:from_list(Diff)),
- Diff = lists:sort(M:to_list(DiffSet)),
+ true = M(equal, {DiffSet,M(from_list, Diff)}),
+ Diff = lists:sort(M(to_list, DiffSet)),
DiffSet.
intersection(Config) when is_list(Config) ->
@@ -176,60 +176,60 @@ intersection(Config) when is_list(Config) ->
test_all([{1,65},{126,130},{253,259},{499,513},{1023,1025}], fun intersection_1/2).
intersection_1(List, M) ->
- ?line S0 = M:from_list(List),
+ S0 = M(from_list, List),
%% Intersection with self.
- ?line true = M:equal(S0, M:intersection(S0, S0)),
- ?line true = M:equal(S0, M:intersection([S0,S0])),
- ?line true = M:equal(S0, M:intersection([S0,S0,S0])),
- ?line true = M:equal(S0, M:intersection([S0])),
+ true = M(equal, {S0,M(intersection, {S0,S0})}),
+ true = M(equal, {S0,M(intersection, [S0,S0])}),
+ true = M(equal, {S0,M(intersection, [S0,S0,S0])}),
+ true = M(equal, {S0,M(intersection, [S0])}),
%% Intersection with empty.
- ?line Empty = M:empty(),
- ?line true = M:equal(Empty, M:intersection(S0, Empty)),
- ?line true = M:equal(Empty, M:intersection([S0,Empty,S0,Empty])),
+ Empty = M(empty, []),
+ true = M(equal, {Empty,M(intersection, {S0,Empty})}),
+ true = M(equal, {Empty,M(intersection, [S0,Empty,S0,Empty])}),
%% The intersection of no sets is undefined.
- ?line {'EXIT',_} = (catch M:intersection([])),
+ {'EXIT',_} = (catch M(intersection, [])),
%% Disjoint sets.
- ?line Disjoint = [{El} || El <- List],
- ?line DisjointSet = M:from_list(Disjoint),
- ?line M:is_empty(M:intersection(S0, DisjointSet)),
+ Disjoint = [{El} || El <- List],
+ DisjointSet = M(from_list, Disjoint),
+ true = M(is_empty, M(intersection, {S0,DisjointSet})),
%% Disjoint, different sizes.
- ?line M:is_empty(M:intersection(S0, M:from_list(remove_some(Disjoint, 0.3)))),
- ?line M:is_empty(M:intersection(S0, M:from_list(remove_some(Disjoint, 0.7)))),
- ?line M:is_empty(M:intersection(S0, M:from_list(remove_some(Disjoint, 0.9)))),
- ?line M:is_empty(M:intersection(M:from_list(remove_some(List, 0.3)), DisjointSet)),
- ?line M:is_empty(M:intersection(M:from_list(remove_some(List, 0.5)), DisjointSet)),
- ?line M:is_empty(M:intersection(M:from_list(remove_some(List, 0.9)), DisjointSet)),
+ [begin
+ SomeRemoved = M(from_list, remove_some(Disjoint, HowMuch)),
+ true = M(is_empty, M(intersection, {S0,SomeRemoved})),
+ MoreRemoved = M(from_list, remove_some(List, HowMuch)),
+ true = M(is_empty, M(intersection, {MoreRemoved,DisjointSet}))
+ end || HowMuch <- [0.3,0.5,0.7,0.9]],
%% Partial overlap (one or more elements in result set).
%% The sets have almost the same size. (Almost because a duplicated
%% element in the original list could be mutated and not mutated
%% at the same time.)
- ?line PartialOverlap = mutate_some(List, []),
- ?line IntersectionSet = check_intersection(List, PartialOverlap, M),
- ?line false = M:is_empty(IntersectionSet),
+ PartialOverlap = mutate_some(List, []),
+ IntersectionSet = check_intersection(List, PartialOverlap, M),
+ false = M(is_empty, IntersectionSet),
%% Partial overlap, different set sizes. (Intersection possibly empty.)
- ?line check_intersection(List, remove_some(PartialOverlap, 0.1), M),
- ?line check_intersection(List, remove_some(PartialOverlap, 0.3), M),
- ?line check_intersection(List, remove_some(PartialOverlap, 0.5), M),
- ?line check_intersection(List, remove_some(PartialOverlap, 0.7), M),
- ?line check_intersection(List, remove_some(PartialOverlap, 0.9), M),
+ check_intersection(List, remove_some(PartialOverlap, 0.1), M),
+ check_intersection(List, remove_some(PartialOverlap, 0.3), M),
+ check_intersection(List, remove_some(PartialOverlap, 0.5), M),
+ check_intersection(List, remove_some(PartialOverlap, 0.7), M),
+ check_intersection(List, remove_some(PartialOverlap, 0.9), M),
IntersectionSet.
check_intersection(Orig, Mutated, M) ->
- OrigSet = M:from_list(Orig),
- MutatedSet = M:from_list(Mutated),
+ OrigSet = M(from_list, Orig),
+ MutatedSet = M(from_list, Mutated),
Intersection = [El || El <- Mutated, not is_tuple(El)],
SortedIntersection = lists:usort(Intersection),
- IntersectionSet = M:intersection(OrigSet, MutatedSet),
- true = M:equal(IntersectionSet, M:from_list(SortedIntersection)),
- SortedIntersection = lists:sort(M:to_list(IntersectionSet)),
+ IntersectionSet = M(intersection, {OrigSet,MutatedSet}),
+ true = M(equal, {IntersectionSet,M(from_list, SortedIntersection)}),
+ SortedIntersection = lists:sort(M(to_list, IntersectionSet)),
IntersectionSet.
@@ -239,63 +239,63 @@ union(Config) when is_list(Config) ->
test_all([{1,71},{125,129},{254,259},{510,513},{1023,1025}], fun union_1/2).
union_1(List, M) ->
- ?line S = M:from_list(List),
+ S = M(from_list, List),
%% Union with self and empty.
- ?line Empty = M:empty(),
- ?line true = M:equal(S, M:union(S, S)),
- ?line true = M:equal(S, M:union([S,S])),
- ?line true = M:equal(S, M:union([S,S,Empty])),
- ?line true = M:equal(S, M:union([S,Empty,S])),
- ?line true = M:equal(S, M:union(S, Empty)),
- ?line true = M:equal(S, M:union([S])),
- ?line true = M:is_empty(M:union([])),
+ Empty = M(empty, []),
+ true = M(equal, {S,M(union, {S,S})}),
+ true = M(equal, {S,M(union, [S,S])}),
+ true = M(equal, {S,M(union, [S,S,Empty])}),
+ true = M(equal, {S,M(union, [S,Empty,S])}),
+ true = M(equal, {S,M(union, {S,Empty})}),
+ true = M(equal, {S,M(union, [S])}),
+ true = M(is_empty, M(union, [])),
%% Partial overlap.
- ?line check_union(List, remove_some(mutate_some(List), 0.9), M),
- ?line check_union(List, remove_some(mutate_some(List), 0.7), M),
- ?line check_union(List, remove_some(mutate_some(List), 0.5), M),
- ?line check_union(List, remove_some(mutate_some(List), 0.3), M),
- ?line check_union(List, remove_some(mutate_some(List), 0.1), M),
-
- ?line check_union(List, mutate_some(remove_some(List, 0.9)), M),
- ?line check_union(List, mutate_some(remove_some(List, 0.7)), M),
- ?line check_union(List, mutate_some(remove_some(List, 0.5)), M),
- ?line check_union(List, mutate_some(remove_some(List, 0.3)), M),
- ?line check_union(List, mutate_some(remove_some(List, 0.1)), M).
+ check_union(List, remove_some(mutate_some(List), 0.9), M),
+ check_union(List, remove_some(mutate_some(List), 0.7), M),
+ check_union(List, remove_some(mutate_some(List), 0.5), M),
+ check_union(List, remove_some(mutate_some(List), 0.3), M),
+ check_union(List, remove_some(mutate_some(List), 0.1), M),
+
+ check_union(List, mutate_some(remove_some(List, 0.9)), M),
+ check_union(List, mutate_some(remove_some(List, 0.7)), M),
+ check_union(List, mutate_some(remove_some(List, 0.5)), M),
+ check_union(List, mutate_some(remove_some(List, 0.3)), M),
+ check_union(List, mutate_some(remove_some(List, 0.1)), M).
check_union(Orig, Other, M) ->
- OrigSet = M:from_list(Orig),
- OtherSet = M:from_list(Other),
+ OrigSet = M(from_list, Orig),
+ OtherSet = M(from_list, Other),
Union = Orig++Other,
SortedUnion = lists:usort(Union),
- UnionSet = M:union(OrigSet, OtherSet),
- SortedUnion = lists:sort(M:to_list(UnionSet)),
- M:equal(UnionSet, M:from_list(Union)),
+ UnionSet = M(union, {OrigSet,OtherSet}),
+ SortedUnion = lists:sort(M(to_list, UnionSet)),
+ M(equal, {UnionSet,M(from_list, Union)}),
UnionSet.
is_subset(Config) when is_list(Config) ->
test_all([{1,132},{253,270},{299,311}], fun is_subset_1/2).
is_subset_1(List, M) ->
- ?line S = M:from_list(List),
- ?line Empty = M:empty(),
+ S = M(from_list, List),
+ Empty = M(empty, []),
%% Subset of empty and self.
- ?line true = M:is_subset(Empty, Empty),
- ?line true = M:is_subset(Empty, S),
- ?line false = M:is_subset(S, Empty),
- ?line true = M:is_subset(S, S),
+ true = M(is_subset, {Empty,Empty}),
+ true = M(is_subset, {Empty,S}),
+ false = M(is_subset, {S,Empty}),
+ true = M(is_subset, {S,S}),
%% Other cases.
- Res = [?line false = M:is_subset(M:singleton(make_ref()), S),
- ?line true = M:is_subset(M:singleton(hd(List)), S),
- ?line true = check_subset(remove_some(List, 0.1), List, M),
- ?line true = check_subset(remove_some(List, 0.5), List, M),
- ?line true = check_subset(remove_some(List, 0.9), List, M),
- ?line check_subset(mutate_some(List), List, M),
- ?line check_subset(rnd_list(length(List) div 2 + 5), List, M),
- ?line subtract_check(List, rnd_list(length(List) div 7 + 9), M)
+ Res = [false = M(is_subset, {M(singleton, make_ref()),S}),
+ true = M(is_subset, {M(singleton, hd(List)),S}),
+ true = check_subset(remove_some(List, 0.1), List, M),
+ true = check_subset(remove_some(List, 0.5), List, M),
+ true = check_subset(remove_some(List, 0.9), List, M),
+ check_subset(mutate_some(List), List, M),
+ check_subset(rnd_list(length(List) div 2 + 5), List, M),
+ subtract_check(List, rnd_list(length(List) div 7 + 9), M)
],
res_to_set(Res, M, 0, []).
@@ -304,12 +304,12 @@ check_subset(X, Y, M) ->
check_one_subset(X, Y, M).
check_one_subset(X, Y, M) ->
- XSet = M:from_list(X),
- YSet = M:from_list(Y),
+ XSet = M(from_list, X),
+ YSet = M(from_list, Y),
SortedX = lists:usort(X),
SortedY = lists:usort(Y),
IsSubSet = length(SortedY--SortedX) =:= length(SortedY) - length(SortedX),
- IsSubSet = M:is_subset(XSet, YSet),
+ IsSubSet = M(is_subset, {XSet,YSet}),
IsSubSet.
%% Encode all test results as a set to return.
@@ -317,54 +317,54 @@ res_to_set([true|T], M, I, Acc) ->
res_to_set(T, M, I+1, [I|Acc]);
res_to_set([_|T], M, I, Acc) ->
res_to_set(T, M, I+1, Acc);
-res_to_set([], M, _, Acc) -> M:from_list(Acc).
+res_to_set([], M, _, Acc) -> M(from_list, Acc).
is_set(Config) when is_list(Config) ->
%% is_set/1 is tested in the other test cases when its argument
%% is a set. Here test some arguments that makes it return false.
- ?line false = gb_sets:is_set([a,b]),
- ?line false = gb_sets:is_set({a,very,bad,tuple}),
+ false = gb_sets:is_set([a,b]),
+ false = gb_sets:is_set({a,very,bad,tuple}),
- ?line false = sets:is_set([a,b]),
- ?line false = sets:is_set({a,very,bad,tuple}),
+ false = sets:is_set([a,b]),
+ false = sets:is_set({a,very,bad,tuple}),
- ?line false = ordsets:is_set([b,a]),
- ?line false = ordsets:is_set({bad,tuple}),
+ false = ordsets:is_set([b,a]),
+ false = ordsets:is_set({bad,tuple}),
%% Now test values that are known to be bad for all set representations.
test_all(fun is_set_1/1).
is_set_1(M) ->
- ?line false = M:is_set(self()),
- ?line false = M:is_set(blurf),
- ?line false = M:is_set(make_ref()),
- ?line false = M:is_set(<<1,2,3>>),
- ?line false = M:is_set(42),
- ?line false = M:is_set(math:pi()),
- ?line false = M:is_set({}),
- M:empty().
+ false = M(is_set, self()),
+ false = M(is_set, blurf),
+ false = M(is_set, make_ref()),
+ false = M(is_set, <<1,2,3>>),
+ false = M(is_set, 42),
+ false = M(is_set, math:pi()),
+ false = M(is_set, {}),
+ M(empty, []).
fold(Config) when is_list(Config) ->
test_all([{0,71},{125,129},{254,259},{510,513},{1023,1025},{9999,10001}],
fun fold_1/2).
fold_1(List, M) ->
- ?line S = M:from_list(List),
- ?line L = M:fold(fun(E, A) -> [E|A] end, [], S),
- ?line true = lists:sort(L) =:= lists:usort(List),
- M:empty().
+ S = M(from_list, List),
+ L = M(fold, {fun(E, A) -> [E|A] end,[],S}),
+ true = lists:sort(L) =:= lists:usort(List),
+ M(empty, []).
filter(Config) when is_list(Config) ->
test_all([{0,69},{126,130},{254,259},{510,513},{1023,1025},{7999,8000}],
fun filter_1/2).
filter_1(List, M) ->
- ?line S = M:from_list(List),
+ S = M(from_list, List),
IsNumber = fun(X) -> is_number(X) end,
- ?line M:equal(M:from_list(lists:filter(IsNumber, List)),
- M:filter(IsNumber, S)),
- ?line M:filter(fun(X) -> is_atom(X) end, S).
+ M(equal, {M(from_list, lists:filter(IsNumber, List)),
+ M(filter, {IsNumber,S})}),
+ M(filter, {fun(X) -> is_atom(X) end,S}).
%%%
%%% Test specifics for gb_sets.
@@ -375,26 +375,26 @@ take_smallest(Config) when is_list(Config) ->
fun take_smallest_1/2).
take_smallest_1(List, M) ->
- case M:module() of
+ case M(module, []) of
gb_sets -> take_smallest_2(List, M);
_ -> ok
end,
- M:empty().
+ M(empty, []).
take_smallest_2(List0, M) ->
- ?line List = lists:usort(List0),
- ?line S = M:from_list(List0),
+ List = lists:usort(List0),
+ S = M(from_list, List0),
take_smallest_3(S, List, M).
take_smallest_3(S0, List0, M) ->
- case M:is_empty(S0) of
+ case M(is_empty, S0) of
true -> ok;
false ->
- ?line Smallest = hd(List0),
- ?line Smallest = gb_sets:smallest(S0),
- ?line {Smallest,S} = gb_sets:take_smallest(S0),
- ?line List = tl(List0),
- ?line true = gb_sets:to_list(S) =:= List,
+ Smallest = hd(List0),
+ Smallest = gb_sets:smallest(S0),
+ {Smallest,S} = gb_sets:take_smallest(S0),
+ List = tl(List0),
+ true = gb_sets:to_list(S) =:= List,
take_smallest_3(S, List, M)
end.
@@ -403,26 +403,26 @@ take_largest(Config) when is_list(Config) ->
fun take_largest_1/2).
take_largest_1(List, M) ->
- case M:module() of
+ case M(module, []) of
gb_sets -> take_largest_2(List, M);
_ -> ok
end,
- M:empty().
+ M(empty, []).
take_largest_2(List0, M) ->
- ?line List = reverse(lists:usort(List0)),
- ?line S = M:from_list(List0),
+ List = reverse(lists:usort(List0)),
+ S = M(from_list, List0),
take_largest_3(S, List, M).
take_largest_3(S0, List0, M) ->
- case M:is_empty(S0) of
+ case M(is_empty, S0) of
true -> ok;
false ->
- ?line Largest = hd(List0),
- ?line Largest = gb_sets:largest(S0),
- ?line {Largest,S} = gb_sets:take_largest(S0),
- ?line List = tl(List0),
- ?line true = gb_sets:to_list(S) =:= reverse(List),
+ Largest = hd(List0),
+ Largest = gb_sets:largest(S0),
+ {Largest,S} = gb_sets:take_largest(S0),
+ List = tl(List0),
+ true = gb_sets:to_list(S) =:= reverse(List),
take_largest_3(S, List, M)
end.
@@ -441,23 +441,23 @@ sets_mods() ->
[Ordsets,Sets,Gb].
test_all(Tester) ->
- ?line Res = [begin
- random:seed(1, 2, 42),
- S = Tester(M),
- {M:size(S),lists:sort(M:to_list(S))}
- end || M <- sets_mods()],
- ?line all_same(Res).
+ Res = [begin
+ random:seed(1, 2, 42),
+ S = Tester(M),
+ {M(size, S),lists:sort(M(to_list, S))}
+ end || M <- sets_mods()],
+ all_same(Res).
test_all([{Low,High}|T], Tester) ->
test_all(lists:seq(Low, High)++T, Tester);
test_all([Sz|T], Tester) when is_integer(Sz) ->
List = rnd_list(Sz),
- ?line Res = [begin
+ Res = [begin
random:seed(19, 2, Sz),
S = Tester(List, M),
- {M:size(S),lists:sort(M:to_list(S))}
+ {M(size, S),lists:sort(M(to_list, S))}
end || M <- sets_mods()],
- ?line all_same(Res),
+ all_same(Res),
test_all(T, Tester);
test_all([], _) -> ok.
diff --git a/lib/stdlib/test/sets_test_lib.erl b/lib/stdlib/test/sets_test_lib.erl
index bdfb0d59d2..86f009a8f9 100644
--- a/lib/stdlib/test/sets_test_lib.erl
+++ b/lib/stdlib/test/sets_test_lib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2013. 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
@@ -17,91 +17,89 @@
%% %CopyrightEnd%
%%
--module(sets_test_lib, [Mod,Equal]).
-
--export([module/0,equal/2,empty/0,from_list/1,to_list/1,singleton/1,
- add_element/2,del_element/2,size/1,is_empty/1,is_set/1,
- intersection/1,intersection/2,subtract/2,
- union/1,union/2,is_subset/2,fold/3,filter/2]).
-
-module() ->
- Mod.
-
-equal(X, Y) ->
- Equal(X, Y).
-
-empty() ->
- Mod:new().
-
-from_list(L) ->
- Mod:from_list(L).
-
-to_list(S) ->
- Mod:to_list(S).
+-module(sets_test_lib).
+
+-export([new/2]).
+
+new(Mod, Eq) ->
+ fun (add_element, {El,S}) -> add_element(Mod, El, S);
+ (del_element, {El,S}) -> del_element(Mod, El, S);
+ (empty, []) -> Mod:new();
+ (equal, {S1,S2}) -> Eq(S1, S2);
+ (filter, {F,S}) -> filter(Mod, F, S);
+ (fold, {F,A,S}) -> fold(Mod, F, A, S);
+ (from_list, L) -> Mod:from_list(L);
+ (intersection, {S1,S2}) -> intersection(Mod, Eq, S1, S2);
+ (intersection, Ss) -> intersection(Mod, Eq, Ss);
+ (is_empty, S) -> is_empty(Mod, S);
+ (is_set, S) -> Mod:is_set(S);
+ (is_subset, {S,Set}) -> is_subset(Mod, Eq, S, Set);
+ (module, []) -> Mod;
+ (singleton, E) -> singleton(Mod, E);
+ (size, S) -> Mod:size(S);
+ (subtract, {S1,S2}) -> subtract(Mod, S1, S2);
+ (to_list, S) -> Mod:to_list(S);
+ (union, {S1,S2}) -> union(Mod, Eq, S1, S2);
+ (union, Ss) -> union(Mod, Eq, Ss)
+ end.
-singleton(E) ->
+singleton(Mod, E) ->
case erlang:function_exported(Mod, singleton, 1) of
true -> Mod:singleton(E);
- false -> from_list([E])
+ false -> Mod:from_list([E])
end.
-add_element(El, S0) ->
+add_element(Mod, El, S0) ->
S = Mod:add_element(El, S0),
true = Mod:is_element(El, S),
- false = is_empty(S),
+ false = is_empty(Mod, S),
true = Mod:is_set(S),
S.
-del_element(El, S0) ->
+del_element(Mod, El, S0) ->
S = Mod:del_element(El, S0),
false = Mod:is_element(El, S),
true = Mod:is_set(S),
S.
-size(S) ->
- Mod:size(S).
-
-is_empty(S) ->
+is_empty(Mod, S) ->
true = Mod:is_set(S),
case erlang:function_exported(Mod, is_empty, 1) of
true -> Mod:is_empty(S);
false -> Mod:size(S) == 0
end.
-is_set(S) ->
- Mod:is_set(S).
-
-intersection(S1, S2) ->
+intersection(Mod, Equal, S1, S2) ->
S = Mod:intersection(S1, S2),
true = Equal(S, Mod:intersection(S2, S1)),
- Disjoint = is_empty(S),
+ Disjoint = is_empty(Mod, S),
Disjoint = Mod:is_disjoint(S1, S2),
Disjoint = Mod:is_disjoint(S2, S1),
S.
-intersection(Ss) ->
+intersection(Mod, Equal, Ss) ->
S = Mod:intersection(Ss),
true = Equal(S, Mod:intersection(lists:reverse(Ss))),
S.
-subtract(S1, S2) ->
+subtract(Mod, S1, S2) ->
S = Mod:subtract(S1, S2),
true = Mod:is_set(S),
true = Mod:size(S) =< Mod:size(S1),
S.
-union(S1, S2) ->
+union(Mod, Equal, S1, S2) ->
S = Mod:union(S1, S2),
true = Equal(S, Mod:union(S2, S1)),
true = Mod:is_set(S),
S.
-union(Ss) ->
+union(Mod, Equal, Ss) ->
S = Mod:union(Ss),
true = Equal(S, Mod:union(lists:reverse(Ss))),
S.
-is_subset(S, Set) ->
+is_subset(Mod, Equal, S, Set) ->
case Mod:is_subset(S, Set) of
false -> false;
true ->
@@ -115,10 +113,10 @@ is_subset(S, Set) ->
true
end.
-fold(F, A, S) ->
+fold(Mod, F, A, S) ->
true = Mod:is_set(S),
Mod:fold(F, A, S).
-filter(F, S) ->
+filter(Mod, F, S) ->
true = Mod:is_set(S),
Mod:filter(F, S).
diff --git a/lib/stdlib/test/shell_SUITE.erl b/lib/stdlib/test/shell_SUITE.erl
index 4b83e42ee0..3c49aaa103 100644
--- a/lib/stdlib/test/shell_SUITE.erl
+++ b/lib/stdlib/test/shell_SUITE.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2013. 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
@@ -28,8 +29,8 @@
refman_bit_syntax/1,
progex_bit_syntax/1, progex_records/1,
progex_lc/1, progex_funs/1,
- otp_5990/1, otp_6166/1, otp_6554/1, otp_6785/1,
- otp_7184/1, otp_7232/1, otp_8393/1]).
+ otp_5990/1, otp_6166/1, otp_6554/1,
+ otp_7184/1, otp_7232/1, otp_8393/1, otp_10302/1]).
-export([ start_restricted_from_shell/1,
start_restricted_on_command_line/1,restricted_local/1]).
@@ -92,8 +93,8 @@ groups() ->
[progex_bit_syntax, progex_records, progex_lc,
progex_funs]},
{tickets, [],
- [otp_5990, otp_6166, otp_6554, otp_6785, otp_7184,
- otp_7232, otp_8393]}].
+ [otp_5990, otp_6166, otp_6554, otp_7184,
+ otp_7232, otp_8393, otp_10302]}].
init_per_suite(Config) ->
Config.
@@ -108,7 +109,7 @@ end_per_group(_GroupName, Config) ->
Config.
--record(state, {bin, reply, leader}).
+-record(state, {bin, reply, leader, unic = latin1}).
start_restricted_from_shell(doc) ->
@@ -122,7 +123,7 @@ start_restricted_from_shell(Config) when is_list(Config) ->
"test_restricted.erl"),
Contents = <<"-module(test_restricted).
-export([local_allowed/3, non_local_allowed/3]).
- local_allowed(i,[],State) ->
+ local_allowed(m,[],State) ->
{true,State};
local_allowed(ugly,[],_State) ->
non_conforming_reply;
@@ -146,7 +147,7 @@ start_restricted_from_shell(Config) when is_list(Config) ->
"test_restricted) end.">>),
?line {ok, test_restricted} =
application:get_env(stdlib, restricted_shell),
- ?line "Pid" ++ _ = t(<<"begin i() end.">>),
+ ?line "Module" ++ _ = t(<<"begin m() end.">>),
?line "exception exit: restricted shell does not allow c(foo)" =
comm_err(<<"begin c(foo) end.">>),
?line "exception exit: restricted shell does not allow init:stop()" =
@@ -199,9 +200,9 @@ start_restricted_on_command_line(Config) when is_list(Config) ->
"-pa "++?config(priv_dir,Config)++
" -stdlib restricted_shell foo"),
?line "Warning! Restricted shell module foo not found: nofile"++_ =
- t({Node, <<"begin i() end.">>}),
- ?line "exception exit: restricted shell does not allow i()" =
- comm_err({Node, <<"begin i() end.">>}),
+ t({Node, <<"begin m() end.">>}),
+ ?line "exception exit: restricted shell does not allow m()" =
+ comm_err({Node, <<"begin m() end.">>}),
?line [ok] =
(catch scan({Node, <<"begin q() end.">>})),
?line test_server:stop_node(Node),
@@ -209,7 +210,7 @@ start_restricted_on_command_line(Config) when is_list(Config) ->
"test_restricted2.erl"),
Contents = <<"-module(test_restricted2).
-export([local_allowed/3, non_local_allowed/3]).
- local_allowed(i,[],State) ->
+ local_allowed(m,[],State) ->
{true,State};
local_allowed(_,_,State) ->
{false,State}.
@@ -225,7 +226,7 @@ start_restricted_on_command_line(Config) when is_list(Config) ->
?line {ok,Node2} = start_node(shell_suite_helper_2,
"-pa "++?config(priv_dir,Config)++
" -stdlib restricted_shell test_restricted2"),
- ?line "Pid" ++ _ = t({Node2,<<"begin i() end.">>}),
+ ?line "Module" ++ _ = t({Node2,<<"begin m() end.">>}),
?line "exception exit: restricted shell does not allow c(foo)" =
comm_err({Node2,<<"begin c(foo) end.">>}),
?line "exception exit: restricted shell does not allow init:stop()" =
@@ -254,7 +255,7 @@ restricted_local(Config) when is_list(Config) ->
"test_restricted_local.erl"),
Contents = <<"-module(test_restricted_local).
-export([local_allowed/3, non_local_allowed/3]).
- local_allowed(i,[],State) ->
+ local_allowed(m,[],State) ->
{true,State};
local_allowed(banan,_,State) ->
{true,State};
@@ -374,15 +375,18 @@ records(Config) when is_list(Config) ->
MS = ?MODULE_STRING,
RR1 = "rr(" ++ MS ++ "). #state{}.",
?line "[state]\n"
- "#state{bin = undefined,reply = undefined,leader = undefined}.\n" =
+ "#state{bin = undefined,reply = undefined,leader = undefined,\n"
+ " unic = latin1}.\n" =
t(RR1),
RR2 = "rr(" ++ MS ++ ",[state]). #state{}.",
?line "[state]\n"
- "#state{bin = undefined,reply = undefined,leader = undefined}.\n" =
+ "#state{bin = undefined,reply = undefined,leader = undefined,\n"
+ " unic = latin1}.\n" =
t(RR2),
RR3 = "rr(" ++ MS ++ ",'_'). #state{}.",
?line "[state]\n"
- "#state{bin = undefined,reply = undefined,leader = undefined}.\n" =
+ "#state{bin = undefined,reply = undefined,leader = undefined,\n"
+ " unic = latin1}.\n" =
t(RR3),
RR4 = "rr(" ++ MS ++ ", '_', {d,test1}).",
?line [[state]] = scan(RR4),
@@ -817,9 +821,6 @@ otp_5916(Config) when is_list(Config) ->
true = if is_record(#r1{},r1,3) -> true; true -> false end,
false = if is_record(#r2{},r1,3) -> true; true -> false end,
- true = if {erlang,is_record}(#r1{},r1,3) -> true; true -> false end,
- false = if {erlang,is_record}(#r2{},r1,3) -> true; true -> false end,
-
ok.">>,
[ok] = scan(C),
ok.
@@ -2282,12 +2283,6 @@ otp_5990(doc) ->
otp_5990(suite) -> [];
otp_5990(Config) when is_list(Config) ->
?line [true] =
- scan(<<"rd(foo,{bar}), {erlang,is_record}(#foo{}, foo).">>),
- ?line [3] =
- scan(<<"rd(foo,{bar}), A = #foo{}, "
- "{if {erlang,is_record}(A, foo) -> erlang; "
- "true -> not_a_module end, length}([1,2,3]).">>),
- ?line [true] =
scan(<<"rd('OrdSet', {orddata = {},ordtype = type}), "
"S = #'OrdSet'{ordtype = {}}, "
"if tuple(S#'OrdSet'.ordtype) -> true; true -> false end.">>),
@@ -2549,19 +2544,6 @@ otp_6554(Config) when is_list(Config) ->
ok.
-otp_6785(doc) ->
- "OTP-6785. Parameterized modules.";
-otp_6785(suite) -> [];
-otp_6785(Config) when is_list(Config) ->
- MFile = filename:join(?config(priv_dir, Config), "parameterized.erl"),
- Contents = <<"-module(parameterized, [A]). "
- "-export([test/0]). "
- "test() -> A. ">>,
- ?line ok = compile_file(Config, MFile, Contents, []),
- ?line (parameterized:new(adsf)):test(),
- file:delete(MFile),
- ok.
-
otp_7184(doc) ->
"OTP-7184. Propagate exit signals from dying evaluator process.";
otp_7184(suite) -> [];
@@ -2757,6 +2739,149 @@ prompt_err(B) ->
S = string:strip(S2, both, $"),
string:strip(S, right, $.).
+otp_10302(doc) ->
+ "OTP-10302. Unicode.";
+otp_10302(suite) -> [];
+otp_10302(Config) when is_list(Config) ->
+ {ok,Node} = start_node(shell_suite_helper_2,
+ "-pa "++?config(priv_dir,Config)++
+ " +pc unicode"),
+ Test1 =
+ <<"begin
+ io:setopts([{encoding,utf8}]),
+ [1024] = \"\\x{400}\",
+ rd(rec, {a = \"\\x{400}\"}),
+ ok = rl(rec)
+ end.">>,
+ "-record(rec,{a = \"\x{400}\"}).\nok.\n" = t({Node,Test1}),
+
+ Test3 =
+ <<"io:setopts([{encoding,utf8}]).
+ rd(rec, {a = \"\\x{400}\"}).
+ ok = rp(#rec{}).">>,
+ "ok.\nrec\n#rec{a = \"\x{400}\"}.\nok.\n" = t({Node,Test3}),
+
+ Test4 =
+ <<"io:setopts([{encoding,utf8}]).
+ A = [1024] = \"\\x{400}\".
+ b().
+ h().">>,
+
+ "ok.\n\"\x{400}\"\nA = \"\x{400}\".\nok.\n"
+ "1: io:setopts([{encoding,utf8}])\n-> ok.\n"
+ "2: A = [1024] = \"\x{400}\"\n-> \"\x{400}\"\n"
+ "3: b()\n-> ok.\nok.\n" = t({Node,Test4}),
+
+ Test5 =
+ <<"begin
+ io:setopts([{encoding,utf8}]),
+ results(0),
+ A = [1024] = \"\\x{400}\",
+ b(),
+ h()
+ end.">>,
+ "A = \"\x{400}\".\nok.\n" = t({Node,Test5}),
+
+ %% One $" is "lost":
+ true =
+ "\x{400}\": command not found" =:=
+ prompt_err({Node,
+ <<"io:setopts([{encoding,utf8}]). v(\"\x{400}\")."/utf8>>,
+ unicode}),
+
+ "ok.\ndefault\n* Bad prompt function: \"\x{400}\".\n" =
+ t({Node,<<"io:setopts([{encoding,utf8}]). "
+ "shell:prompt_func(\"\x{400}\")."/utf8>>,
+ unicode}),
+ rpc:call(Node,shell, prompt_func, [default]),
+ _ = shell:prompt_func(default),
+
+ %% Test lib:format_exception() (cf. OTP-6554)
+ Test6 =
+ <<"begin
+ A = <<\"\\xaa\">>,
+ S = lists:flatten(io_lib:format(\"~p/~p.\", [A, A])),
+ {ok, Ts, _} = erl_scan:string(S, 1, [unicode]),
+ {ok, Es} = erl_parse:parse_exprs(Ts),
+ B = erl_eval:new_bindings(),
+ erl_eval:exprs(Es, B)
+ end.">>,
+
+ "** exception error: an error occurred when evaluating"
+ " an arithmetic expression\n in operator '/'/2\n"
+ " called as <<\"\xaa\">> / <<\"\xaa\">>.\n" = t(Test6),
+ Test7 =
+ <<"io:setopts([{encoding,utf8}]).
+ A = <<\"\\xaa\">>,
+ S = lists:flatten(io_lib:format(\"~p/~p.\", [A, A])),
+ {ok, Ts, _} = erl_scan:string(S, 1, [unicode]),
+ {ok, Es} = erl_parse:parse_exprs(Ts),
+ B = erl_eval:new_bindings(),
+ erl_eval:exprs(Es, B).">>,
+
+ "ok.\n** exception error: an error occurred when evaluating"
+ " an arithmetic expression\n in operator '/'/2\n"
+ " called as <<\"ª\">> / <<\"ª\">>.\n" = t({Node,Test7}),
+ Test8 =
+ <<"begin
+ A = [1089],
+ S = lists:flatten(io_lib:format(\"~tp/~tp.\", [A, A])),
+ {ok, Ts, _} = erl_scan:string(S, 1, [unicode]),
+ {ok, Es} = erl_parse:parse_exprs(Ts),
+ B = erl_eval:new_bindings(),
+ erl_eval:exprs(Es, B)
+ end.">>,
+ "** exception error: an error occurred when evaluating"
+ " an arithmetic expression\n in operator '/'/2\n"
+ " called as [1089] / [1089].\n" = t(Test8),
+ Test9 =
+ <<"io:setopts([{encoding,utf8}]).
+ A = [1089],
+ S = lists:flatten(io_lib:format(\"~tp/~tp.\", [A, A])),
+ {ok, Ts, _} = erl_scan:string(S, 1, [unicode]),
+ {ok, Es} = erl_parse:parse_exprs(Ts),
+ B = erl_eval:new_bindings(),
+ erl_eval:exprs(Es, B).">>,
+
+ "ok.\n** exception error: an error occurred when evaluating"
+ " an arithmetic expression\n in operator '/'/2\n"
+ " called as \"\x{441}\" / \"\x{441}\".\n" = t({Node,Test9}),
+ Test10 =
+ <<"A = {\"1\\xaa\",
+ $\\xaa,
+ << <<\"hi\">>/binary >>,
+ <<\"1\xaa\">>},
+ fun(a) -> true end(A).">>,
+ "** exception error: no function clause matching \n"
+ " erl_eval:'-inside-an-interpreted-fun-'"
+ "({\"1\xc2\xaa\",170,<<\"hi\">>,\n "
+ " <<\"1\xc2\xaa\">>}) .\n" = t(Test10),
+ Test11 =
+ <<"io:setopts([{encoding,utf8}]).
+ A = {\"1\\xaa\",
+ $\\xaa,
+ << <<\"hi\">>/binary >>,
+ <<\"1\xaa\">>},
+ fun(a) -> true end(A).">>,
+
+ "ok.\n** exception error: no function clause matching \n"
+ " erl_eval:'-inside-an-interpreted-fun-'"
+ "({\"1\xaa\",170,<<\"hi\">>,\n "
+ " <<\"1\xaa\"/utf8>>}) .\n" = t({Node,Test11}),
+ Test12 = <<"fun(a, b) -> false end(65, [1089]).">>,
+ "** exception error: no function clause matching \n"
+ " erl_eval:'-inside-an-interpreted-fun-'(65,[1089])"
+ " .\n" = t(Test12),
+ Test13 =
+ <<"io:setopts([{encoding,utf8}]).
+ fun(a, b) -> false end(65, [1089]).">>,
+ "ok.\n** exception error: no function clause matching \n"
+ " erl_eval:'-inside-an-interpreted-fun-'(65,\"\x{441}\")"
+ " .\n" = t({Node,Test13}),
+
+ test_server:stop_node(Node),
+ ok.
+
scan(B) ->
F = fun(Ts) ->
case erl_parse:parse_term(Ts) of
@@ -2770,37 +2895,46 @@ scan(B) ->
scan(t(B), F).
scan(S0, F) ->
- case erl_scan:tokens([], S0, 1) of
+ case erl_scan:tokens([], S0, 1, [unicode]) of
{done,{ok,Ts,_},S} ->
[F(Ts) | scan(S, F)];
_Else ->
[]
end.
+t({Node,Bin,Enc}) when is_atom(Node),is_binary(Bin), is_atom(Enc) ->
+ t0({Bin,Enc}, fun() -> start_new_shell(Node) end);
t({Node,Bin}) when is_atom(Node),is_binary(Bin) ->
- t0(Bin, fun() -> start_new_shell(Node) end);
+ t0({Bin,latin1}, fun() -> start_new_shell(Node) end);
t(Bin) when is_binary(Bin) ->
- t0(Bin, fun() -> start_new_shell() end);
+ t0({Bin,latin1}, fun() -> start_new_shell() end);
+t({Bin,Enc}) when is_binary(Bin), is_atom(Enc) ->
+ t0({Bin,Enc}, fun() -> start_new_shell() end);
t(L) ->
t(list_to_binary(L)).
-t0(Bin, F) ->
+t0({Bin,Enc}, F) ->
%% Spawn a process so that io_request messages do not interfer.
P = self(),
- C = spawn(fun() -> t1(P, Bin, F) end),
+ C = spawn(fun() -> t1(P, {Bin, Enc}, F) end),
receive {C, R} -> R end.
-t1(Parent, Bin, F) ->
- %% io:format("*** Testing ~s~n", [binary_to_list(Bin)]),
- S = #state{bin = Bin, reply = [], leader = group_leader()},
+t1(Parent, {Bin,Enc}, F) ->
+ io:format("*** Testing ~s~n", [binary_to_list(Bin)]),
+ S = #state{bin = Bin, unic = Enc, reply = [], leader = group_leader()},
group_leader(self(), self()),
_Shell = F(),
try
server_loop(S)
catch exit:R -> Parent ! {self(), R};
- throw:{?MODULE,LoopReply} ->
+ throw:{?MODULE,LoopReply,latin1} ->
L0 = binary_to_list(list_to_binary(LoopReply)),
[$\n | L1] = lists:dropwhile(fun(X) -> X =/= $\n end, L0),
+ Parent ! {self(), dotify(L1)};
+ throw:{?MODULE,LoopReply,_Uni} ->
+ Tmp = unicode:characters_to_binary(LoopReply),
+ L0 = unicode:characters_to_list(Tmp),
+ [$\n | L1] = lists:dropwhile(fun(X) -> X =/= $\n end, L0),
Parent ! {self(), dotify(L1)}
after group_leader(S#state.leader, self())
end.
@@ -2844,7 +2978,7 @@ do_io_request(Req, From, S, ReplyAs) ->
case io_requests([Req], [], S) of
{_Status,{eof,_},S1} ->
io_reply(From, ReplyAs, {error,terminated}),
- throw({?MODULE,S1#state.reply});
+ throw({?MODULE,S1#state.reply,S1#state.unic});
{_Status,Reply,S1} ->
io_reply(From, ReplyAs, Reply),
S1
@@ -2867,13 +3001,34 @@ io_requests([], [Rs|Cont], S) ->
io_requests([], [], S) ->
{ok,ok,S}.
+io_request({setopts, Opts}, S) ->
+ #state{unic = OldEnc, bin = Bin} = S,
+ NewEnc = case proplists:get_value(encoding, Opts) of
+ undefined -> OldEnc;
+ utf8 -> unicode;
+ New -> New
+ end,
+ NewBin = case {OldEnc, NewEnc} of
+ {E, E} -> Bin;
+ {latin1, _} ->
+ unicode:characters_to_binary(Bin, latin1, unicode);
+ {_, latin1} ->
+ unicode:characters_to_binary(Bin, unicode, latin1);
+ {_, _} -> Bin
+ end,
+ {ok, ok, S#state{unic = NewEnc, bin = NewBin}};
+io_request(getopts, S) ->
+ {ok,[{encoding,S#state.unic}],S};
io_request({get_geometry,columns}, S) ->
{ok,80,S};
io_request({get_geometry,rows}, S) ->
{ok,24,S};
io_request({put_chars,Chars}, S) ->
{ok,ok,S#state{reply = [S#state.reply | Chars]}};
-io_request({put_chars,_,Chars}, S) ->
+io_request({put_chars,latin1,Chars}, S) ->
+ {ok,ok,S#state{reply = [S#state.reply | Chars]}};
+io_request({put_chars,unicode,Chars0}, S) ->
+ Chars = unicode:characters_to_list(Chars0),
{ok,ok,S#state{reply = [S#state.reply | Chars]}};
io_request({put_chars,Mod,Func,Args}, S) ->
case catch apply(Mod, Func, Args) of
@@ -2899,9 +3054,12 @@ get_until_loop(M, F, As, S, {more,Cont}, Enc) ->
0 ->
get_until_loop(M, F, As, S,
catch apply(M, F, [Cont,eof|As]), Enc);
+ _ when S#state.unic =:= latin1 ->
+ get_until_loop(M, F, As, S#state{bin = <<>>},
+ catch apply(M, F, [Cont,binary_to_list(Bin)|As]), Enc);
_ ->
get_until_loop(M, F, As, S#state{bin = <<>>},
- catch apply(M, F, [Cont,binary_to_list(Bin)|As]), Enc)
+ catch apply(M, F, [Cont,unicode:characters_to_list(Bin)|As]), Enc)
end;
get_until_loop(_M, _F, _As, S, {done,Res,Buf}, Enc) ->
{ok,Res,S#state{bin = buf2bin(Buf, Enc)}};
@@ -2912,6 +3070,8 @@ buf2bin(eof,_) ->
<<>>;
buf2bin(Buf,latin1) ->
list_to_binary(Buf);
+buf2bin(Buf,utf8) ->
+ unicode:characters_to_binary(Buf,unicode,unicode);
buf2bin(Buf,unicode) ->
unicode:characters_to_binary(Buf,unicode,unicode).
diff --git a/lib/stdlib/test/stdlib.cover b/lib/stdlib/test/stdlib.cover
index 61f4f064b9..e71be880cb 100644
--- a/lib/stdlib/test/stdlib.cover
+++ b/lib/stdlib/test/stdlib.cover
@@ -1,17 +1,2 @@
%% -*- erlang -*-
{incl_app,stdlib,details}.
-
-{excl_mods,stdlib,
- [erl_parse,
- erl_eval,
- ets,
- filename,
- gen_event,
- gen_server,
- gen,
- lists,
- io,
- io_lib,
- io_lib_format,
- io_lib_pretty,
- proc_lib]}.
diff --git a/lib/stdlib/test/stdlib.spec.vxworks b/lib/stdlib/test/stdlib.spec.vxworks
deleted file mode 100644
index ddc804b831..0000000000
--- a/lib/stdlib/test/stdlib.spec.vxworks
+++ /dev/null
@@ -1,8 +0,0 @@
-{topcase, {dir, "../stdlib_test"}}.
-{skip,{dets_SUITE,"Not runnable VxWorks/NFS"}}.
-{skip,{slave_SUITE,"VxWorks: slave nodes are not supported"}}.
-{skip,{tar_SUITE,errors,"VxWorks filesystem too primitive"}}.
-{skip,{tar_SUITE,create_long_names,"VxWorks names too short"}}.
-{skip,{epp_SUITE,"Test not adopted to VxWorks"}}.
-{skip,{select_SUITE,"Test too memory consuming for VxWorks"}}.
-{skip,{beam_lib_SUITE,error,"All sections not present in stripped beam files"}}.
diff --git a/lib/stdlib/test/string_SUITE.erl b/lib/stdlib/test/string_SUITE.erl
index 6969c095a0..96e653985f 100644
--- a/lib/stdlib/test/string_SUITE.erl
+++ b/lib/stdlib/test/string_SUITE.erl
@@ -1,7 +1,8 @@
+%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2012. 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
@@ -473,8 +474,8 @@ to_upper_to_lower(suite) ->
to_upper_to_lower(doc) ->
[];
to_upper_to_lower(Config) when is_list(Config) ->
- ?line "1234ABCDEF���=" = string:to_upper("1234abcdef���="),
- ?line "����������abc()" = string:to_lower("����������abc()"),
+ ?line "1234ABCDEFÅÄÖ=" = string:to_upper("1234abcdefåäö="),
+ ?line "éèíúùòóåäöabc()" = string:to_lower("ÉÈÍÚÙÒÓÅÄÖabc()"),
?line All = lists:seq(0, 255),
?line UC = string:to_upper(All),
diff --git a/lib/stdlib/test/supervisor_3.erl b/lib/stdlib/test/supervisor_3.erl
new file mode 100644
index 0000000000..0023219ff3
--- /dev/null
+++ b/lib/stdlib/test/supervisor_3.erl
@@ -0,0 +1,45 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1996-2013. 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
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%% Description: Simulates the behaviour that a child process may have.
+%% Is used by the supervisor_SUITE test suite.
+-module(supervisor_3).
+
+-export([start_child/2, init/1]).
+
+-export([handle_call/3, handle_info/2, terminate/2]).
+
+start_child(Name, Caller) ->
+ gen_server:start_link(?MODULE, [Name, Caller], []).
+
+init([Name, Caller]) ->
+ Caller ! {Name, self()},
+ receive
+ {Result, Caller} ->
+ Result
+ end.
+
+handle_call(Req, _From, State) ->
+ {reply, Req, State}.
+
+handle_info(_, State) ->
+ {noreply, State}.
+
+terminate(_Reason, Time) ->
+ timer:sleep(Time),
+ ok.
diff --git a/lib/stdlib/test/supervisor_SUITE.erl b/lib/stdlib/test/supervisor_SUITE.erl
index 767ae3d62c..ac5a34c3bc 100644
--- a/lib/stdlib/test/supervisor_SUITE.erl
+++ b/lib/stdlib/test/supervisor_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. 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
@@ -46,15 +46,17 @@
temporary_normal/1,
permanent_shutdown/1, transient_shutdown/1,
temporary_shutdown/1,
+ faulty_application_shutdown/1,
permanent_abnormal/1, transient_abnormal/1,
temporary_abnormal/1, temporary_bystander/1]).
%% Restart strategy tests
-export([ one_for_one/1,
one_for_one_escalation/1, one_for_all/1,
- one_for_all_escalation/1,
+ one_for_all_escalation/1, one_for_all_other_child_fails_restart/1,
simple_one_for_one/1, simple_one_for_one_escalation/1,
rest_for_one/1, rest_for_one_escalation/1,
+ rest_for_one_other_child_fails_restart/1,
simple_one_for_one_extra/1, simple_one_for_one_shutdown/1]).
%% Misc tests
@@ -98,19 +100,22 @@ groups() ->
{normal_termination, [],
[permanent_normal, transient_normal, temporary_normal]},
{shutdown_termination, [],
- [permanent_shutdown, transient_shutdown, temporary_shutdown]},
+ [permanent_shutdown, transient_shutdown, temporary_shutdown,
+ faulty_application_shutdown]},
{abnormal_termination, [],
[permanent_abnormal, transient_abnormal,
temporary_abnormal]},
{restart_one_for_one, [],
[one_for_one, one_for_one_escalation]},
{restart_one_for_all, [],
- [one_for_all, one_for_all_escalation]},
+ [one_for_all, one_for_all_escalation,
+ one_for_all_other_child_fails_restart]},
{restart_simple_one_for_one, [],
[simple_one_for_one, simple_one_for_one_shutdown,
simple_one_for_one_extra, simple_one_for_one_escalation]},
{restart_rest_for_one, [],
- [rest_for_one, rest_for_one_escalation]}].
+ [rest_for_one, rest_for_one_escalation,
+ rest_for_one_other_child_fails_restart]}].
init_per_suite(Config) ->
Config.
@@ -659,6 +664,39 @@ temporary_shutdown(Config) when is_list(Config) ->
[0,0,0,0] = get_child_counts(sup_test).
%%-------------------------------------------------------------------------
+%% Faulty application should shutdown and pass on errors
+faulty_application_shutdown(Config) when is_list(Config) ->
+
+ %% Set some paths
+ AppDir = filename:join(?config(data_dir, Config), "app_faulty"),
+ EbinDir = filename:join(AppDir, "ebin"),
+
+ %% Start faulty app
+ code:add_patha(EbinDir),
+
+ %% {error,
+ %% {{shutdown,
+ %% {failed_to_start_child,
+ %% app_faulty,
+ %% {undef,
+ %% [{an_undefined_module_with,an_undefined_function,[argument1,argument2],
+ %% []},
+ %% {app_faulty_server,init,1,
+ %% [{file,"app_faulty/src/app_faulty_server.erl"},{line,16}]},
+ %% {gen_server,init_it,6,
+ %% [{file,"gen_server.erl"},{line,304}]},
+ %% {proc_lib,init_p_do_apply,3,
+ %% [{file,"proc_lib.erl"},{line,227}]}]}}},
+ %% {app_faulty,start,[normal,[]]}}}
+
+ {error, Error} = application:start(app_faulty),
+ {{shutdown, {failed_to_start_child,app_faulty,{undef, CallStack}}},
+ {app_faulty,start,_}} = Error,
+ [{an_undefined_module_with,an_undefined_function,_,_}|_] = CallStack,
+ ok = application:unload(app_faulty),
+ ok.
+
+%%-------------------------------------------------------------------------
%% A permanent child should always be restarted.
permanent_abnormal(Config) when is_list(Config) ->
{ok, SupPid} = start_link({ok, {{one_for_one, 2, 3600}, []}}),
@@ -844,6 +882,57 @@ one_for_all_escalation(Config) when is_list(Config) ->
%%-------------------------------------------------------------------------
+%% Test that the supervisor terminates a restarted child when a different
+%% child fails to start.
+one_for_all_other_child_fails_restart(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ Self = self(),
+ Child1 = {child1, {supervisor_3, start_child, [child1, Self]},
+ permanent, 1000, worker, []},
+ Child2 = {child2, {supervisor_3, start_child, [child2, Self]},
+ permanent, 1000, worker, []},
+ Children = [Child1, Child2],
+ StarterFun = fun() ->
+ {ok, SupPid} = start_link({ok, {{one_for_all, 3, 3600}, Children}}),
+ Self ! {sup_pid, SupPid},
+ receive {stop, Self} -> ok end
+ end,
+ StarterPid = spawn_link(StarterFun),
+ Ok = {{ok, undefined}, Self},
+ %% Let the children start.
+ Child1Pid = receive {child1, Pid1} -> Pid1 end,
+ Child1Pid ! Ok,
+ Child2Pid = receive {child2, Pid2} -> Pid2 end,
+ Child2Pid ! Ok,
+ %% Supervisor started.
+ SupPid = receive {sup_pid, Pid} -> Pid end,
+ link(SupPid),
+ exit(Child1Pid, die),
+ %% Let child1 restart but don't let child2.
+ Child1Pid2 = receive {child1, Pid3} -> Pid3 end,
+ Child1Pid2Ref = erlang:monitor(process, Child1Pid2),
+ Child1Pid2 ! Ok,
+ Child2Pid2 = receive {child2, Pid4} -> Pid4 end,
+ Child2Pid2 ! {{stop, normal}, Self},
+ %% Check child1 is terminated.
+ receive
+ {'DOWN', Child1Pid2Ref, _, _, shutdown} ->
+ ok;
+ {_childName, _Pid} ->
+ exit(SupPid, kill),
+ check_exit([StarterPid, SupPid]),
+ test_server:fail({restarting_child_not_terminated, Child1Pid2})
+ end,
+ %% Let the restart complete.
+ Child1Pid3 = receive {child1, Pid5} -> Pid5 end,
+ Child1Pid3 ! Ok,
+ Child2Pid3 = receive {child2, Pid6} -> Pid6 end,
+ Child2Pid3 ! Ok,
+ StarterPid ! {stop, Self},
+ check_exit([StarterPid, SupPid]).
+
+
+%%-------------------------------------------------------------------------
%% Test the simple_one_for_one base case.
simple_one_for_one(Config) when is_list(Config) ->
process_flag(trap_exit, true),
@@ -1009,6 +1098,52 @@ rest_for_one_escalation(Config) when is_list(Config) ->
terminate(SupPid, CPid1, child1, abnormal),
check_exit([CPid2, SupPid]).
+
+%%-------------------------------------------------------------------------
+%% Test that the supervisor terminates a restarted child when a different
+%% child fails to start.
+rest_for_one_other_child_fails_restart(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ Self = self(),
+ Child1 = {child1, {supervisor_3, start_child, [child1, Self]},
+ permanent, 1000, worker, []},
+ Child2 = {child2, {supervisor_3, start_child, [child2, Self]},
+ permanent, 1000, worker, []},
+ Children = [Child1, Child2],
+ StarterFun = fun() ->
+ {ok, SupPid} = start_link({ok, {{rest_for_one, 3, 3600}, Children}}),
+ Self ! {sup_pid, SupPid},
+ receive {stop, Self} -> ok end
+ end,
+ StarterPid = spawn_link(StarterFun),
+ Ok = {{ok, undefined}, Self},
+ %% Let the children start.
+ Child1Pid = receive {child1, Pid1} -> Pid1 end,
+ Child1Pid ! Ok,
+ Child2Pid = receive {child2, Pid2} -> Pid2 end,
+ Child2Pid ! Ok,
+ %% Supervisor started.
+ SupPid = receive {sup_pid, Pid} -> Pid end,
+ link(SupPid),
+ exit(Child1Pid, die),
+ %% Let child1 restart but don't let child2.
+ Child1Pid2 = receive {child1, Pid3} -> Pid3 end,
+ Child1Pid2 ! Ok,
+ Child2Pid2 = receive {child2, Pid4} -> Pid4 end,
+ Child2Pid2 ! {{stop, normal}, Self},
+ %% Let child2 restart.
+ receive
+ {child2, Child2Pid3} ->
+ Child2Pid3 ! Ok;
+ {child1, _Child1Pid3} ->
+ exit(SupPid, kill),
+ check_exit([StarterPid, SupPid]),
+ test_server:fail({restarting_started_child, Child1Pid2})
+ end,
+ StarterPid ! {stop, Self},
+ check_exit([StarterPid, SupPid]).
+
+
%%-------------------------------------------------------------------------
%% Test that the supervisor does not hang forever if the child unliks
%% and then is terminated by the supervisor.
diff --git a/lib/stdlib/test/supervisor_SUITE_data/Makefile.src b/lib/stdlib/test/supervisor_SUITE_data/Makefile.src
new file mode 100644
index 0000000000..dbc5729f47
--- /dev/null
+++ b/lib/stdlib/test/supervisor_SUITE_data/Makefile.src
@@ -0,0 +1,15 @@
+EFLAGS=+debug_info
+
+APP_FAULTY= \
+ app_faulty/ebin/app_faulty_sup.@EMULATOR@ \
+ app_faulty/ebin/app_faulty_server.@EMULATOR@ \
+ app_faulty/ebin/app_faulty.@EMULATOR@ \
+
+all: $(APP_FAULTY)
+
+app_faulty/ebin/app_faulty_server.@EMULATOR@: app_faulty/src/app_faulty_server.erl
+ erlc $(EFLAGS) -oapp_faulty/ebin app_faulty/src/app_faulty_server.erl
+app_faulty/ebin/app_faulty_sup.@EMULATOR@: app_faulty/src/app_faulty_sup.erl
+ erlc $(EFLAGS) -oapp_faulty/ebin app_faulty/src/app_faulty_sup.erl
+app_faulty/ebin/app_faulty.@EMULATOR@: app_faulty/src/app_faulty.erl
+ erlc $(EFLAGS) -oapp_faulty/ebin app_faulty/src/app_faulty.erl
diff --git a/lib/stdlib/test/supervisor_SUITE_data/app_faulty/ebin/app_faulty.app b/lib/stdlib/test/supervisor_SUITE_data/app_faulty/ebin/app_faulty.app
new file mode 100644
index 0000000000..d4ab07e485
--- /dev/null
+++ b/lib/stdlib/test/supervisor_SUITE_data/app_faulty/ebin/app_faulty.app
@@ -0,0 +1,10 @@
+{application, app_faulty,
+ [{description, "very simple example faulty application"},
+ {id, "app_faulty"},
+ {vsn, "1.0"},
+ {modules, [app_faulty, app_faulty_sup, app_faulty_server]},
+ {registered, [app_faulty]},
+ {applications, [kernel, stdlib]},
+ {env, [{var,val1}]},
+ {mod, {app_faulty, []}}
+ ]}.
diff --git a/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty.erl b/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty.erl
new file mode 100644
index 0000000000..c65b411cd6
--- /dev/null
+++ b/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty.erl
@@ -0,0 +1,17 @@
+-module(app_faulty).
+
+-behaviour(application).
+
+%% Application callbacks
+-export([start/2, stop/1]).
+
+start(_Type, _StartArgs) ->
+ case app_faulty_sup:start_link() of
+ {ok, Pid} ->
+ {ok, Pid};
+ Error ->
+ Error
+ end.
+
+stop(_State) ->
+ ok.
diff --git a/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty_server.erl b/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty_server.erl
new file mode 100644
index 0000000000..6628f92210
--- /dev/null
+++ b/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty_server.erl
@@ -0,0 +1,32 @@
+-module(app_faulty_server).
+
+-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]).
+
+start_link() ->
+ gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+
+init([]) ->
+ an_undefined_module_with:an_undefined_function(argument1, argument2),
+ {ok, []}.
+
+handle_call(_Request, _From, State) ->
+ {reply, ok, State}.
+
+handle_cast(_Msg, State) ->
+ {noreply, State}.
+
+handle_info(_Info, State) ->
+ {noreply, State}.
+
+terminate(_Reason, _State) ->
+ ok.
+
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
diff --git a/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty_sup.erl b/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty_sup.erl
new file mode 100644
index 0000000000..8115a88809
--- /dev/null
+++ b/lib/stdlib/test/supervisor_SUITE_data/app_faulty/src/app_faulty_sup.erl
@@ -0,0 +1,17 @@
+-module(app_faulty_sup).
+
+-behaviour(supervisor).
+
+%% API
+-export([start_link/0]).
+
+%% Supervisor callbacks
+-export([init/1]).
+
+start_link() ->
+ supervisor:start_link(?MODULE, []).
+
+init([]) ->
+ AChild = {app_faulty,{app_faulty_server,start_link,[]},
+ permanent,2000,worker,[app_faulty_server]},
+ {ok,{{one_for_all,0,1}, [AChild]}}.
diff --git a/lib/stdlib/test/sys_SUITE.erl b/lib/stdlib/test/sys_SUITE.erl
index fe039e8bcc..c06ba545e7 100644
--- a/lib/stdlib/test/sys_SUITE.erl
+++ b/lib/stdlib/test/sys_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. 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
@@ -56,70 +56,60 @@ end_per_group(_GroupName, Config) ->
log(suite) -> [];
log(Config) when is_list(Config) ->
- ?line {ok,_Server} = start(),
- ?line ok = sys:log(?server,true),
- ?line {ok,-44} = public_call(44),
- ?line ok = sys:log(?server,false),
- ?line ok = sys:log(?server,print),
- ?line stop(),
+ {ok,_Server} = start(),
+ ok = sys:log(?server,true),
+ {ok,-44} = public_call(44),
+ ok = sys:log(?server,false),
+ ok = sys:log(?server,print),
+ stop(),
ok.
log_to_file(suite) -> [];
log_to_file(Config) when is_list(Config) ->
TempName = test_server:temp_name(?config(priv_dir,Config) ++ "sys."),
- ?line {ok,_Server} = start(),
- ?line ok = sys:log_to_file(?server,TempName),
- ?line {ok,-44} = public_call(44),
- ?line ok = sys:log_to_file(?server,false),
- ?line {ok,Fd} = file:open(TempName,[read]),
- ?line Msg1 = io:get_line(Fd,''),
- ?line Msg2 = io:get_line(Fd,''),
- ?line file:close(Fd),
- ?line lists:prefix("*DBG* sys_SUITE_server got call {req,44} from ",Msg1),
- ?line lists:prefix("*DBG* sys_SUITE_server sent {ok,-44} to ",Msg2),
- ?line stop(),
+ {ok,_Server} = start(),
+ ok = sys:log_to_file(?server,TempName),
+ {ok,-44} = public_call(44),
+ ok = sys:log_to_file(?server,false),
+ {ok,Fd} = file:open(TempName,[read]),
+ Msg1 = io:get_line(Fd,''),
+ Msg2 = io:get_line(Fd,''),
+ file:close(Fd),
+ lists:prefix("*DBG* sys_SUITE_server got call {req,44} from ",Msg1),
+ lists:prefix("*DBG* sys_SUITE_server sent {ok,-44} to ",Msg2),
+ stop(),
ok.
stats(suite) -> [];
stats(Config) when is_list(Config) ->
- ?line Self = self(),
- ?line {ok,_Server} = start(),
- ?line ok = sys:statistics(?server,true),
- ?line {ok,-44} = public_call(44),
- ?line {ok,Stats} = sys:statistics(?server,get),
- ?line lists:member({messages_in,1},Stats),
- ?line lists:member({messages_out,1},Stats),
- ?line ok = sys:statistics(?server,false),
- ?line {status,_Pid,{module,_Mod},[_PDict,running,Self,_,_]} =
+ Self = self(),
+ {ok,_Server} = start(),
+ ok = sys:statistics(?server,true),
+ {ok,-44} = public_call(44),
+ {ok,Stats} = sys:statistics(?server,get),
+ lists:member({messages_in,1},Stats),
+ lists:member({messages_out,1},Stats),
+ ok = sys:statistics(?server,false),
+ {status,_Pid,{module,_Mod},[_PDict,running,Self,_,_]} =
sys:get_status(?server),
- ?line {ok,no_statistics} = sys:statistics(?server,get),
- ?line stop(),
+ {ok,no_statistics} = sys:statistics(?server,get),
+ stop(),
ok.
trace(suite) -> [];
trace(Config) when is_list(Config) ->
- ?line {ok,_Server} = start(),
- case os:type() of
- vxworks ->
- ?line test_server:sleep(20000);
- _ ->
- ?line test_server:sleep(2000)
- end,
- ?line test_server:capture_start(),
- ?line sys:trace(?server,true),
- ?line {ok,-44} = public_call(44),
+ {ok,_Server} = start(),
+ test_server:sleep(2000),
+ test_server:capture_start(),
+ sys:trace(?server,true),
+ {ok,-44} = public_call(44),
%% ho, hum, allow for the io to reach us..
- case os:type() of
- vxworks ->
- ?line test_server:sleep(10000);
- _ ->
- ?line test_server:sleep(1000)
- end,
- ?line test_server:capture_stop(),
- ?line [Msg1,Msg2] = test_server:capture_get(),
- ?line lists:prefix("*DBG* sys_SUITE_server got call {req,44} from ",Msg1),
- ?line lists:prefix("*DBG* sys_SUITE_server sent {ok,-44} to ",Msg2),
- ?line stop(),
+ test_server:sleep(1000),
+ test_server:capture_stop(),
+ [Msg1,Msg2] = test_server:capture_get(),
+ lists:prefix("*DBG* sys_SUITE_server got call {req,44} from ",Msg1),
+ lists:prefix("*DBG* sys_SUITE_server sent {ok,-44} to ",Msg2),
+ stop(),
ok.
suspend(suite) -> [];
diff --git a/lib/stdlib/test/timer_SUITE.erl b/lib/stdlib/test/timer_SUITE.erl
index f84c72b0f8..bea2b3fb2a 100644
--- a/lib/stdlib/test/timer_SUITE.erl
+++ b/lib/stdlib/test/timer_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. 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
@@ -32,7 +32,6 @@
%% functions I guess. But I don't have time for that now.
%%
%% Expect it to run for at least 5-10 minutes!
-%% Except for VxWorks of course, where a couple of hours is more apropriate...
%% The main test case in this module is "do_big_test", which
@@ -77,12 +76,7 @@ end_per_group(_GroupName, Config) ->
do_big_test(TConfig) when is_list(TConfig) ->
Dog = ?t:timetrap(?t:minutes(20)),
Save = process_flag(trap_exit, true),
- Result = case os:type() of
- vxworks ->
- big_test(10);
- _ ->
- big_test(200)
- end,
+ Result = big_test(200),
process_flag(trap_exit, Save),
?t:timetrap_cancel(Dog),
report_result(Result).
diff --git a/lib/stdlib/test/unicode_SUITE.erl b/lib/stdlib/test/unicode_SUITE.erl
index 4055af2741..e2d789bbe6 100644
--- a/lib/stdlib/test/unicode_SUITE.erl
+++ b/lib/stdlib/test/unicode_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2013. 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
@@ -29,7 +29,7 @@
random_lists/1,
roundtrips/1,
latin1/1,
- exceptions/1]).
+ exceptions/1, binaries_errors/1]).
init_per_testcase(Case, Config) when is_atom(Case), is_list(Config) ->
Dog=?t:timetrap(?t:minutes(20)),
@@ -44,7 +44,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[utf8_illegal_sequences_bif,
utf16_illegal_sequences_bif, random_lists, roundtrips,
- latin1, exceptions].
+ latin1, exceptions, binaries_errors].
groups() ->
[].
@@ -61,6 +61,149 @@ init_per_group(_GroupName, Config) ->
end_per_group(_GroupName, Config) ->
Config.
+binaries_errors(Config) when is_list(Config) ->
+ setlimit(10),
+ ex_binaries_errors_utf8(Config),
+ setlimit(default),
+ ex_binaries_errors_utf8(Config),
+ ex_binaries_errors_utf16_little(Config),
+ ex_binaries_errors_utf16_big(Config),
+ ex_binaries_errors_utf32_little(Config),
+ ex_binaries_errors_utf32_big(Config).
+
+ex_binaries_errors_utf8(Config) when is_list(Config) ->
+ %% Original smoke test, we should not forget the original offset...
+ <<_:8,_:8,RR2/binary>> = <<$a,$b,164,165,$c>>,
+ {error,[],<<164,165,$c>>} = unicode:characters_to_list(RR2),
+ %% Now, try with longer binary (trapping)
+ BrokenPart = list_to_binary(lists:seq(128,255)),
+ BrokenSz = byte_size(BrokenPart),
+ [ begin
+ OKList = lists:flatten(lists:duplicate(N,lists:seq(1,255))),
+ OKBin = unicode:characters_to_binary(OKList),
+ OKLen = length(OKList),
+ %% Copy to avoid that the binary get's writable
+ PartlyBroken = binary:copy(<<OKBin/binary, BrokenPart/binary>>),
+ PBSz = byte_size(PartlyBroken),
+ {error,OKList,DeepBrokenPart} =
+ unicode:characters_to_list(PartlyBroken),
+ BrokenPart = iolist_to_binary(DeepBrokenPart),
+ [ begin
+ NewList = lists:nthtail(X, OKList),
+ NewSz = byte_size(unicode:characters_to_binary(NewList)) +
+ BrokenSz,
+ Chomped = binary:part(PartlyBroken,PBSz - NewSz, NewSz),
+ true = (binary:referenced_byte_size(Chomped) =:= PBSz),
+ {error,NewList,DeepBrokenPart2} =
+ unicode:characters_to_list(Chomped),
+ BrokenPart = iolist_to_binary(DeepBrokenPart2)
+ end || X <- lists:seq(1,OKLen) ]
+ end || N <- lists:seq(1,20) ],
+ ok.
+
+ex_binaries_errors_utf16_little(Config) when is_list(Config) ->
+ BrokenPart = << <<X:16/little>> || X <- lists:seq(16#DC00,16#DFFF) >>,
+ BrokenSz = byte_size(BrokenPart),
+ [ begin
+ OKList = lists:flatten(lists:duplicate(N,lists:seq(1,255))),
+ OKBin = unicode:characters_to_binary(OKList,unicode,{utf16,little}),
+ OKLen = length(OKList),
+ %% Copy to avoid that the binary get's writable
+ PartlyBroken = binary:copy(<<OKBin/binary, BrokenPart/binary>>),
+ PBSz = byte_size(PartlyBroken),
+ {error,OKList,DeepBrokenPart} =
+ unicode:characters_to_list(PartlyBroken,{utf16,little}),
+ BrokenPart = iolist_to_binary(DeepBrokenPart),
+ [ begin
+ NewList = lists:nthtail(X, OKList),
+ NewSz = byte_size(unicode:characters_to_binary(NewList,unicode,{utf16,little})) +
+ BrokenSz,
+ Chomped = binary:part(PartlyBroken,PBSz - NewSz, NewSz),
+ true = (binary:referenced_byte_size(Chomped) =:= PBSz),
+ {error,NewList,DeepBrokenPart2} =
+ unicode:characters_to_list(Chomped,{utf16,little}),
+ BrokenPart = iolist_to_binary(DeepBrokenPart2)
+ end || X <- lists:seq(1,OKLen) ]
+ end || N <- lists:seq(1,15) ],
+ ok.
+ex_binaries_errors_utf16_big(Config) when is_list(Config) ->
+ BrokenPart = << <<X:16/big>> || X <- lists:seq(16#DC00,16#DFFF) >>,
+ BrokenSz = byte_size(BrokenPart),
+ [ begin
+ OKList = lists:flatten(lists:duplicate(N,lists:seq(1,255))),
+ OKBin = unicode:characters_to_binary(OKList,unicode,{utf16,big}),
+ OKLen = length(OKList),
+ %% Copy to avoid that the binary get's writable
+ PartlyBroken = binary:copy(<<OKBin/binary, BrokenPart/binary>>),
+ PBSz = byte_size(PartlyBroken),
+ {error,OKList,DeepBrokenPart} =
+ unicode:characters_to_list(PartlyBroken,{utf16,big}),
+ BrokenPart = iolist_to_binary(DeepBrokenPart),
+ [ begin
+ NewList = lists:nthtail(X, OKList),
+ NewSz = byte_size(unicode:characters_to_binary(NewList,unicode,{utf16,big})) +
+ BrokenSz,
+ Chomped = binary:part(PartlyBroken,PBSz - NewSz, NewSz),
+ true = (binary:referenced_byte_size(Chomped) =:= PBSz),
+ {error,NewList,DeepBrokenPart2} =
+ unicode:characters_to_list(Chomped,{utf16,big}),
+ BrokenPart = iolist_to_binary(DeepBrokenPart2)
+ end || X <- lists:seq(1,OKLen) ]
+ end || N <- lists:seq(1,15) ],
+ ok.
+
+ex_binaries_errors_utf32_big(Config) when is_list(Config) ->
+ BrokenPart = << <<X:32/big>> || X <- lists:seq(16#DC00,16#DFFF) >>,
+ BrokenSz = byte_size(BrokenPart),
+ [ begin
+ OKList = lists:flatten(lists:duplicate(N,lists:seq(1,255))),
+ OKBin = unicode:characters_to_binary(OKList,unicode,{utf32,big}),
+ OKLen = length(OKList),
+ %% Copy to avoid that the binary get's writable
+ PartlyBroken = binary:copy(<<OKBin/binary, BrokenPart/binary>>),
+ PBSz = byte_size(PartlyBroken),
+ {error,OKList,DeepBrokenPart} =
+ unicode:characters_to_list(PartlyBroken,{utf32,big}),
+ BrokenPart = iolist_to_binary(DeepBrokenPart),
+ [ begin
+ NewList = lists:nthtail(X, OKList),
+ NewSz = byte_size(unicode:characters_to_binary(NewList,unicode,{utf32,big})) +
+ BrokenSz,
+ Chomped = binary:part(PartlyBroken,PBSz - NewSz, NewSz),
+ true = (binary:referenced_byte_size(Chomped) =:= PBSz),
+ {error,NewList,DeepBrokenPart2} =
+ unicode:characters_to_list(Chomped,{utf32,big}),
+ BrokenPart = iolist_to_binary(DeepBrokenPart2)
+ end || X <- lists:seq(1,OKLen) ]
+ end || N <- lists:seq(1,15) ],
+ ok.
+
+ex_binaries_errors_utf32_little(Config) when is_list(Config) ->
+ BrokenPart = << <<X:32/little>> || X <- lists:seq(16#DC00,16#DFFF) >>,
+ BrokenSz = byte_size(BrokenPart),
+ [ begin
+ OKList = lists:flatten(lists:duplicate(N,lists:seq(1,255))),
+ OKBin = unicode:characters_to_binary(OKList,unicode,{utf32,little}),
+ OKLen = length(OKList),
+ %% Copy to avoid that the binary get's writable
+ PartlyBroken = binary:copy(<<OKBin/binary, BrokenPart/binary>>),
+ PBSz = byte_size(PartlyBroken),
+ {error,OKList,DeepBrokenPart} =
+ unicode:characters_to_list(PartlyBroken,{utf32,little}),
+ BrokenPart = iolist_to_binary(DeepBrokenPart),
+ [ begin
+ NewList = lists:nthtail(X, OKList),
+ NewSz = byte_size(unicode:characters_to_binary(NewList,unicode,{utf32,little})) +
+ BrokenSz,
+ Chomped = binary:part(PartlyBroken,PBSz - NewSz, NewSz),
+ true = (binary:referenced_byte_size(Chomped) =:= PBSz),
+ {error,NewList,DeepBrokenPart2} =
+ unicode:characters_to_list(Chomped,{utf32,little}),
+ BrokenPart = iolist_to_binary(DeepBrokenPart2)
+ end || X <- lists:seq(1,OKLen) ]
+ end || N <- lists:seq(1,15) ],
+ ok.
+
exceptions(Config) when is_list(Config) ->
diff --git a/lib/stdlib/test/zip_SUITE.erl b/lib/stdlib/test/zip_SUITE.erl
index 7233c061ef..a57641ef62 100644
--- a/lib/stdlib/test/zip_SUITE.erl
+++ b/lib/stdlib/test/zip_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2013. 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
@@ -109,13 +109,32 @@ borderline_test(Size, TempDir) ->
ok.
unzip_list(Archive, Name) ->
- case os:find_executable("unzip") of
- Unzip when is_list(Unzip) ->
+ case unix_unzip_exists() of
+ true ->
unzip_list1(Archive, Name);
_ ->
ok
end.
+%% Used to do os:find_executable() to check if unzip exists, but on
+%% some hosts that would give an unzip program which did not take the
+%% "-Z" option.
+%% Here we check that "unzip -Z" (which should display usage) and
+%% check that it exists with status 0.
+unix_unzip_exists() ->
+ case os:type() of
+ {unix,_} ->
+ Port = open_port({spawn,"unzip -Z > /dev/null"}, [exit_status]),
+ receive
+ {Port,{exit_status,0}} ->
+ true;
+ {Port,{exit_status,_Fail}} ->
+ false
+ end;
+ _ ->
+ false
+ end.
+
unzip_list1(Archive, Name) ->
Expect = Name ++ "\n",
cmd_expect("unzip -Z -1 " ++ Archive, Expect).