|
25 | 25 | PersistentVector PersistentArrayMap PersistentHashSet ISeq) |
26 | 26 | java.util.regex.Pattern |
27 | 27 | (java.io File) |
28 | | - (java.util UUID Arrays))) |
| 28 | + (java.util UUID Arrays) |
| 29 | + clojure.tools.analyzer.jvm.test.FieldMethodOverload)) |
29 | 30 |
|
30 | 31 | (defn validate [ast] |
31 | 32 | (env/with-env (ana.jvm/global-env) |
|
199 | 200 | (let [a (ana (r/read-string "^[long] String/valueOf"))] |
200 | 201 | (is (= :method-value (:op a))) |
201 | 202 | (is (:validated? a)) |
202 | | - (is (= 1 (count (:methods a))))) |
| 203 | + (is (= 1 (count (:methods a)))) |
| 204 | + (is (= '[long] (-> a :methods first :parameter-types)))) |
203 | 205 |
|
204 | 206 | (let [a (ana (r/read-string "^[int int] String/.substring"))] |
205 | 207 | (is (= :method-value (:op a))) |
206 | 208 | (is (:validated? a)) |
207 | | - (is (= 1 (count (:methods a)))))) |
| 209 | + (is (= 1 (count (:methods a)))) |
| 210 | + (is (= '[int int] (-> a :methods first :parameter-types))))) |
208 | 211 |
|
209 | 212 | (deftest method-value-kinds-test |
210 | 213 | (let [a (ast1 File/.isDirectory)] |
|
305 | 308 | (let [a (ana (r/read-string "^[double] Math/abs"))] |
306 | 309 | (is (= :method-value (:op a))) |
307 | 310 | (is (= 1 (count (:methods a)))) |
| 311 | + (is (= '[double] (-> a :methods first :parameter-types))) |
308 | 312 | (is (:validated? a))) |
309 | 313 |
|
310 | 314 | (let [a (ana (r/read-string "^[float] Math/abs"))] |
311 | 315 | (is (= :method-value (:op a))) |
312 | 316 | (is (= 1 (count (:methods a)))) |
| 317 | + (is (= '[float] (-> a :methods first :parameter-types))) |
313 | 318 | (is (:validated? a))) |
314 | 319 |
|
315 | 320 | (let [a (ana (r/read-string "^[long] Math/abs"))] |
316 | 321 | (is (= :method-value (:op a))) |
317 | 322 | (is (= 1 (count (:methods a)))) |
| 323 | + (is (= '[long] (-> a :methods first :parameter-types))) |
318 | 324 | (is (:validated? a))) |
319 | 325 |
|
320 | 326 | (let [a (ana (r/read-string "^[int] Math/abs"))] |
321 | 327 | (is (= :method-value (:op a))) |
322 | 328 | (is (= 1 (count (:methods a)))) |
| 329 | + (is (= '[int] (-> a :methods first :parameter-types))) |
323 | 330 | (is (:validated? a)))) |
324 | 331 |
|
325 | 332 | (deftest param-tags-constructor-invocation-test |
|
354 | 361 | (let [a (ana (r/read-string "^[long/1 long] java.util.Arrays/binarySearch"))] |
355 | 362 | (is (= :method-value (:op a))) |
356 | 363 | (is (= 1 (count (:methods a)))) |
| 364 | + (is (= '[long<> long] (-> a :methods first :parameter-types))) |
357 | 365 | (is (:validated? a))) |
358 | 366 |
|
359 | 367 | (let [a (ana (r/read-string "^[Object/1 _] java.util.Arrays/binarySearch"))] |
360 | 368 | (is (= :method-value (:op a))) |
361 | 369 | (is (= 1 (count (:methods a)))) |
| 370 | + (is (= '[java.lang.Object<> java.lang.Object] (-> a :methods first :parameter-types))) |
362 | 371 | (is (:validated? a)))) |
363 | 372 |
|
364 | 373 | (deftest bad-param-tags-test |
365 | 374 | (is (thrown? ExceptionInfo (ana (r/read-string "^[String String] Math/abs")))) |
366 | 375 | (is (thrown? ExceptionInfo (ana (r/read-string "(^[] String/foo \"a\")")))) |
367 | 376 | (is (thrown? ExceptionInfo (ana (r/read-string "(^[] String/.foo \"a\")")))) |
368 | 377 | (is (thrown? ExceptionInfo (ana (r/read-string "(^[String String String] java.util.UUID/new 1 2 3)"))))) |
| 378 | + |
| 379 | +(deftest field-method-overload-test |
| 380 | + (let [a (ast1 clojure.tools.analyzer.jvm.test.FieldMethodOverload/doppelganger)] |
| 381 | + (is (= :static-field (:op a)))) |
| 382 | + |
| 383 | + (let [a (ana (r/read-string "^[] clojure.tools.analyzer.jvm.test.FieldMethodOverload/doppelganger"))] |
| 384 | + (is (= :method-value (:op a))) |
| 385 | + (is (= 1 (count (:methods a)))) |
| 386 | + (is (= '[] (-> a :methods first :parameter-types)))) |
| 387 | + |
| 388 | + (let [a (ast1 (clojure.tools.analyzer.jvm.test.FieldMethodOverload/doppelganger))] |
| 389 | + (is (= :static-call (:op a))) |
| 390 | + (is (:validated? a))) |
| 391 | + |
| 392 | + (let [a (ast1 (clojure.tools.analyzer.jvm.test.FieldMethodOverload/doppelganger (int 1) (int 2)))] |
| 393 | + (is (= :static-call (:op a))) |
| 394 | + (is (:validated? a)))) |
0 commit comments