test: fold cljs ports into spec; add exceptions spec + gap coverage

Mine the cljs port batteries into the spec layer and delete them (their behavior
is covered by spec; the unique functions they exercised are now specced).
Removed test/integration/ports/ entirely.

New/expanded spec coverage from the mining:
- spec/exceptions-spec: try/catch/finally, throw, ex-info/ex-message/ex-data/ex-cause
- doto, pr-str, keyword/symbol constructors, atom?, dynamic var binding

Two rare edges filed (jolt-...): rethrow of a caught ex-info re-wraps it; var-set
on a dynamic var inside binding no-ops. Core try/catch/ex-info and binding work.

Test layout is now spec (22 files, ~677 cases) / integration / unit / support.
conformance 218/218, jpm test green.
This commit is contained in:
Yogthos 2026-06-05 01:12:39 -04:00
parent bcd0e42b33
commit a681daf7b9
24 changed files with 46 additions and 822 deletions

View file

@ -59,4 +59,5 @@
["some-> nil stops" "nil" "(some-> nil inc)"]
["some->>" "[2 3]" "(some->> [1 2] (map inc))"]
["cond->" "2" "(cond-> 1 true inc false inc)"]
["cond->>" "[1 2]" "(cond->> [2] true (cons 1))"])
["cond->>" "[1 2]" "(cond->> [2] true (cons 1))"]
["doto returns subject" "5" "(let [a (doto (atom 0) (reset! 5))] @a)"])

View file

@ -0,0 +1,28 @@
# Specification: exceptions — try/catch/finally, throw, ex-info.
(use ../support/harness)
(defspec "exceptions / try-catch"
["catch :default" ":caught"
"(try (throw (ex-info \"boom\" {})) (catch :default e :caught))"]
["catch by class" ":caught"
"(try (throw (ex-info \"boom\" {})) (catch Exception e :caught))"]
["catch binds error" "\"boom\""
"(try (throw (ex-info \"boom\" {})) (catch :default e (ex-message e)))"]
["no throw -> body" "1"
"(try 1 (catch :default e :caught))"]
["finally runs on ok" "2"
"(let [a (atom 0)] (try 2 (finally (reset! a 9))) )"]
["finally runs on throw" "9"
"(let [a (atom 0)] (try (throw (ex-info \"x\" {})) (catch :default e nil) (finally (reset! a 9))) @a)"]
["catch value of body" "5"
"(try (+ 2 3) (catch :default e 0))"])
(defspec "exceptions / ex-info"
["ex-message" "\"oops\"" "(ex-message (ex-info \"oops\" {}))"]
["ex-data" "{:k 1}" "(ex-data (ex-info \"oops\" {:k 1}))"]
["ex-data via catch" "{:code 42}"
"(try (throw (ex-info \"e\" {:code 42})) (catch :default e (ex-data e)))"]
["ex-cause" "true"
"(let [c (ex-info \"root\" {})] (= c (ex-cause (ex-info \"outer\" {} c))))"]
["propagates to outer" "\"inner\""
"(try (try (throw (ex-info \"inner\" {})) (finally nil)) (catch :default e (ex-message e)))"])

View file

@ -9,7 +9,9 @@
["var sugar #'" "true" "(var? #'+)"]
["var-get" "5" "(do (def w 5) (var-get #'w))"]
["defn defines fn" "3" "(do (defn f [x] (inc x)) (f 2))"]
["def with docstring" "7" "(do (def d \"a doc\" 7) d)"])
["def with docstring" "7" "(do (def d \"a doc\" 7) d)"]
["dynamic var binding" "2" "(do (def ^:dynamic *x* 1) (binding [*x* 2] *x*))"]
["binding restores" "1" "(do (def ^:dynamic *y* 1) (binding [*y* 9] nil) *y*)"])
(defspec "namespaces / ns operations"
["in-ns switches" "true" "(do (in-ns 'my.ns) (symbol? 'x))"]

View file

@ -47,7 +47,11 @@
["name of keyword" "\"a\"" "(name :a)"]
["name of qualified" "\"b\"" "(name :a/b)"]
["namespace" "\"a\"" "(namespace :a/b)"]
["namespace simple" "nil" "(namespace :a)"])
["namespace simple" "nil" "(namespace :a)"]
["keyword constructor" ":foo" "(keyword \"foo\")"]
["keyword ns + name" ":a/b" "(keyword \"a\" \"b\")"]
["symbol constructor" "(quote x)" "(symbol \"x\")"]
["name of string" "\"s\"" "(name \"s\")"])
(defspec "predicates / equality & identity"
["= same" "true" "(= 1 1)"]

View file

@ -13,7 +13,9 @@
["reset-vals!" "[0 9]" "(let [a (atom 0)] (reset-vals! a 9))"]
["compare-and-set! ok" "true" "(let [a (atom 0)] (compare-and-set! a 0 1))"]
["compare-and-set! no" "false" "(let [a (atom 0)] (compare-and-set! a 9 1))"]
["atom?" "true" "(do (require (quote [clojure.core])) (instance? clojure.lang.Atom (atom 0)))"])
["atom?" "true" "(do (require (quote [clojure.core])) (instance? clojure.lang.Atom (atom 0)))"]
["atom? predicate" "true" "(atom? (atom 0))"]
["atom? on non-atom" "false" "(atom? 5)"])
(defspec "state / watches & validators"
["add-watch fires" "1" "(let [a (atom 0) seen (atom 0)] (add-watch a :k (fn [k r o n] (reset! seen 1))) (reset! a 5) @seen)"]

View file

@ -11,6 +11,8 @@
["subs from" "\"bc\"" "(subs \"abc\" 1)"]
["subs range" "\"b\"" "(subs \"abc\" 1 2)"]
["string? true" "true" "(string? \"x\")"]
["pr-str vector" "\"[1 2 3]\"" "(pr-str [1 2 3])"]
["pr-str quotes str" "\"\\\"hi\\\"\"" "(pr-str \"hi\")"]
["seq of string" "[\\a \\b]" "(seq \"ab\")"])
(defspec "clojure.string"