+;; won't work if we turn off #:cleanup though
+
+(with-fresh-speaker
+ (let ((hive (make-hive)))
+ (bootstrap-actor hive <cleanly>)
+ (run-hive hive '() #:cleanup #f))
+ (test-equal '()
+ (get-spoken)))
+
+;; The exploder self-destructs, even though run-hive has cleanup
+;; disabled, because it cleans up on self-destruct.
+
+(define-actor <exploder> (<actor>)
+ ((explode (lambda (exploder message)
+ (speak "POOF\n")
+ (self-destruct exploder)))
+ (*cleanup* (lambda _ (speak "Cleaning up post-explosion\n")))))
+
+(with-fresh-speaker
+ (let ((hive (make-hive)))
+ (define exploder (bootstrap-actor hive <exploder>))
+ (run-hive hive (list (bootstrap-message hive exploder 'explode))
+ #:cleanup #f))
+ (test-equal '("POOF\n" "Cleaning up post-explosion\n")
+ (get-spoken)))
+
+(define-class <hi-on-init> (<actor>)
+ (name #:init-keyword #:name)
+ (create-friend #:init-value #f
+ #:init-keyword #:create-friend)
+ (actions #:allocation #:each-subclass
+ #:init-value (build-actions
+ (*init* hi-on-init-init))))
+
+(define (hi-on-init-init actor message)
+ (speak (format #f "Hi! ~a inits now.\n"
+ (slot-ref actor 'name)))
+ (and=> (slot-ref actor 'create-friend)
+ (lambda (friend-name)
+ (create-actor actor <hi-on-init> #:name friend-name))))
+
+(with-fresh-speaker
+ (let ((hive (make-hive)))
+ (define hi-on-init (bootstrap-actor hive <hi-on-init>
+ #:name "jack"
+ #:create-friend "jill"))
+ (run-hive hive '()))
+ (test-equal (get-spoken)
+ '("Hi! jack inits now.\n" "Hi! jill inits now.\n")))
+