1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 20:30:28 +02:00

Tweak the "unused modules are removed" test.

* test-suite/tests/gc.test ("gc")["unused modules are removed"]: Add
  loop to clean up stale references from the stack.
This commit is contained in:
Ludovic Courtès 2009-12-11 23:27:47 +01:00
parent 2cf7ff2e79
commit 9035e9d6db

View file

@ -59,19 +59,23 @@
(with-test-prefix "gc" (with-test-prefix "gc"
(pass-if "Unused modules are removed" (pass-if "Unused modules are removed"
(let* ((guard (make-guardian)) (let* ((guard (make-guardian))
(total 1000)) (total 1000))
(for-each (lambda (x) (guard (make-module))) (iota total)) (for-each (lambda (x) (guard (make-module))) (iota total))
(gc) ;; Avoid false references to the modules on the stack.
(gc) ;; twice: have to kill the weak vectors. (let cleanup ((i 20))
(gc) ;; thrice: because the test doesn't succeed with only (and (> i 0)
;; one gc round. not sure why. (begin (cleanup (1- i)) i)))
(= (let lp ((i 0)) (gc)
(if (guard) (gc) ;; twice: have to kill the weak vectors.
(lp (1+ i)) (gc) ;; thrice: because the test doesn't succeed with only
i)) ;; one gc round. not sure why.
total))))
(= (let lp ((i 0))
(if (guard)
(lp (1+ i))
i))
total))))