|
14 | 14 | [clojure.reflect :as r] |
15 | 15 | [clojure.test-helper :refer [should-not-reflect]]) |
16 | 16 | (:import |
17 | | - (clojure.test SwissArmy ConcreteClass) |
18 | | - (clojure.lang Tuple Compiler Compiler$CompilerException) |
19 | | - (java.util Arrays UUID Locale))) |
| 17 | + #_(clojure.test SwissArmy ConcreteClass) |
| 18 | + #_(clojure.lang Tuple Compiler Compiler$CompilerException) |
| 19 | + #_(java.util Arrays UUID Locale))) |
20 | 20 |
|
21 | 21 | (set! *warn-on-reflection* true) |
22 | 22 |
|
23 | | -(deftest no-hints-with-param-tags |
| 23 | +#_(deftest no-hints-with-param-tags |
24 | 24 | (should-not-reflect |
25 | 25 | (defn touc-no-reflect [s] |
26 | 26 | (^[] String/.toUpperCase s))) |
|
34 | 34 | (defn no-overloads-no-reflect [v] |
35 | 35 | (java.time.OffsetDateTime/.getYear v)))) |
36 | 36 |
|
37 | | -(deftest no-param-tags-use-qualifier |
| 37 | +#_(deftest no-param-tags-use-qualifier |
38 | 38 | ;; both Date and OffsetDateTime have .getYear - want to show here the qualifier is used |
39 | 39 | (let [f (fn [^java.util.Date d] (java.time.OffsetDateTime/.getYear d)) |
40 | 40 | date (java.util.Date. 1714495523100)] |
|
45 | 45 | (is (thrown? ClassCastException |
46 | 46 | (f date))))) |
47 | 47 |
|
48 | | -(deftest param-tags-in-invocation-positions |
| 48 | +#_(deftest param-tags-in-invocation-positions |
49 | 49 | (testing "qualified static method invocation" |
50 | 50 | (is (= 3 (^[long] Math/abs -3))) |
51 | 51 | (is (= [1 2] (^[_ _] Tuple/create 1 2))) |
|
77 | 77 | ;; Mapping of symbols returned from reflect call to :parameter-type used as arguments to .getDeclaredMethod, |
78 | 78 | ;; :arg-type used as arguments to the methods and constructors being tested, :arg-tag used as arg-tags |
79 | 79 | ;; to the methods and constructors being tested. |
80 | | -(def reflected-parameter-types {'int {:parameter-type Integer/TYPE |
| 80 | +#_(def reflected-parameter-types {'int {:parameter-type Integer/TYPE |
81 | 81 | :arg-type "(int 42)" |
82 | 82 | :arg-tag "int"} |
83 | 83 | 'boolean {:parameter-type Boolean/TYPE |
|
99 | 99 | :arg-type "(into-array [\"a\" \"b\"])" |
100 | 100 | :arg-tag "\"[Ljava.lang.String;\""}}) |
101 | 101 |
|
102 | | -(defn is-static-method? [class method-name params] |
| 102 | +#_(defn is-static-method? [class method-name params] |
103 | 103 | (let [method (.getDeclaredMethod ^Class class ^String (name method-name) ^"[Ljava.lang.Object;" params)] |
104 | 104 | (java.lang.reflect.Modifier/isStatic (.getModifiers method)))) |
105 | 105 |
|
106 | | -(defn get-methods |
| 106 | +#_(defn get-methods |
107 | 107 | "Reflect the class located at `path`, filter out the public members, add a :type |
108 | 108 | of :constructor, :static, or :instance to each." |
109 | 109 | [path] |
|
118 | 118 | :else (conj res (assoc m :type :instance))))) |
119 | 119 | [] public))) |
120 | 120 |
|
121 | | -(defn exercise-constructor |
| 121 | +#_(defn exercise-constructor |
122 | 122 | "Provided a map of data returned from a call to reflect representing a constructor. |
123 | 123 | Construct a new instance of the class providing the appropriate arg-tags and return |
124 | 124 | a map containing the new instance and expected target class" |
|
131 | 131 | new-instance (eval fun-call-str)] |
132 | 132 | {:expected target-class :actual new-instance})) |
133 | 133 |
|
134 | | -(defn exercise-static-method |
| 134 | +#_(defn exercise-static-method |
135 | 135 | "Provided a map of data returned from a call to reflect representing a static class method. |
136 | 136 | Call the static method providing the appropriate arg-tags and return a map containing |
137 | 137 | the actual and expected response." |
|
146 | 146 | response (eval fun-call-str)] |
147 | 147 | {:expected expected-response :actual response})) |
148 | 148 |
|
149 | | -(defn exercise-instance-method |
| 149 | +#_(defn exercise-instance-method |
150 | 150 | "Provided a map of data returned from a call to reflect representing a class instance method. |
151 | 151 | Call the method providing the appropriate arg-tags and return a map containing |
152 | 152 | the actual and expected response." |
|
160 | 160 | response (eval fun-call-str)] |
161 | 161 | {:expected expected-response :actual response})) |
162 | 162 |
|
163 | | -(deftest arg-tags-in-constructors-and-static-and-instance-methods |
| 163 | +#_(deftest arg-tags-in-constructors-and-static-and-instance-methods |
164 | 164 | (doseq [m (get-methods 'clojure.test.SwissArmy)] |
165 | 165 | (case (:type m) |
166 | 166 | :constructor (let [{:keys [expected actual]} (exercise-constructor m)] |
|
170 | 170 | :instance (let [{:keys [expected actual]} (exercise-instance-method m)] |
171 | 171 | (is (= expected actual)))))) |
172 | 172 |
|
173 | | -(defmacro arg-tags-called-in-macro |
| 173 | +#_(defmacro arg-tags-called-in-macro |
174 | 174 | [a-type b-type a b] |
175 | 175 | `(^[~a-type ~b-type] SwissArmy/staticArityOverloadMethod ~a ~b)) |
176 | 176 |
|
177 | | -(deftest arg-tags-in-macro |
| 177 | +#_(deftest arg-tags-in-macro |
178 | 178 | (is (= "int-int" (arg-tags-called-in-macro int int 1 2)))) |
179 | 179 |
|
180 | | -(deftest bridge-methods |
| 180 | +#_(deftest bridge-methods |
181 | 181 | (testing "Allows correct intended usage." |
182 | 182 | (let [concrete (ConcreteClass.)] |
183 | 183 | (is (= 42 (^[Integer] ConcreteClass/.stampWidgets concrete (int 99)))))) |
|
187 | 187 | (^[Object] ConcreteClass/.stampWidgets concrete (int 99)))))))) |
188 | 188 |
|
189 | 189 |
|
190 | | -(deftest incorrect-arity-invocation-error-messages |
| 190 | +#_(deftest incorrect-arity-invocation-error-messages |
191 | 191 |
|
192 | 192 | (testing "Invocation with param-tags having incorrect number of args" |
193 | 193 | (let [e (try |
|
0 commit comments