From 2ca6b53da655b4c1377e8ddb818ce70c71e3538e Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Wed, 14 Jun 2017 13:16:47 +0200 Subject: stdlib: Modify handling of Unicode in proc_lib --- lib/stdlib/test/proc_lib_SUITE.erl | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'lib/stdlib/test') diff --git a/lib/stdlib/test/proc_lib_SUITE.erl b/lib/stdlib/test/proc_lib_SUITE.erl index c4fafe82a4..7686889360 100644 --- a/lib/stdlib/test/proc_lib_SUITE.erl +++ b/lib/stdlib/test/proc_lib_SUITE.erl @@ -552,14 +552,17 @@ t_format(_Config) -> t_format() -> error_logger:add_report_handler(?MODULE, self()), - Pid = proc_lib:spawn(fun t_format_looper/0), + Pid = proc_lib:spawn(fun '\x{aaa}t_format_looper'/0), HugeData = gb_sets:from_list(lists:seq(1, 100)), - Pid ! {die,HugeData}, + SomeData1 = list_to_atom([246]), + SomeData2 = list_to_atom([1024]), + Pid ! {SomeData1,SomeData2}, + Pid ! {die,{HugeData,SomeData1,SomeData2}}, Report = receive {crash_report, Pid, Report0} -> Report0 end, - Usz = do_test_format(Report, unlimited), - Tsz = do_test_format(Report, 20), + Usz = do_test_format(Report, latin1, unlimited), + Tsz = do_test_format(Report, latin1, 20), if Tsz >= Usz -> @@ -568,6 +571,16 @@ t_format() -> ok end, + UszU = do_test_format(Report, unicode, unlimited), + TszU = do_test_format(Report, unicode, 20), + + if + TszU >= UszU -> + ct:fail(failed); + true -> + ok + end, + ok. t_format_arbitrary(_Config) -> @@ -597,15 +610,19 @@ do_test_format(Report, Encoding, Depth) -> io:format("*** Depth = ~p, Encoding = ~p", [Depth, Encoding]), S0 = proc_lib:format(Report, Encoding, Depth), S = lists:flatten(S0), - io:put_chars(S), + case Encoding of + latin1 -> io:format("~s\n", [S]); + _ -> io:format("~ts\n", [S]) + end, length(S). -t_format_looper() -> +'\x{aaa}t_format_looper'() -> receive {die,Data} -> exit(Data); - _ -> - t_format_looper() + M -> + put(M, M), + '\x{aaa}t_format_looper'() end. %%----------------------------------------------------------------- -- cgit v1.2.3 From d9e56433f0aff84cae516486fdd7043de38f23fe Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Tue, 20 Jun 2017 12:27:35 +0200 Subject: stdlib: Improve handling of Unicode in edlin_expand --- lib/stdlib/test/Makefile | 1 + lib/stdlib/test/edlin_expand_SUITE.erl | 26 ++++++++++++++++++++++-- lib/stdlib/test/unicode_expand.erl | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 lib/stdlib/test/unicode_expand.erl (limited to 'lib/stdlib/test') diff --git a/lib/stdlib/test/Makefile b/lib/stdlib/test/Makefile index 72211332e9..7b79dcf04d 100644 --- a/lib/stdlib/test/Makefile +++ b/lib/stdlib/test/Makefile @@ -36,6 +36,7 @@ MODULES= \ ets_tough_SUITE \ expand_test \ expand_test1 \ + unicode_expand \ ExpandTestCaps \ ExpandTestCaps1 \ filelib_SUITE \ diff --git a/lib/stdlib/test/edlin_expand_SUITE.erl b/lib/stdlib/test/edlin_expand_SUITE.erl index 1f694ea549..5c2b1965ba 100644 --- a/lib/stdlib/test/edlin_expand_SUITE.erl +++ b/lib/stdlib/test/edlin_expand_SUITE.erl @@ -22,7 +22,7 @@ init_per_testcase/2, end_per_testcase/2, init_per_group/2,end_per_group/2]). -export([normal/1, quoted_fun/1, quoted_module/1, quoted_both/1, erl_1152/1, - erl_352/1]). + erl_352/1, unicode/1]). -include_lib("common_test/include/ct.hrl"). @@ -37,7 +37,8 @@ suite() -> {timetrap,{minutes,1}}]. all() -> - [normal, quoted_fun, quoted_module, quoted_both, erl_1152, erl_352]. + [normal, quoted_fun, quoted_module, quoted_both, erl_1152, erl_352, + unicode]. groups() -> []. @@ -150,6 +151,7 @@ quoted_both(Config) when is_list(Config) -> {yes,"weird-fun-name'()",[]} = do_expand("'ExpandTestCaps1':'#"), ok. +%% Note: pull request #1152. erl_1152(Config) when is_list(Config) -> "\n"++"foo"++" "++[1089]++_ = do_format(["foo",[1089]]), ok. @@ -226,6 +228,26 @@ check_trailing([I|Str], ArityStr, Suffix, Dots) -> Rest =:= Suffix end. +unicode(Config) when is_list(Config) -> + {module,unicode_expand} = c:l('unicode_expand'), + {no,[],[{"'кlирилли́ческий атом'",0}, + {"'кlирилли́ческий атом'",1}, + {"'кlирилли́ческий атомB'",1}, + {"module_info",0}, + {"module_info",1}]} = do_expand("unicode_expand:"), + {yes,"рилли́ческий атом", []} = do_expand("unicode_expand:'кlи"), + {yes,"еский атом", []} = do_expand("unicode_expand:'кlирилли́ч"), + {yes,"(",[]} = do_expand("unicode_expand:'кlирилли́ческий атомB'"), + "\n'кlирилли́ческий атом'/0 'кlирилли́ческий атом'/1 " + "'кlирилли́ческий атомB'/1 \nmodule_info/0 " + "module_info/1 \n" = + do_format([{"'кlирилли́ческий атом'",0}, + {"'кlирилли́ческий атом'",1}, + {"'кlирилли́ческий атомB'",1}, + {"module_info",0}, + {"module_info",1}]), + ok. + do_expand(String) -> edlin_expand:expand(lists:reverse(String)). diff --git a/lib/stdlib/test/unicode_expand.erl b/lib/stdlib/test/unicode_expand.erl new file mode 100644 index 0000000000..41f741fa84 --- /dev/null +++ b/lib/stdlib/test/unicode_expand.erl @@ -0,0 +1,36 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2017. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% +-module(unicode_expand). + +-export(['кlирилли́ческий атом'/0, 'кlирилли́ческий атом'/1, + 'кlирилли́ческий атомB'/1]). + +-export_type(['кlирилли́ческий атом'/0]). + +-type 'кlирилли́ческий атом'() :: integer(). + +'кlирилли́ческий атом'() -> + 'кlирилли́ческий атом'('кlирилли́ческий атом'). + +'кlирилли́ческий атом'(_Atom) -> + ok. + +'кlирилли́ческий атомB'(_B) -> + true. -- cgit v1.2.3 From d4317108cb50081de28337685e77564854175704 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 22 Aug 2017 16:41:25 +0200 Subject: stdlib: add Unicode translation modifier in error_logger_tty_h Check if standard_io can handle Unicode, and if so add the 't' modifier to format strings. --- lib/stdlib/test/error_logger_h_SUITE.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/stdlib/test') diff --git a/lib/stdlib/test/error_logger_h_SUITE.erl b/lib/stdlib/test/error_logger_h_SUITE.erl index 30f96e0522..1f2a9fda0b 100644 --- a/lib/stdlib/test/error_logger_h_SUITE.erl +++ b/lib/stdlib/test/error_logger_h_SUITE.erl @@ -162,7 +162,7 @@ tty_log_open(Log) -> {ok,D} -> D; _ -> unlimited end, - error_logger:add_report_handler(?MODULE, {Fd,Depth}), + error_logger:add_report_handler(?MODULE, {Fd,Depth,latin1}), Fd. tty_log_close() -> @@ -393,11 +393,11 @@ dl_format_1([], [], _, Facc, Aacc) -> %%% calling error_logger_tty_h:write_event/2. %%% -init({_,_}=St) -> +init({_,_,_}=St) -> {ok,St}. -handle_event(Event, {Fd,Depth}=St) -> - case error_logger_tty_h:write_event(tag_event(Event), io_lib, Depth) of +handle_event(Event, {Fd,Depth,Enc}=St) -> + case error_logger_tty_h:write_event(tag_event(Event), io_lib, {Depth,Enc}) of ok -> ok; Str when is_list(Str) -> @@ -405,7 +405,7 @@ handle_event(Event, {Fd,Depth}=St) -> end, {ok,St}. -terminate(_Reason, {Fd,_}) -> +terminate(_Reason, {Fd,_,_}) -> ok = file:close(Fd), []. -- cgit v1.2.3