ephemeron test added by sytse on Fri Mar 16 13:10:13 2018

($deftest srfi-124-ephemerons
  ($import! emacs-global garbage-collect)
  ($letrec ((fn ((k v)
                  ($let ((e (make-ephemeron k (cons k v))))
                    (reference-barrier k)
    ($let* ((v "value")
            (e ($let ((e (fn (list 42) v)))
                 ($should (not? (ephemeron-broken? e)))
                 ($should (equal? (cons (list 42) "value") (ephemeron-value e)))
                 ;; This triggers the bad behavior of the interpreter:
                 ((constant #inert) (ephemeron-key e))
                 ;; ($should (ephemeron-broken? e))
                 (display "Should be (#t #f #f): ")
                 ;; Unfortunately, this prints (#f (42) ((42) . "value"))
                 (writenl (list (ephemeron-broken? e)
                                (ephemeron-key e)
                                (ephemeron-value e)))
      ;; Here the return value of the first ephemeron-key call has
      ;; disappeared from the stack:
      ($should (ephemeron-broken? e))
      ($should (eq? #f (ephemeron-key e)))
      ($should (eq? #f (ephemeron-value e))))))