-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't prune
require
forms if they are needed for a given import
t…
- Loading branch information
Showing
8 changed files
with
157 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns defines-deftype) | ||
|
||
(defrecord SomeDefType []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
(ns refactor-nrepl.ns.prune-dependencies-test | ||
(:require | ||
[clojure.test :refer [are deftest]] | ||
[refactor-nrepl.ns.prune-dependencies :as sut])) | ||
|
||
(deftest imports->namespaces | ||
(are [input expected] (= expected | ||
(sut/imports->namespaces input)) | ||
['java.io.File] #{'java.io} | ||
['my_ns.File] #{'my-ns} | ||
['[java.io File]] #{'java.io} | ||
['[java.io File FileReader]] #{'java.io} | ||
['(java.io File)] #{'java.io} | ||
['java.io.File | ||
'my_ns.File | ||
'[java.io File] | ||
'(java.io File)] #{'java.io 'my-ns})) | ||
|
||
(deftest libspec->namespaces | ||
(are [input expected] (= expected | ||
(sut/libspec->namespaces input)) | ||
'foo.bar | ||
'[foo.bar], | ||
|
||
'[foo.bar] | ||
'[foo.bar], | ||
|
||
'[foo.bar :as bar] | ||
'[foo.bar], | ||
|
||
'[clojure data edn | ||
[instant :as inst :reload true] | ||
[pprint :refer [cl-format formatter get-pretty-writer]] | ||
[string :refer :all :reload-all true] | ||
[test :refer :all] | ||
[walk :refer [postwalk prewalk]] | ||
xml] | ||
'[clojure.data clojure.edn clojure.instant clojure.pprint clojure.string clojure.test clojure.walk clojure.xml])) | ||
|
||
(deftest imports-contain-libspec? | ||
(are [imports libspec expected] (= expected | ||
(sut/imports-contain-libspec? (sut/imports->namespaces imports) | ||
libspec)) | ||
#_imports #_libspec #_expected | ||
'[] 'foo.bar false | ||
'[foo.bar.SomeType] 'foo.bar true | ||
'[foo_bar.SomeType] 'foo-bar true | ||
'[[foo.bar SomeType]] 'foo.bar true | ||
'[[foo_bar SomeType]] 'foo-bar true | ||
'[foo.bar.SomeType] 'foo.baz false | ||
'[] '[foo.bar] false | ||
'[foo.bar.SomeType] '[foo.bar] true | ||
'[foo.bar.SomeType] '[foo.bar :as f] true | ||
'[[foo.bar SomeType]] '[foo.bar] true | ||
'[[foo_bar SomeType]] '[foo-bar :as f] true | ||
'[foo_bar.SomeType] '[foo-bar :as f] true | ||
'[[foo_bar SomeType]] '[foo-bar] true | ||
'[[foo_bar SomeType]] '[foo-bar :as f] true | ||
'[foo.bar.SomeType] '[foo.baz] false | ||
'[clojure.data.Data] '[clojure data] true | ||
'[clojure.data.Data] '[clojure [data :as d]] true | ||
'[clojure.data.Data] '[clojure foo] false)) |