-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
info
: don't use a fallback for ns-qualified symbols
#134
Changes from 3 commits
3801e8f
2db7cb0
61234d9
3565c39
42b74ab
a0c45e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
(ns orchard.info-test | ||
(:require | ||
[clojure.test :as test :refer [deftest is testing use-fixtures]] | ||
[clojure.string :as str] | ||
[clojure.java.io :refer [resource]] | ||
[clojure.string :as str :refer [replace-first]] | ||
[clojure.test :refer [are deftest is testing use-fixtures]] | ||
[orchard.cljs.test-env :as test-env] | ||
[orchard.info :as info] | ||
[orchard.java :as java] | ||
[orchard.misc :as misc] | ||
[clojure.java.io :refer [resource]] | ||
[orchard.cljs.test-env :as test-env] | ||
[orchard.test-ns])) | ||
|
||
@java/cache-initializer ;; make tests more deterministic | ||
|
@@ -352,7 +352,8 @@ | |
|
||
(deftest info-macros-referred-var-test | ||
(testing "Macro - referred" | ||
(let [params '[{:sym orchard.test-ns/my-add} | ||
(let [params '[{:sym orchard.test-ns/my-add}, | ||
|
||
{:ns orchard.test-ns | ||
:sym my-add}] | ||
expected '{:name my-add | ||
|
@@ -368,7 +369,7 @@ | |
(map #(select-keys % [:ns :name :arglists :macro :file])))))) | ||
|
||
(testing "- :clj" | ||
(is (= (take 2 (repeat expected)) | ||
(is (= [{}, expected] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed this expectation, |
||
(->> params | ||
(map #(info/info* %)) | ||
(map #(select-keys % [:ns :name :arglists :macro :file]))))))))) | ||
|
@@ -467,21 +468,43 @@ | |
:returns int})) | ||
(is (re-find #"Returns the greater of two" (:doc i)))))) | ||
|
||
(def some-var nil) | ||
|
||
(deftest info-undefined-namespace-test | ||
(testing "Fully qualified sym can still be resolved" | ||
(is (= '{:added "1.2" | ||
:ns clojure.string | ||
:name upper-case | ||
:file "clojure/string.clj"} | ||
(select-keys (info/info* {:ns 'gibberish :sym 'clojure.string/upper-case}) | ||
[:added :ns :name :file])))) | ||
(testing "clojure.core syms can still be resolved" | ||
(is (= '{:added "1.0" | ||
:ns clojure.core | ||
:name merge | ||
:file "clojure/core.clj"} | ||
(select-keys (info/info* {:ns 'gibberish :sym 'merge}) | ||
[:added :ns :name :file]))))) | ||
(let [current-ns (-> ::_ namespace symbol)] | ||
(are [input expected] (= expected | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we can agree to disagree? I didn't use an Normally to reach this level of exhaustiveness with manually coded tests, one would have to take 1 to 2 'screenfuls' worth of code. That's generally not too readable - it's so wordy that it's hard to compare the test cases between them. Normally people give up before even attempting this level of exhaustiveness, so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can live with this, I simply don't like it. Too many years of writing RSpecs I guess. :-) There's also the practical problem that CIDER's test runner doesn't work well with |
||
(select-keys (info/info* input) | ||
[:added :ns :name :file])) | ||
{:ns current-ns :sym 'some-var} '{:ns orchard.info-test, | ||
:name some-var, | ||
:file "orchard/info_test.clj"} | ||
{:ns current-ns :sym 'replace-first} '{:added "1.2", | ||
:ns clojure.string, | ||
:name replace-first, | ||
:file "clojure/string.clj"} | ||
{:ns current-ns :sym 'merge} '{:added "1.0" | ||
:ns clojure.core | ||
:name merge | ||
:file "clojure/core.clj"} | ||
{:ns current-ns :sym 'non.existing.ns/merge} {} | ||
{:ns current-ns :sym 'clojure.string/upper-case} '{:added "1.2" | ||
:ns clojure.string | ||
:name upper-case | ||
:file "clojure/string.clj"} | ||
{:ns current-ns :sym 'non.existing.ns/upper-case} {} | ||
|
||
{:ns 'gibberish :sym 'some-var} {} | ||
{:ns 'gibberish :sym 'replace-first} {} | ||
{:ns 'gibberish :sym 'merge} '{:added "1.0" | ||
:ns clojure.core | ||
:name merge | ||
:file "clojure/core.clj"} | ||
{:ns 'gibberish :sym 'non.existing.ns/merge} {} | ||
{:ns 'gibberish :sym 'clojure.string/upper-case} '{:added "1.2" | ||
:ns clojure.string | ||
:name upper-case | ||
:file "clojure/string.clj"} | ||
{:ns 'gibberish :sym 'non.existing.ns/upper-case} {}))) | ||
|
||
(deftest javadoc-info-unit-test | ||
(testing "Get an HTTP URL for a Sun/Oracle Javadoc" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
|
||
(deftest project-resources-test | ||
(testing "get the correct resources for the orchard project" | ||
(let [resources (resource/project-resources)] | ||
(let [resources (->> (resource/project-resources) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was wrong with this test before? There were more resources returned or something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes especially in local envs where there can be more resources for arbitrary reasons. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. |
||
(filter (fn [{:keys [relpath]}] | ||
(= relpath "clojuredocs/test_export.edn"))))] | ||
(is (= "clojuredocs/test_export.edn" (-> resources first :relpath))) | ||
(is (= java.net.URL (-> resources first :url class)))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed these two lines, I don't think they make sense. If one is explicitly querying
:sym foo/+
(i.e. fully-qualified), then trying to resolve+
withoutfoo
is not accurate.The comment says
maybe referred
. But(some-> ns (m/resolve-var sym) (m/var-meta))
a few lines above already handles refers, that's part of whatresolve-var
/ns-resolve
do