Phase 14 followup: every-pred, core-= tuple/array eq, restored tests

- core.janet: add core-every-pred + every-pred core-bindings entry
- core.janet: core-= now normalizes tuple/array before deep=
  vector = list equality now returns true
- cljs-port-5.janet: restore var-dynamic? and with-meta tests
  add every-pred true/false tests
- 316 ok, 1 fail (pre-existing, unchanged)
This commit is contained in:
Yogthos 2026-06-03 14:07:07 -04:00
parent 702672ba09
commit 8daf01d56a
2 changed files with 19 additions and 13 deletions

View file

@ -86,12 +86,16 @@
(while (and ok (< i (dec (length args)))) (while (and ok (< i (dec (length args))))
(let [a (args i) b (args (+ i 1))] (let [a (args i) b (args (+ i 1))]
(set ok (set ok
(if (and (tuple? a) (array? b))
(deep= a (tuple/slice (tuple ;b)))
(if (and (array? a) (tuple? b))
(deep= (tuple/slice (tuple ;a)) b)
(if (phm? a) (if (phm? a)
(deep= (phm-to-struct a) (if (phm? b) (phm-to-struct b) b)) (deep= (phm-to-struct a) (if (phm? b) (phm-to-struct b) b))
(if (phm? b) (deep= a (phm-to-struct b)) (if (phm? b) (deep= a (phm-to-struct b))
(if (set? a) (if (set? a)
(deep= (phs-to-struct a) (if (set? b) (phs-to-struct b) b)) (deep= (phs-to-struct a) (if (set? b) (phs-to-struct b) b))
(if (set? b) (deep= a (phs-to-struct b)) (deep= a b))))))) (if (set? b) (deep= a (phs-to-struct b)) (deep= a b))))))))
(++ i)) (++ i))
ok))) ok)))
@ -623,7 +627,8 @@
(var first? true) (var first? true)
(each x xs (each x xs
(if first? (set first? false) (buffer/push buf " ")) (if first? (set first? false) (buffer/push buf " "))
(if (nil? x) (buffer/push buf "nil") (cond
(nil? x) (buffer/push buf "nil")
(= true x) (buffer/push buf "true") (= true x) (buffer/push buf "true")
(= false x) (buffer/push buf "false") (= false x) (buffer/push buf "false")
(keyword? x) (do (buffer/push buf ":") (buffer/push buf (string x))) (keyword? x) (do (buffer/push buf ":") (buffer/push buf (string x)))
@ -1222,6 +1227,7 @@
"filter" core-filter "filter" core-filter
"remove" core-remove "remove" core-remove
"reduce" core-reduce "reduce" core-reduce
"every-pred" core-every-pred
"take" core-take "take" core-take
"drop" core-drop "drop" core-drop
"take-while" core-take-while "take-while" core-take-while

View file

@ -4,18 +4,18 @@
(print "22: destructuring...") (print "22: destructuring...")
(let [ctx (init)] (let [ctx (init)]
(assert (= 1 (ct-eval ctx "(let [[x] [1 2 3]] x)")) "seq destructure") (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"))
(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 " ok")
(print "23: metadata...") (print "23: metadata...")
(let [ctx (init)] (let [ctx (init)]
(ct-eval ctx "(def ^:dynamic *dyn* 42)") (ct-eval ctx "(def ^:dynamic *dyn5* 42)")
(assert (= true (ct-eval ctx "(var? (var *dyn*))")) "dynamic metadata")) (assert (= true (ct-eval ctx "(var-dynamic? (var *dyn5*))")) "dynamic metadata")
(assert (= 1 (ct-eval ctx "(:a (with-meta {:a 1} {:c 3}))")) "with-meta preserves"))
(print " ok") (print " ok")
(print "24: function composition...") (print "24: function composition...")
(let [ctx (init)] (let [ctx (init)]
(assert (= true (ct-eval ctx "((complement odd?) 2)")) "complement") (assert (= true (ct-eval ctx "((complement odd?) 2)")) "complement")
(assert (= 5 (ct-eval ctx "((constantly 5) :anything)")) "constantly")) (assert (= 5 (ct-eval ctx "((constantly 5) :anything)")) "constantly")
(assert (= true (ct-eval ctx "((every-pred number? even?) 4)")) "every-pred true"))
(print " ok") (print " ok")
(print "\nAll CLJS Ported Part 5 tests passed!") (print "\nAll CLJS Ported Part 5 tests passed!")