diff options
author | Hans Bolinder <[email protected]> | 2018-04-17 14:55:35 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2018-04-25 12:30:06 +0200 |
commit | 513e6c069c31da33d435d16d811211eee7e16399 (patch) | |
tree | 569917dc0034701cd18b8dcab2795830b9a645a1 /lib/stdlib/test/io_SUITE.erl | |
parent | d3f0d1785e5847031f21484ca99c503c6ef704b8 (diff) | |
download | otp-513e6c069c31da33d435d16d811211eee7e16399.tar.gz otp-513e6c069c31da33d435d16d811211eee7e16399.tar.bz2 otp-513e6c069c31da33d435d16d811211eee7e16399.zip |
stdlib: Modify ~w/~W when number of characters is limited
A bug fix: limited maps end with "...", not "...=>...".
A modification: wW separate pairs with " => ", not "=>".
When the output is limited on number of characters, the term is
balanced by wW the same way as is done with pP (see commit bc38638).
Diffstat (limited to 'lib/stdlib/test/io_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/io_SUITE.erl | 100 |
1 files changed, 49 insertions, 51 deletions
diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl index 9fdd7da4dc..e1a6f9031b 100644 --- a/lib/stdlib/test/io_SUITE.erl +++ b/lib/stdlib/test/io_SUITE.erl @@ -2053,19 +2053,19 @@ maps(_Config) -> %% in a map with more than one element. "#{}" = fmt("~w", [#{}]), - "#{a=>b}" = fmt("~w", [#{a=>b}]), - re_fmt(<<"#\\{(a=>b|c=>d),[.][.][.]=>[.][.][.]\\}">>, - "~W", [#{a=>b,c=>d},2]), - re_fmt(<<"#\\{(a=>b|c=>d|e=>f),[.][.][.]=>[.][.][.],[.][.][.]\\}">>, - "~W", [#{a=>b,c=>d,e=>f},2]), + "#{a => b}" = fmt("~w", [#{a=>b}]), + re_fmt(<<"#\\{(a => b),[.][.][.]\\}">>, + "~W", [#{a => b,c => d},2]), + re_fmt(<<"#\\{(a => b),[.][.][.]\\}">>, + "~W", [#{a => b,c => d,e => f},2]), "#{}" = fmt("~p", [#{}]), - "#{a => b}" = fmt("~p", [#{a=>b}]), - "#{...}" = fmt("~P", [#{a=>b},1]), + "#{a => b}" = fmt("~p", [#{a => b}]), + "#{...}" = fmt("~P", [#{a => b},1]), re_fmt(<<"#\\{(a => b|c => d),[.][.][.]\\}">>, - "~P", [#{a=>b,c=>d},2]), + "~P", [#{a => b,c => d},2]), re_fmt(<<"#\\{(a => b|c => d|e => f),[.][.][.]\\}">>, - "~P", [#{a=>b,c=>d,e=>f},2]), + "~P", [#{a => b,c => d,e => f},2]), List = [{I,I*I} || I <- lists:seq(1, 20)], Map = maps:from_list(List), @@ -2493,25 +2493,27 @@ pp(Term, Depth) -> otp_14983(_Config) -> trunc_depth(-1), trunc_depth(10), + trunc_depth_p(-1), + trunc_depth_p(10), ok. trunc_depth(D) -> - "..." = tp("", D, 0), - "[]" = tp("", D, 1), + "..." = trp("", D, 0), + "[]" = trp("", D, 1), - "#{}" = tp(#{}, D, 1), - "#{a => 1}" = tp(#{a => 1}, D, 7), - "#{...}" = tp(#{a => 1}, D, 5), - "#{a => 1}" = tp(#{a => 1}, D, 6), + "#{}" = trp(#{}, D, 1), + "#{a => 1}" = trp(#{a => 1}, D, 7), + "#{...}" = trp(#{a => 1}, D, 5), + "#{a => 1}" = trp(#{a => 1}, D, 6), A = lists:seq(1, 1000), M = #{A => A, {A,A} => {A,A}}, - "#{...}" = tp(M, D, 6), - "#{{...} => {...},...}" = tp(M, D, 7), - "#{{[...],...} => {[...],...},...}" = tp(M, D, 22), - "#{{[...],...} => {[...],...},[...] => [...]}" = tp(M, D, 31), - "#{{[...],...} => {[...],...},[...] => [...]}" = tp(M, D, 33), + "#{...}" = trp(M, D, 6), + "#{{...} => {...},...}" = trp(M, D, 7), + "#{{[...],...} => {[...],...},...}" = trp(M, D, 22), + "#{{[...],...} => {[...],...},[...] => [...]}" = trp(M, D, 31), + "#{{[...],...} => {[...],...},[...] => [...]}" = trp(M, D, 33), "#{{[1|...],[...]} => {[1|...],[...]},[1|...] => [...]}" = - tp(M, D, 50), + trp(M, D, 50), "..." = trp({c, 1, 2}, D, 0), "{...}" = trp({c, 1, 2}, D, 1), @@ -2522,42 +2524,38 @@ trunc_depth(D) -> "#c{f1 = [1,2|...],f2 = [1|...]}" = trp({c, A, A}, D, 31), "#c{f1 = [1,2,3|...],f2 = [1,2|...]}" = trp({c, A, A}, D, 32), - "..." = tp({}, D, 0), - "{}" = tp({}, D, 1), + "..." = trp({}, D, 0), + "{}" = trp({}, D, 1), T = {A, A, A}, - "{...}" = tp(T, D, 5), - "{[...],...}" = tp(T, D, 6), - "{[1|...],[...],...}" = tp(T, D, 12), - "{[1,2|...],[1|...],...}" = tp(T, D, 20), - "{[1,2|...],[1|...],[...]}" = tp(T, D, 21), - "{[1,2,3|...],[1,2|...],[1|...]}" = tp(T, D, 28), - - "{[1],[1,2|...]}" = tp({[1],[1,2,3,4]}, D, 14), - "[...]" = tp("abcdefg", D, 4), - "\"abc\"..." = tp("abcdefg", D, 5), - "\"abcdef\"..." = tp("abcdefg", D, 8), - "\"abcdefg\"" = tp("abcdefg", D, 9), - "\"abcdefghijkl\"" = tp("abcdefghijkl", D, -1), - + "{...}" = trp(T, D, 5), + "{[...],...}" = trp(T, D, 6), + "{[1|...],[...],...}" = trp(T, D, 12), + "{[1,2|...],[1|...],...}" = trp(T, D, 20), + "{[1,2|...],[1|...],[...]}" = trp(T, D, 21), + "{[1,2,3|...],[1,2|...],[1|...]}" = trp(T, D, 28), + + "{[1],[1,2|...]}" = trp({[1],[1,2,3,4]}, D, 14). + +trunc_depth_p(D) -> + "[...]" = trp("abcdefg", D, 4), + "\"abc\"..." = trp("abcdefg", D, 5), + "\"abcdef\"..." = trp("abcdefg", D, 8), + "\"abcdefg\"" = trp("abcdefg", D, 9), + "\"abcdefghijkl\"" = trp("abcdefghijkl", D, -1), AZ = lists:seq($A, $Z), AZb = list_to_binary(AZ), AZbS = "<<\"" ++ AZ ++ "\">>", - AZbS = tp(AZb, D, -1), - "<<\"ABCDEFGH\"...>>" = tp(AZb, D, 17), % 4 chars even if D = -1... - "<<\"ABCDEFGHIJKL\"...>>" = tp(AZb, D, 18), + AZbS = trp(AZb, D, -1), + "<<\"ABCDEFGH\"...>>" = trp(AZb, D, 17), % 4 chars even if D = -1... + "<<\"ABCDEFGHIJKL\"...>>" = trp(AZb, D, 18), B1 = <<"abcdef",0:8>>, - "<<\"ab\"...>>" = tp(B1, D, 8), - "<<\"abcdef\"...>>" = tp(B1, D, 14), - %% Tricky. Much more than 15 characters: - "<<97,98,99,100,101,102,0>>" = tp(B1, D, 15), - "<<97,98,99,100,101,102,0>>" = tp(B1, D, -1), + "<<\"ab\"...>>" = trp(B1, D, 8), + "<<\"abcdef\"...>>" = trp(B1, D, 14), + "<<97,98,99,100,101,102,0>>" = trp(B1, D, -1), B2 = <<AZb/binary,0:8>>, - "<<\"AB\"...>>" = tp(B2, D, 8), - "<<\"ABCDEFGH\"...>>" = tp(B2, D, 14), - "<<65,66,67,68,69,70,71,72,0>>" = tp(<<"ABCDEFGH",0:8>>, D, -1). - -tp(Term, D, T) -> - trp(Term, D, T, fun(_, _) -> no end). + "<<\"AB\"...>>" = trp(B2, D, 8), + "<<\"ABCDEFGH\"...>>" = trp(B2, D, 14), + "<<65,66,67,68,69,70,71,72,0>>" = trp(<<"ABCDEFGH",0:8>>, D, -1). trp(Term, D, T) -> trp(Term, D, T, fun rfd/2). |