aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-09-08 09:10:13 +0200
committerBjörn Gustavsson <[email protected]>2015-09-11 12:24:36 +0200
commit358d73bb6432367823eda3636f9ce167c73750b0 (patch)
tree6ca2cb09fab502a7ea3188b7c0ce879a7e16a03d /lib/stdlib/test
parente882c376be9c62950ed84ae0ba7936cf4c827462 (diff)
downloadotp-358d73bb6432367823eda3636f9ce167c73750b0.tar.gz
otp-358d73bb6432367823eda3636f9ce167c73750b0.tar.bz2
otp-358d73bb6432367823eda3636f9ce167c73750b0.zip
lists_SUITE: Test lists:keyreplace/4
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/lists_SUITE.erl16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/stdlib/test/lists_SUITE.erl b/lib/stdlib/test/lists_SUITE.erl
index e0dd34e82d..cf42ac473d 100644
--- a/lib/stdlib/test/lists_SUITE.erl
+++ b/lib/stdlib/test/lists_SUITE.erl
@@ -38,7 +38,7 @@
% Test cases must be exported.
-export([member/1, reverse/1,
keymember/1, keysearch_keyfind/1,
- keystore/1, keytake/1,
+ keystore/1, keytake/1, keyreplace/1,
append_1/1, append_2/1,
seq_loop/1, seq_2/1, seq_3/1, seq_2_e/1, seq_3_e/1,
@@ -82,7 +82,8 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[{group, append}, reverse, member, keymember,
- keysearch_keyfind, keystore, keytake, dropwhile, {group,sort},
+ keysearch_keyfind, keystore, keytake, keyreplace,
+ dropwhile, {group,sort},
{group, usort}, {group, keysort}, {group, ukeysort},
{group, funsort}, {group, ufunsort}, {group, sublist},
{group, flatten}, {group, seq}, zip_unzip, zip_unzip3,
@@ -382,6 +383,17 @@ keytake(Config) when is_list(Config) ->
?line false = lists:keytake(4, 2, L),
ok.
+%% Test lists:keyreplace/4.
+keyreplace(Config) when is_list(Config) ->
+ [{new,42}] = lists:keyreplace(k, 1, [{k,1}], {new,42}),
+ [atom,{new,a,b}] = lists:keyreplace(k, 1, [atom,{k,1}], {new,a,b}),
+ [a,{x,y,z}] = lists:keyreplace(a, 5, [a,{x,y,z}], {no,use}),
+
+ %% Error cases.
+ {'EXIT',_} = (catch lists:keyreplace(k, 1, [], not_tuple)),
+ {'EXIT',_} = (catch lists:keyreplace(k, 0, [], {a,b})),
+ ok.
+
merge(doc) -> ["merge functions"];
merge(suite) -> [];
merge(Config) when is_list(Config) ->