diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-02-01 07:22:40 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-02-01 07:22:40 -0800 |
commit | fb8b7312de0fa42fe9b544aca54d1ee05518bf40 (patch) | |
tree | 08bc4990f07d3489819940241417f0d5fdf68e69 | |
parent | 6c14ce4f78a762cb9ad88a336289451d1ca0e326 (diff) | |
download | txr-fb8b7312de0fa42fe9b544aca54d1ee05518bf40.tar.gz txr-fb8b7312de0fa42fe9b544aca54d1ee05518bf40.tar.bz2 txr-fb8b7312de0fa42fe9b544aca54d1ee05518bf40.zip |
hash-eql: regression: always returns zero.
* hash.c (hash_eql): Use hash_traversal_limit for
the initial value of the limit rather than zero.
Commit 84e9903c27ede099e2361e15b16a05c6aa4dc819 in October
2019 fixed eql_hash to actually make use of the limit, which
broke the assumption that we could use zero.
* tests/010/hash.tl: Add a few tests for hash-equal and
hash-eql.
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | tests/010/hash.tl | 6 |
2 files changed, 7 insertions, 1 deletions
@@ -1418,7 +1418,7 @@ val maphash(val fun, val hash) val hash_eql(val obj) { - int lim = 0; + int lim = hash_traversal_limit; return num_fast(eql_hash(obj, &lim)); } diff --git a/tests/010/hash.tl b/tests/010/hash.tl index b2e8d891..d6a8542b 100644 --- a/tests/010/hash.tl +++ b/tests/010/hash.tl @@ -86,3 +86,9 @@ (mtest (hash-isec h1 h2) #H(() (b 2) (c 3) (d 4)) [hash-isec h1 h2 +] #H(() (b 0) (c 0) (d 0)))) + +(mtest + (eql (hash-equal "abc") (hash-equal "abc")) t + (eql (hash-equal (expt 2 128)) (hash-equal (expt 2 128))) t + (eql (hash-eql "abc") (hash-eql "abc")) nil + (eql (hash-eql (expt 2 128)) (hash-eql (expt 2 128))) t) |