General fixes shaken out by clojure/tools.reader
Running clojure.tools.reader's own suite on jolt surfaced a batch of general gaps (all runtime, JVM-certified, no re-mint — reader.ss is loaded at runtime and jolt-core has no octal literals, so selfhost holds): Reader: - (load "rel") resolves a non-/ path against the current namespace's directory, like Clojure — (load "common_tests") from clojure.tools.reader-test loads clojure/tools/common_tests.clj. Was resolved against the roots directly. - Octal integer literals: 042 reads as 34, not decimal 42; octal string escapes (\377 is one char, not \0 + "00"). \oNNN char octal already worked. - (symbol nil name) now equals (symbol name) and the reader literal — a nil namespace is the #f no-ns sentinel, not jolt-nil (jolt= compares ns by equal?). clojure.test: - thrown-with-msg? honors the class hierarchy (instance?) before falling back to a simple-name match, so (thrown-with-msg? RuntimeException ...) matches an ExceptionInfo, like thrown? already did. Host interop (java layer): - java.util.regex: Pattern.matcher / Matcher.matches / .group / .groupCount / .find, and Pattern/compile. - clojure.lang: RT/map, PersistentList/create, PersistentHashSet/createWithCheck. - java.lang.Character: digit / isDigit / isWhitespace / valueOf. - java.util.LinkedList (Deque surface over the ArrayList backing); ArrayList / LinkedList are now seqable. - BigInteger 2-arg ctor (string, radix) + .negate / .bitLength / .signum / .abs; BigInt/fromBigInteger and Numbers/reduceBigInt (identity on jolt's exact ints). Suite: reader_test 22/30, reader-edn_test 13/16. The remaining failures are fundamental numeric-model differences (no BigDecimal type; BigInt and Long are one exact-integer type) or need JVM reflection (record/ctor tagged literals via getConstructors) — out of scope. make test green (+8 corpus rows, 0 new divergences), shakesmoke byte-identical.
This commit is contained in:
parent
850a84c272
commit
e16085402b
9 changed files with 217 additions and 21 deletions
|
|
@ -264,13 +264,28 @@
|
|||
(def-var! "clojure.core" "use" loader-use)
|
||||
|
||||
(def-var! "clojure.core" "load-file" jolt-load-file)
|
||||
;; load: each arg is a "/"-rooted resource path like "/app/extra"; load the file
|
||||
;; for it relative to the search roots (strip the leading slash, try .clj/.cljc).
|
||||
|
||||
;; The directory of a namespace's resource path: "clojure.tools.reader-test" ->
|
||||
;; "clojure/tools" (drop the last segment of ns-name->rel). "" for a top-level ns.
|
||||
(define (ns-rel-dir name)
|
||||
(let* ((r (ns-name->rel name)))
|
||||
(let loop ((k (fx- (string-length r) 1)))
|
||||
(cond ((fx<? k 0) "")
|
||||
((char=? (string-ref r k) #\/) (substring r 0 k))
|
||||
(else (loop (fx- k 1)))))))
|
||||
|
||||
;; load: an arg starting with "/" is a root-relative resource path ("/app/extra");
|
||||
;; otherwise it is resolved against the CURRENT namespace's directory, matching
|
||||
;; Clojure — (load "common_tests") from clojure.tools.reader-test loads
|
||||
;; clojure/tools/common_tests.clj. Strip the leading slash / try .clj/.cljc.
|
||||
(define (jolt-load . paths)
|
||||
(for-each
|
||||
(lambda (p)
|
||||
(let* ((rel (if (and (> (string-length p) 0) (char=? (string-ref p 0) #\/))
|
||||
(substring p 1 (string-length p)) p))
|
||||
(let* ((rel (cond
|
||||
((and (> (string-length p) 0) (char=? (string-ref p 0) #\/))
|
||||
(substring p 1 (string-length p)))
|
||||
(else (let ((dir (ns-rel-dir (chez-current-ns))))
|
||||
(if (string=? dir "") p (string-append dir "/" p))))))
|
||||
(f (resolve-on-roots rel)))
|
||||
(if f (load-jolt-file f)
|
||||
(error #f "Could not locate resource on source roots" p))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue