jolt/test/integration/deps-conformance-test.janet
Yogthos 1898df99bc regex: \p{...} property classes; interop: the String method surface (cuerdas is green)
\p{L}/\p{Lu}/\p{Ll}/\p{N}/\p{Z}/\p{Ps}/\p{Pe} (+\P negation) land in
both escape positions of the regex compiler, mapped onto the byte PEGs:
ASCII exact, any high byte (inside a UTF-8 sequence) counts as a LETTER —
so ^\p{L}+$ accepts UTF-8 words while \p{N}/\p{Z} stay ASCII. (?u) was
already a tolerated no-op flag. Unknown property names error at compile.

Chasing the acceptance target (cuerdas via deps-conformance) pulled in the
rest of its clj-compat chain, each a real gap:
- the deps-conformance harness reads libraries under clj-compat reader
  features (deps are clj/cljc by definition — without :clj, cuerdas's
  #?(:clj (instance? Pattern x)) branches resolved to NIL bodies)
- instance? knows Pattern/java.util.regex.Pattern (regex values) and
  Character (cuerdas's rx/regexp? gate on split)
- the java.lang.String method surface: .toLowerCase/.toUpperCase/.trim/
  .indexOf(-1 on miss)/.lastIndexOf/.substring/.charAt/.startsWith/
  .endsWith/.contains/.replace/.equalsIgnoreCase/... — ASCII case mapping,
  unknown methods error (the old path silently returned nil)
- the (.method obj args) SUGAR now desugars to (. obj method args) in the
  interpreter — it was never implemented (bare .method heads resolved as
  vars, hence 'Cannot call nil')
- Long/MAX_VALUE / MIN_VALUE statics (f64 approximations)

deps-conformance: medley ok, cuerdas ok (was check-error); dependency now
loads its clj branches and fails only on its single-segment ns resolution.
30 new spec rows (11 regex, 19 interop). Gate exit 0.
2026-06-10 21:29:22 -04:00

59 lines
2.6 KiB
Text

# Conformance pass for deps.edn-loaded libraries: resolve a few real, pure-cljc
# git libraries and check that their namespaces load and a sample call works.
#
# Network-gated: set JOLT_CONFORMANCE=1 to run (it clones from GitHub). Skipped by
# default so CI stays offline. Findings are summarized in docs/tools-deps.md.
(use ../../src/jolt/api)
(use ../../src/jolt/types)
(import ../../src/jolt/deps :as deps)
(use ../../src/jolt/reader)
# deps are clj/cljc libraries by definition (the jolt-dw4 premise): read them
# under clj-compat features so their #?(:clj ...) branches resolve (spec
# 02-reader S18 — features are a property of the loading context).
(reader-features-set! ["jolt" "clj" "default"])
(unless (os/getenv "JOLT_CONFORMANCE")
(print "deps-conformance: set JOLT_CONFORMANCE=1 to run (needs network) — skipped")
(os/exit 0))
(def libs
[{:name "medley" :url "https://github.com/weavejester/medley" :tag "1.4.0"
:ns "medley.core" :check "(medley.core/find-first odd? [2 4 5])" :expect "5"}
{:name "cuerdas" :url "https://github.com/funcool/cuerdas" :tag "2022.06.16-403"
:ns "cuerdas.core" :check "(cuerdas.core/kebab \"helloWorld\")" :expect "hello-world"}
{:name "dependency" :url "https://github.com/stuartsierra/dependency" :tag "dependency-1.0.0"
:ns "com.stuartsierra.dependency"
:check "(boolean (com.stuartsierra.dependency/graph))" :expect "true"}])
(def base (string (or (os/getenv "TMPDIR") "/tmp") "/jolt-conf-" (os/time)))
(os/mkdir base)
(defn- try-lib [lib]
(def dir (string base "/" (lib :name)))
(os/mkdir dir)
(spit (string dir "/deps.edn")
(string "{:deps {the/lib {:git/url \"" (lib :url) "\" :git/tag \"" (lib :tag) "\"}}}"))
(def prev (os/cwd))
(defer (os/cd prev)
(os/cd dir)
(def r (protect (deps/resolve-deps "deps.edn")))
(if (not (r 0))
[:resolve-failed (string (r 1))]
(let [ctx (init {:paths (r 1)})]
(ctx-set-current-ns ctx "user")
(def lr (protect (eval-string ctx (string "(require (quote [" (lib :ns) "]))"))))
(if (not (lr 0))
[:load-failed (string (lr 1))]
(let [cr (protect (eval-string ctx (lib :check)))]
(cond
(not (cr 0)) [:check-error (string (cr 1))]
(= (string (normalize-pvecs (cr 1))) (lib :expect)) [:ok nil]
[:check-mismatch (string "got " (string (normalize-pvecs (cr 1))))])))))))
(print "deps conformance — pure-cljc git libs:\n")
(each lib libs
(def [status detail] (try (try-lib lib) ([err] [:crash (string err)])))
(printf " %-12s %-16s %s" (lib :name) status (or detail "")))
(print "")
(os/exit 0)