Skip to content

A peer-to-peer stack for code collaboration

936 B
Raw Blame
;; This script stubs some primitives for code evaluated afterwards.
;;
;; This code is used by `rad/tests/run.rad` to test code that relies on
;; primitives. Currently only some primitives are stubbed.
;;
;; A primitive `prim` is stubbed by creating a ref `primitive-stub-ref/prim`
;; that holds the original primitive value. The function `prim` is then
;; redefined as calling the function stored in the reference.
;;
;; See `prelude/chain/install-remote-chain-fake` for how to use primitve stubs.

;; now!
(def primitive-stub-ref/now! (ref now!))
(def now!
  (fn [] ((read-ref primitive-stub-ref/now!))))

;; read-file!
(def primitive-stub-ref/read-file! (ref read-file!))
(def read-file!
  (fn [path] ((read-ref primitive-stub-ref/read-file!) path)))

;; find-module-file!
(def primitive-stub-ref/find-module-file! (ref find-module-file!))
(def find-module-file!
  (fn [path] ((read-ref primitive-stub-ref/find-module-file!) path)))