kyleect / cid-lang

An (on going) implementation of a Scheme based language.
https://kyleect.github.io/cid-lang/
1 stars 0 forks source link

First class mocking #27

Open kyleect opened 1 year ago

kyleect commented 1 year ago
(define sum (lambda (a b) (+ a b)))

(mock (sum # #) 15)

(sum 2 2) ;==> 15

(mock-restore (sum # #))

(sum 2 2) ;==> 4

(mock (sum # 0) 25)

(sum 2 0) ;==> 25
(sum 2 2) ;==> 4
(sum 0 2) ;==> 2

;; These also works
(mock-restore sum) ;; Restore all calls
(mock-restore) ;; Restore all calls across all mocks
kyleect commented 1 year ago
(mock-verify (sum 2 2) '(called once))