From 189a98881fc3d29ce173a019e2a154e4f6b9b7a3 Mon Sep 17 00:00:00 2001 From: Nicola Mometto Date: Fri, 18 Oct 2024 14:39:24 +0100 Subject: [PATCH] fix: use t.r reader so it works on older clojure versions --- .../clojure/tools/analyzer/jvm/core_test.clj | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/test/clojure/clojure/tools/analyzer/jvm/core_test.clj b/src/test/clojure/clojure/tools/analyzer/jvm/core_test.clj index 7828ac0..a0b88da 100644 --- a/src/test/clojure/clojure/tools/analyzer/jvm/core_test.clj +++ b/src/test/clojure/clojure/tools/analyzer/jvm/core_test.clj @@ -5,6 +5,7 @@ [clojure.tools.analyzer.env :as env] [clojure.tools.analyzer.passes.elide-meta :refer [elides elide-meta]] [clojure.tools.analyzer.ast :refer [postwalk]] + [clojure.tools.reader :as r] [clojure.test :refer [deftest is]])) (defprotocol p (f [_])) @@ -20,13 +21,16 @@ (env/with-env (ana.jvm/global-env) (postwalk (ana/analyze '~form e) elide-meta)))) +(defn ana [form] + (binding [ana/macroexpand-1 ana.jvm/macroexpand-1 + ana/create-var ana.jvm/create-var + ana/parse ana.jvm/parse + ana/var? var? + elides {:all #{:line :column :file}}] + (ana.jvm/analyze form e))) + (defmacro ast1 [form] - `(binding [ana/macroexpand-1 ana.jvm/macroexpand-1 - ana/create-var ana.jvm/create-var - ana/parse ana.jvm/parse - ana/var? var? - elides {:all #{:line :column :file}}] - (ana.jvm/analyze '~form e))) + `(ana '~form)) (defmacro mexpand [form] `(ana.jvm/macroexpand-1 '~form e)) @@ -108,3 +112,6 @@ (deftest analyze+eval-context-test (let [do-ast (ana.jvm/analyze+eval '(do 1 2 3))] (is (= :ctx/statement (-> do-ast :statements first :env :context))))) + +(deftest array_class + (is (ana (r/read-string "(fn [^{:tag int/2} x] (instance? int/2 x))"))))