File tree Expand file tree Collapse file tree
src/test/clojure/clojure/tools/analyzer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 [clojure.tools.analyzer.utils :refer [compile-if]]
99 [clojure.tools.analyzer.passes.index-vector-nodes :refer [index-vector-nodes]]))
1010
11+ (def clojure-version-seven-query
12+ '[:find ?docstring
13+ :where
14+ [?def :op :def ]
15+ [?def :init ?fn]
16+ [?fn :methods ?method]
17+ [?method :body ?body]
18+ [?body :statements ?statement]
19+ [?statement :val ?docstring]
20+ [?statement :type :string ]
21+ [?statement :idx 0 ]])
22+
23+ (def clojure-version-eight-and-above-query
24+ '[:find ?docstring
25+ :where
26+ [?def :op :def ]
27+ [?def :init ?fn]
28+ [?fn :expr ?expr]
29+ [?expr :methods ?method]
30+ [?method :body ?body]
31+ [?body :statements ?statement]
32+ [?statement :val ?docstring]
33+ [?statement :type :string ]
34+ [?statement :idx 0 ]])
35+
1136(compile-if (Class/forName " datomic.Datom" )
1237 (deftest query
13- (let [ast (ast/prewalk (ast (defn x [] " misplaced docstring" 1 ))
14- index-vector-nodes)]
38+ (let [ast (ast/prewalk (ast (defn x [] " misplaced docstring" 1 ))
39+ index-vector-nodes)
40+ the-query (if (< (:minor *clojure-version*) 8 )
41+ clojure-version-seven-query
42+ clojure-version-eight-and-above-query)]
1543 (is (= " misplaced docstring"
16- (ffirst
17- (q '[:find ?docstring
18- :where
19- [?def :op :def ]
20- [?def :init ?fn]
21- [?fn :methods ?method]
22- [?method :body ?body]
23- [?body :statements ?statement]
24- [?statement :val ?docstring]
25- [?statement :type :string ]
26- [?statement :idx 0 ]]
27- [ast])))))))
44+ (ffirst (q the-query [ast])))))))
You can’t perform that action at this time.
0 commit comments