diff --git a/project.clj b/project.clj index 13d98d0..a842b3d 100644 --- a/project.clj +++ b/project.clj @@ -9,7 +9,7 @@ :url "https://github.com/clj-commons/kibit" :connection "scm:git:git://github.com/clj-commons/kibit.git" :developerConnection "scm:git:ssh://git@github.com/clj-commons/kibit.git"} - :dependencies [[org.clojure/clojure "1.8.0"] + :dependencies [[org.clojure/clojure "1.11.1"] [org.clojure/core.logic "1.1.0"] [org.clojure/tools.cli "1.1.230"] [rewrite-clj "1.1.47"] diff --git a/src/kibit/check/reader.clj b/src/kibit/check/reader.clj index d835677..9ba4db3 100644 --- a/src/kibit/check/reader.clj +++ b/src/kibit/check/reader.clj @@ -69,8 +69,8 @@ (rest form)) (option-spec? form) - (let [[_ as? form-alias] form] - (deps-from-libspec prefix (first form) (when (= :as as?) form-alias))) + (let [opts (apply hash-map (next form))] + (deps-from-libspec prefix (first form) (or (:as opts) (:as-alias opts)))) (symbol? form) (list (with-meta diff --git a/test/kibit/test/core.clj b/test/kibit/test/core.clj index af366c1..7ada2a3 100644 --- a/test/kibit/test/core.clj +++ b/test/kibit/test/core.clj @@ -15,7 +15,8 @@ "Hello" '(do "Hello") '(when test then) '(do (when test then)) :one '(do :one) - {:one 1} '(do {:one 1}))) + {:one 1} '(do {:one 1}) + #{:a :b} '#{(do :a) (do :b)})) ;; This test confirms when checking will happen and when it won't (deftest simplify-exprs diff --git a/test/kibit/test/driver.clj b/test/kibit/test/driver.clj index 3e88ebc..24f9b88 100644 --- a/test/kibit/test/driver.clj +++ b/test/kibit/test/driver.clj @@ -12,9 +12,12 @@ false "test.resources/fourth.txt")) (deftest find-clojure-sources-are - (is (= [(io/file "test/resources/first.clj") + (is (= [(io/file "test/resources/as_alias.clj") + (io/file "test/resources/double_pound_reader_macros.clj") + (io/file "test/resources/first.clj") (io/file "test/resources/keyword_suggestions.clj") (io/file "test/resources/keywords.clj") + (io/file "test/resources/namespaced_maps.clj") (io/file "test/resources/reader_conditionals.cljc") (io/file "test/resources/second.cljx") (io/file "test/resources/sets.clj") @@ -44,5 +47,20 @@ (map #(select-keys % [:expr :alt]) (driver/run ["test/resources/keyword_suggestions.clj"] nil "--reporter" "no-op"))))) -(deftest process-cljc-file - (is (driver/run ["test/resources/reader_conditionals.cljc"] nil))) +(defmacro with-err-str + [& body] + `(let [s# (java.io.StringWriter.)] + (binding [*err* s#] + ~@body + (str s#)))) + +(deftest process-reader-macros + (is (= ["" "" "" ""] + [(with-err-str + (driver/run ["test/resources/reader_conditionals.cljc"] nil)) + (with-err-str + (driver/run ["test/resources/double_pound_reader_macros.clj"] nil)) + (with-err-str + (driver/run ["test/resources/namespaced_maps.clj"] nil)) + (with-err-str + (driver/run ["test/resources/as_alias.clj"] nil))]))) diff --git a/test/resources/as_alias.clj b/test/resources/as_alias.clj new file mode 100644 index 0000000..fa7b635 --- /dev/null +++ b/test/resources/as_alias.clj @@ -0,0 +1,5 @@ +(ns resources.as-alias + (:require + [foo.bar :a :b :as-alias fb])) + +::fb/example diff --git a/test/resources/double_pound_reader_macros.clj b/test/resources/double_pound_reader_macros.clj new file mode 100644 index 0000000..e797502 --- /dev/null +++ b/test/resources/double_pound_reader_macros.clj @@ -0,0 +1 @@ +[##Inf ##-Inf ##NaN] diff --git a/test/resources/namespaced_maps.clj b/test/resources/namespaced_maps.clj new file mode 100644 index 0000000..f1bd4e9 --- /dev/null +++ b/test/resources/namespaced_maps.clj @@ -0,0 +1 @@ +#:car{:make "Jeep" :model "Wrangler"}