aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-05-10 11:47:25 +0200
committerSverker Eriksson <[email protected]>2017-05-10 11:47:25 +0200
commit42d240e9144bd6219c9fd3b59ef9bc4f29bcf5f5 (patch)
tree4229ac7f656110a30c45d492b86a67991359488d /lib/stdlib/test
parent381a47d5219407f9c734cf0b081776129e7c180f (diff)
parent6c3265b86582d4848e1c77efee3a649a137694d6 (diff)
downloadotp-42d240e9144bd6219c9fd3b59ef9bc4f29bcf5f5.tar.gz
otp-42d240e9144bd6219c9fd3b59ef9bc4f29bcf5f5.tar.bz2
otp-42d240e9144bd6219c9fd3b59ef9bc4f29bcf5f5.zip
Merge branch 'sverker/ets-select-replace-const'
* sverker/ets-select-replace-const: stdlib: Add examples for ets:select_replace docs erts: Fix ets:select_replace with {const, NewTuple}
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/ets_SUITE.erl20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl
index 4c2f6cfe9e..05451a83fb 100644
--- a/lib/stdlib/test/ets_SUITE.erl
+++ b/lib/stdlib/test/ets_SUITE.erl
@@ -1349,6 +1349,26 @@ t_select_replace(Config) when is_list(Config) ->
NeqPairs(X,Y)) || X <- Terms, Y <- Terms],
+ %% Wrap entire tuple with 'const'
+ [[begin
+ Old = {Key, 1, 2},
+ ets:insert(T2, Old),
+ 1 = ets:select_replace(T2, [{Old, [], [{const, New}]}]),
+ [New] = ets:lookup(T2, Key),
+ ets:delete(T2, Key)
+ end || New <- [{Key, 1, 2}, {Key, 3, 4}, {Key, 1}, {Key, 1, 2, 3}, {Key}]
+ ]
+ || Key <- [{1, tuple}, {nested, {tuple, {a,b}}} | Terms]],
+
+ %% 'const' wrap does not work with maps or variables in keys
+ [[begin
+ Old = {Key, 1, 2},
+ {'EXIT',{badarg,_}} = (catch ets:select_replace(T2, [{Old, [], [{const, New}]}]))
+ end || New <- [{Key, 1, 2}, {Key, 3, 4}, {Key, 1}, {Key, 1, 2, 3}, {Key}]
+ ]
+ || Key <- [#{a => 1}, {nested, #{a => 1}}, '$1']],
+
+
ets:delete(T2),
verify_etsmem(EtsMem).