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:
parent
bcd0e42b33
commit
a681daf7b9
24 changed files with 46 additions and 822 deletions
28
test/spec/exceptions-spec.janet
Normal file
28
test/spec/exceptions-spec.janet
Normal 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)))"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue