Add test for with-db

This commit is contained in:
2026-05-19 10:26:40 -05:00
parent e9c384d666
commit dc0724def4

View File

@@ -199,4 +199,17 @@
(define get-solution (?- (zebra ? ?water-drinker ?zebra-owner)))
(define solution (get-solution))
(assert-equal 'norwegian (assq-ref solution '?water-drinker))
(assert-equal 'japanese (assq-ref solution '?zebra-owner))))
(assert-equal 'japanese (assq-ref solution '?zebra-owner)))
(define-test "with-db"
(define my-db '())
(define get-solution #f)
(define solution #f)
(with-db my-db
(<- (foo bar)))
(set! get-solution (?- (foo ?x)))
(set! solution (get-solution))
(assert-equal #f (assq-ref solution '?x))
(with-db my-db
(set! get-solution (?- (foo ?x)))
(set! solution (get-solution)))
(assert-equal 'bar (assq-ref solution '?x))))