This is an automated email from the ASF dual-hosted git repository. kocolosk pushed a commit to branch update-toolchain in repository https://gitbox.apache.org/repos/asf/couchdb-khash.git
commit 8fb3d806e85e524c4880a089cdc89d8800046747 Author: Adam Kocoloski <[email protected]> AuthorDate: Fri Nov 26 18:50:29 2021 +0000 Fix issues uncovered by dialyzer * update an incomplete type spec for khash:del/2 * use assertEqual instead of assertMatch to silence a spurious warning * khash:keys/1 was never implemented; use khash:fold/3 in the test suite instead and enable the missing test --- src/khash.erl | 2 +- test/khash_tests.erl | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/khash.erl b/src/khash.erl index 1db4c4c..3f078ca 100644 --- a/src/khash.erl +++ b/src/khash.erl @@ -77,7 +77,7 @@ get(Hash, Key, Default) -> put(Hash, Key, Value) -> put_int(Hash, erlang:phash2(Key), Key, Value). --spec del(khash(), any()) -> ok. +-spec del(khash(), any()) -> ok | not_found. del(Hash, Key) -> del_int(Hash, erlang:phash2(Key), Key). diff --git a/test/khash_tests.erl b/test/khash_tests.erl index 8461b3d..e1d988e 100644 --- a/test/khash_tests.erl +++ b/test/khash_tests.erl @@ -98,7 +98,7 @@ randomized_test_() -> {1.0, fun run_put/1}, {1.0, fun run_del/1}, {0.5, fun run_size/1}, - % {0.3, fun run_keys/1}, + {0.3, fun run_keys/1}, {0.3, fun run_to_list/1} ], {ok, Actions, ?NUM_RAND_CYCLES, {Dict, KHash}} @@ -310,7 +310,7 @@ validate_randomized_state({D, H}) -> DKVs == HKVs. run_clear({_D0, H}) -> - ?assertMatch(ok, khash:clear(H)), + ?assertEqual(ok, khash:clear(H)), {dict:new(), H}. run_get2({D, H}) -> @@ -341,7 +341,7 @@ run_put({D0, H}) -> K = random_key(D0), V = random_val(), D1 = dict:store(K, V, D0), - ?assertMatch(ok, khash:put(H, K, V)), + ?assertEqual(ok, khash:put(H, K, V)), {D1, H}. run_del({D0, H}) -> @@ -363,8 +363,7 @@ run_size({D, H}) -> run_keys({D, H}) -> DKeys = dict:fetch_keys(D), - {ok, HKeys0} = khash:keys(H), - HKeys = lists:sort(HKeys0), + HKeys = khash:fold(H, fun(K, _V, Acc) -> [K | Acc] end, []), ?assertEqual(lists:sort(DKeys), lists:sort(HKeys)), {D, H}.
