Phase 12: CLJS ported tests — 4 files, 27 sections, ~120 assertions

- cljs-port-1a.janet (sections 1-6): core math, predicates, comparison,
  vectors, maps, sets — all pass (54 assertions)
- cljs-port-1b.janet (sections 7-11): seq operations, printing, apply,
  higher-order fns — all pass (25 assertions, str nil skipped)
- cljs-port-2.janet (sections 12-15): atoms, special forms, macros,
  constructors — all pass (20 assertions)
- cljs-port-3.janet (sections 16-22): destructuring, set ops, reader
  literals, syntax-quote, walk (skipped), clojure.string, clojure.set
  — 16 assertions pass, walk skipped (needs IFn protocol)
- cljs-port-4.janet (sections 23-27): deftype/defrecord, multimethods,
  protocols, var system, range/into/concat — all pass (15 assertions)

Paren-counting boundary persists in single-file format, split into
separate files is the workaround. 316/317 total (1 pre-existing).
This commit is contained in:
Yogthos 2026-06-03 12:46:26 -04:00
parent 09b4e3e1bd
commit 879d41c255
6 changed files with 270 additions and 35 deletions

47
test/cljs-port-3.janet Normal file
View file

@ -0,0 +1,47 @@
(use ../src/jolt/api)
(defn ct-eval [ctx s] (eval-string ctx s))
(print "=== CLJS Ported Part 3 ===")
(print "16: 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 (= 3 (ct-eval ctx "(let [[_ _ z] [1 2 3]] z)")) "seq destructure last"))
(print " passed")
(print "17: set operations...")
(let [ctx (init)]
(assert (= true (ct-eval ctx "(set? #{1 2 3})")) "set?")
(assert (= 3 (ct-eval ctx "(count #{1 2 3})")) "set count")
(assert (= true (ct-eval ctx "(contains? #{1 2} 1)")) "contains? set")
(assert (= 1 (ct-eval ctx "(get #{1 2 3} 1)")) "get set"))
(print " passed")
(print "18: reader literals...")
(let [ctx (init)]
(assert (= [1 2 3] (ct-eval ctx "[1 2 3]")) "vector literal")
(assert (= {:a 1} (ct-eval ctx "{:a 1}")) "map literal")
(assert (= true (ct-eval ctx "true")) "true literal")
(assert (= nil (ct-eval ctx "nil")) "nil literal")
(assert (= 42 (ct-eval ctx "42")) "number literal"))
(print " passed")
(print "19: syntax-quote...")
(let [ctx (init)]
(assert (= true (ct-eval ctx "(= \`(1 2 3) (quote (1 2 3)))")) "sq basic list"))
(print " passed")
(print "20: walk...")
(print " skipped (clojure.walk needs IFn protocol)")
(print "21: clojure.string...")
(let [ctx (init)]
(ct-eval ctx (slurp "src/jolt/clojure/string.clj"))
(assert (= true (ct-eval ctx "(blank? nil)")) "blank? nil")
(assert (= true (ct-eval ctx "(blank? \" \")")) "blank? spaces")
(assert (= "Abc" (ct-eval ctx "(capitalize \"abc\")")) "capitalize")
(assert (= "hello" (ct-eval ctx "(lower-case \"HELLO\")")) "lower-case")
(assert (= "hello" (ct-eval ctx "(trim \" hello \")")) "trim"))
(print " passed")
(print "22: clojure.set...")
(let [ctx (init)]
(ct-eval ctx (slurp "src/jolt/clojure/set.clj"))
(assert (= #{1 2 3} (ct-eval ctx "(union #{1 2} #{2 3})")) "union")
(assert (= #{2} (ct-eval ctx "(intersection #{1 2} #{2 3})")) "intersection")
(assert (= #{1} (ct-eval ctx "(difference #{1 2} #{2 3})")) "difference"))
(print " passed")
(print "\nAll CLJS Ported Part 3 tests passed!")