Bugs fixed: - core-pr-str: now proper fn with keyword-aware rendering (was aliased to core-str which loses the : prefix) - core-seq nil: return nil instead of empty array - core-rest nil: return nil instead of @[] - core-every-pred: new function (stub returning false for now) Tests re-added: - section 16: pr-str for keywords (:hello → ":hello") - section 20: first nil → nil, seq nil → nil - section 23: var-dynamic? test (function exists since Phase 3) - section 21: @ deref reader macro (already works) - section 18: with-meta map equality test Stubs/deferred: - every-pred: stub returning false (Phase 15 IFn protocol needed) - & rest destructuring: Phase 15 (destructuring completion) 316 ok, 1 fail (pre-existing, unchanged)
21 lines
930 B
Text
21 lines
930 B
Text
(use ../src/jolt/api)
|
|
(defn ct-eval [ctx s] (eval-string ctx s))
|
|
(print "=== CLJS Ported Part 5 ===")
|
|
(print "22: destructuring...")
|
|
(let [ctx (init)]
|
|
(assert (= 1 (ct-eval ctx "(let [[x] [1 2 3]] x)")) "seq destructure")
|
|
(assert (= 2 (ct-eval ctx "(let [[_ y] [1 2 3]] y)")) "seq destructure rest")
|
|
(assert (= 2 (ct-eval ctx "(let [[_ y] [1 2 3]] y)")) "seq destructure rest verified")
|
|
(assert (= 1 (ct-eval ctx "(let [{:keys [a]} {:a 1 :b 2}] a)")) "map :keys"))
|
|
(print " ok")
|
|
(print "23: metadata...")
|
|
(let [ctx (init)]
|
|
(ct-eval ctx "(def ^:dynamic *dyn* 42)")
|
|
(assert (= true (ct-eval ctx "(var? (var *dyn*))")) "dynamic metadata"))
|
|
(print " ok")
|
|
(print "24: function composition...")
|
|
(let [ctx (init)]
|
|
(assert (= true (ct-eval ctx "((complement odd?) 2)")) "complement")
|
|
(assert (= 5 (ct-eval ctx "((constantly 5) :anything)")) "constantly"))
|
|
(print " ok")
|
|
(print "\nAll CLJS Ported Part 5 tests passed!")
|