Use a helper thread to make the test more reliable

* test/src/fns-tests.el (ft-weak-equal-table): With wide-ints, the test
unexpecetly passed probably because some stray reference to '(key 0) was
on the stack.  With a helper thread, the test works as expected.
This commit is contained in:
Helmut Eller 2026-02-11 08:37:32 +01:00
parent dc94610043
commit a4dcb8ef73

View file

@ -1423,6 +1423,8 @@
(ert-deftest ft-weak-equal-table ()
:expected-result (if (fboundp 'igc--collect) :failed :passed)
(unless (featurep 'threads)
(ert-skip '(not (featurep 'threads))))
(let* ((h (make-hash-table :weakness 'key-or-value :test #'equal))
(n 10)
(root nil))
@ -1432,7 +1434,8 @@
(puthash key val h)))
(should (= (hash-table-count h) n))
(ft--gc 'key)
(setq root (gethash '(key 0) h))
(setq root (thread-join (make-thread (lambda ()
(gethash '(key 0) h)))))
(ft--gc 'key-or-value)
(should (< (hash-table-count h) n))
(should (equal root (gethash '(key 0) h)))))