diff options
author | Björn Gustavsson <[email protected]> | 2015-09-08 09:00:22 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-09-11 12:24:36 +0200 |
commit | e882c376be9c62950ed84ae0ba7936cf4c827462 (patch) | |
tree | 86841697856cff921e2ab635362f4060376cfab7 /lib/stdlib/test | |
parent | 1d00d0df6ff344e3a0ef58a5636ad32259ca31b0 (diff) | |
download | otp-e882c376be9c62950ed84ae0ba7936cf4c827462.tar.gz otp-e882c376be9c62950ed84ae0ba7936cf4c827462.tar.bz2 otp-e882c376be9c62950ed84ae0ba7936cf4c827462.zip |
lists_SUITE: Extend flatten/1 test to also test flatlength/1
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r-- | lib/stdlib/test/lists_SUITE.erl | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/stdlib/test/lists_SUITE.erl b/lib/stdlib/test/lists_SUITE.erl index 4a15bb9b81..e0dd34e82d 100644 --- a/lib/stdlib/test/lists_SUITE.erl +++ b/lib/stdlib/test/lists_SUITE.erl @@ -2326,18 +2326,24 @@ sublist_3_e(Config) when is_list(Config) -> -define(flatten_error1(X), ?line {'EXIT', _} = (catch lists:flatten(X))). -define(flatten_error2(X,Y), ?line {'EXIT', _} = (catch lists:flatten(X,Y))). -flatten_1(doc) -> ["flatten/1"]; -flatten_1(suite) -> []; +%% Test lists:flatten/1,2 and lists:flatlength/1. flatten_1(Config) when is_list(Config) -> - ?line [] = lists:flatten([]), - ?line [1,2] = lists:flatten([1,2]), - ?line [1,2] = lists:flatten([1,[2]]), - ?line [1,2] = lists:flatten([[1],2]), - ?line [1,2] = lists:flatten([[1],[2]]), - ?line [1,2] = lists:flatten([[1,2]]), - ?line [a,b,c,d] = lists:flatten([[a],[b,c,[d]]]), - - ok. + [] = lists_flatten([]), + [1,2] = lists_flatten([1,2]), + [1,2] = lists_flatten([1,[2]]), + [1,2] = lists_flatten([[1],2]), + [1,2] = lists_flatten([[1],[2]]), + [1,2] = lists_flatten([[1,2]]), + [a,b,c,d] = lists_flatten([[a],[b,c,[d]]]), + + ok. + +lists_flatten(List) -> + Flat = lists:flatten(List), + Flat = lists:flatten(List, []), + Len = lists:flatlength(List), + Len = length(Flat), + Flat. flatten_1_e(doc) -> ["flatten/1 error cases"]; flatten_1_e(suite) -> []; |