~subsetpark/fugue

469ef4a4b6d168d48853ce5c7758e142c0c9a30f — Zach Smith 6 months ago 98b59f8
Test for new-form
2 files changed, 5 insertions(+), 3 deletions(-)

M fugue.janet
M test/fugue.janet
M fugue.janet => fugue.janet +1 -3
@@ 141,12 141,10 @@

(eval (pred*-form 'Root))

(defn- init-name [name] (symbol "new-" name))

(defn- new-form
  "Generate the init form wrapper."
  [name]
  (let [init-name (init-name name)]
  (let [init-name (symbol "new-" name)]
    ~(defn ,init-name [& rest] (:new ,name ;rest))))

(eval (new-form 'Root))

M test/fugue.janet => test/fugue.janet +4 -0
@@ 34,6 34,10 @@
    (inst-tests Animal cat)
    (is (= "Bowler Cat" (cat :name)))))

(deftest new-form
  (let [an-animal (new-Animal)]
    (inst-tests Animal an-animal)))

(fugue/defproto Human () name {:default "John Doe"})

(deftest defaults