Phase 14 followup: fix 4 core bugs, re-add 5 tests
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)
This commit is contained in:
parent
f97e6191db
commit
702672ba09
3 changed files with 18 additions and 4 deletions
|
|
@ -196,7 +196,7 @@
|
|||
(defn core-rest [coll]
|
||||
(if (lazy-seq? coll) (ls-rest coll)
|
||||
(if (or (nil? coll) (= 0 (length coll)))
|
||||
@[]
|
||||
nil
|
||||
(if (tuple? coll)
|
||||
(tuple/slice coll 1)
|
||||
(array/slice coll 1)))))
|
||||
|
|
@ -617,6 +617,20 @@
|
|||
(def core-print print)
|
||||
(def core-println (fn [& xs] (apply print xs) (print "\n") nil))
|
||||
|
||||
(defn core-pr-str [& xs]
|
||||
"Returns a string representation of xs suitable for reading."
|
||||
(var buf @"")
|
||||
(var first? true)
|
||||
(each x xs
|
||||
(if first? (set first? false) (buffer/push buf " "))
|
||||
(if (nil? x) (buffer/push buf "nil")
|
||||
(= true x) (buffer/push buf "true")
|
||||
(= false x) (buffer/push buf "false")
|
||||
(keyword? x) (do (buffer/push buf ":") (buffer/push buf (string x)))
|
||||
(string? x) (do (buffer/push buf "\"") (buffer/push buf x) (buffer/push buf "\""))
|
||||
(buffer/push buf (string x))))
|
||||
(string buf))
|
||||
|
||||
(defn core-pr [& xs]
|
||||
(var i 0)
|
||||
(while (< i (length xs))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue