Use parameterized context instead of macro weirdness for tests

This commit is contained in:
2026-05-19 11:53:53 -05:00
parent 56fdd158d2
commit 57756193ab
2 changed files with 43 additions and 30 deletions

View File

@@ -200,16 +200,19 @@
(define solution (get-solution))
(assert-equal 'norwegian (assq-ref solution '?water-drinker))
(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)))
;; Outside context
(set! get-solution (?- (foo ?x)))
(set! solution (get-solution))
(assert-equal #f (assq-ref solution '?x))
;; Inside context
(with-db my-db
(set! get-solution (?- (foo ?x)))
(set! solution (get-solution)))
(assert-equal 'bar (assq-ref solution '?x))))
(set! solution (get-solution))
(assert-equal 'bar (assq-ref solution '?x)))))