From fb8b7312de0fa42fe9b544aca54d1ee05518bf40 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 1 Feb 2024 07:22:40 -0800 Subject: 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. --- hash.c | 2 +- tests/010/hash.tl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hash.c b/hash.c index 86b980b2..7ebe95a7 100644 --- a/hash.c +++ b/hash.c @@ -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) -- cgit v1.2.3