test: fold phase ports into spec; promote compile-mode test
Mine the phase* port batteries into the spec layer and delete them (their
behavior is now covered by spec): phase5 (hierarchies), phase6 (tagged
literals/reader-conditionals), phase7 (lazy/sets), phase8+phase12 (protocols;
phase12 was a duplicate of phase8), phase10 (strings/set), phase13
(reify/walk). Unique cases mined into spec: reader #inst/#uuid/#?@ splice,
(Type. args) dot constructor, lazy-seq body-runs-once, keywordize-keys/
stringify-keys, custom :default key and explicit :hierarchy dispatch.
phase6-final tested the COMPILE-MODE path ({:compile? true}), distinct from the
interpreter-based spec — kept and renamed integration/compile-mode-test.
jpm test green, conformance 218/218.
This commit is contained in:
parent
3f5b42d784
commit
bcd0e42b33
13 changed files with 19 additions and 338 deletions
|
|
@ -27,4 +27,5 @@
|
|||
|
||||
(defspec "lazy / realized?"
|
||||
["unrealized" "false" "(realized? (lazy-seq (cons 1 nil)))"]
|
||||
["realized after" "true" "(let [s (lazy-seq (cons 1 nil))] (first s) (realized? s))"])
|
||||
["realized after" "true" "(let [s (lazy-seq (cons 1 nil))] (first s) (realized? s))"]
|
||||
["body runs once" "1" "(let [c (atom 0) s (lazy-seq (do (swap! c inc) [1 2 3]))] (seq s) (seq s) @c)"])
|
||||
|
|
|
|||
|
|
@ -25,4 +25,8 @@
|
|||
["ancestors" "true" "(do (derive ::c ::p) (derive ::p ::g) (contains? (ancestors ::c) ::g))"]
|
||||
["descendants" "true" "(do (derive ::c ::p) (contains? (descendants ::p) ::c))"]
|
||||
["dispatch via hierarchy" "\"animal\""
|
||||
"(do (derive ::dog ::animal) (defmulti speak identity) (defmethod speak ::animal [_] \"animal\") (speak ::dog))"])
|
||||
"(do (derive ::dog ::animal) (defmulti speak identity) (defmethod speak ::animal [_] \"animal\") (speak ::dog))"]
|
||||
["custom :default key" ":unknown"
|
||||
"(do (defmulti classify :type :default :other) (defmethod classify :a [_] :alpha) (defmethod classify :other [_] :unknown) (classify {:type :zzz}))"]
|
||||
["explicit :hierarchy" "\"a\""
|
||||
"(do (def h (derive (make-hierarchy) ::dog ::animal)) (defmulti snd identity :hierarchy h) (defmethod snd ::animal [_] \"a\") (snd ::dog))"])
|
||||
|
|
|
|||
|
|
@ -24,4 +24,6 @@
|
|||
["require :refer" "true" "(do (require '[clojure.string :refer [blank?]]) (blank? \"\"))"]
|
||||
["require :as + :refer" "true" "(do (require '[clojure.string :as s :refer [blank?]]) (and (blank? \"\") (= \"X\" (s/upper-case \"x\"))))"]
|
||||
["require clojure.set" "#{1 2 3}" "(do (require '[clojure.set :as set]) (set/union #{1 2} #{3}))"]
|
||||
["require clojure.walk" "{:a 2}" "(do (require '[clojure.walk :as w]) (w/postwalk (fn [x] (if (number? x) (inc x) x)) {:a 1}))"])
|
||||
["require clojure.walk" "{:a 2}" "(do (require '[clojure.walk :as w]) (w/postwalk (fn [x] (if (number? x) (inc x) x)) {:a 1}))"]
|
||||
["walk keywordize-keys" "{:a 1}" "(do (require '[clojure.walk :as w]) (w/keywordize-keys {\"a\" 1}))"]
|
||||
["walk stringify-keys" "true" "(do (require '[clojure.walk :as w]) (= {\"a\" 1} (w/stringify-keys {:a 1})))"])
|
||||
|
|
|
|||
|
|
@ -43,4 +43,8 @@
|
|||
["satisfies? false" "false"
|
||||
"(do (defprotocol P (m [_])) (defrecord R []) (satisfies? P (->R)))"]
|
||||
["instance? record" "true"
|
||||
"(do (defrecord R [a]) (instance? R (->R 1)))"])
|
||||
"(do (defrecord R [a]) (instance? R (->R 1)))"]
|
||||
["dot constructor" "5"
|
||||
"(do (deftype P [n]) (.-n (P. 5)))"]
|
||||
["dot ctor + method" "5"
|
||||
"(do (defprotocol G (val-of [_])) (deftype P [n] G (val-of [_] n)) (val-of (P. 5)))"])
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
["discard #_" "[1 3]" "[1 #_2 3]"]
|
||||
["regex literal" "true" "(= \"abc\" (re-find #\"abc\" \"xabcx\"))"]
|
||||
["reader conditional" "1" "#?(:clj 1 :cljs 2 :default 3)"]
|
||||
["reader cond splice" "[1 2 3]" "[#?@(:clj [1 2 3] :cljs [4 5])]"]
|
||||
["inst literal reads" "true" "(some? #inst \"2020-01-01T00:00:00Z\")"]
|
||||
["uuid literal" "\"550e8400-e29b-41d4-a716-446655440000\"" "(str #uuid \"550e8400-e29b-41d4-a716-446655440000\")"]
|
||||
["tagged literal var" "true" "(var? #'+)"]
|
||||
["deref sugar" "5" "(let [a (atom 5)] @a)"]
|
||||
["meta sugar" "{:t 1}" "(meta ^{:t 1} [])"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue