Skip to content

Commit 7a9260d

Browse files
committed
more tests
1 parent 11ff2fc commit 7a9260d

3 files changed

Lines changed: 46 additions & 3 deletions

File tree

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
</dependency>
4747
</dependencies>
4848

49+
<build>
50+
<testSourceDirectory>src/test/java</testSourceDirectory>
51+
</build>
52+
4953
<scm>
5054
<connection>scm:git:git://github.com/clojure/tools.analyzer.jvm.git</connection>
5155
<developerConnection>scm:git:git://github.com/clojure/tools.analyzer.jvm.git</developerConnection>

src/test/clojure/clojure/tools/analyzer/jvm/passes_test.clj

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
PersistentVector PersistentArrayMap PersistentHashSet ISeq)
2626
java.util.regex.Pattern
2727
(java.io File)
28-
(java.util UUID Arrays)))
28+
(java.util UUID Arrays)
29+
clojure.tools.analyzer.jvm.test.FieldMethodOverload))
2930

3031
(defn validate [ast]
3132
(env/with-env (ana.jvm/global-env)
@@ -199,12 +200,14 @@
199200
(let [a (ana (r/read-string "^[long] String/valueOf"))]
200201
(is (= :method-value (:op a)))
201202
(is (:validated? a))
202-
(is (= 1 (count (:methods a)))))
203+
(is (= 1 (count (:methods a))))
204+
(is (= '[long] (-> a :methods first :parameter-types))))
203205

204206
(let [a (ana (r/read-string "^[int int] String/.substring"))]
205207
(is (= :method-value (:op a)))
206208
(is (:validated? a))
207-
(is (= 1 (count (:methods a))))))
209+
(is (= 1 (count (:methods a))))
210+
(is (= '[int int] (-> a :methods first :parameter-types)))))
208211

209212
(deftest method-value-kinds-test
210213
(let [a (ast1 File/.isDirectory)]
@@ -305,21 +308,25 @@
305308
(let [a (ana (r/read-string "^[double] Math/abs"))]
306309
(is (= :method-value (:op a)))
307310
(is (= 1 (count (:methods a))))
311+
(is (= '[double] (-> a :methods first :parameter-types)))
308312
(is (:validated? a)))
309313

310314
(let [a (ana (r/read-string "^[float] Math/abs"))]
311315
(is (= :method-value (:op a)))
312316
(is (= 1 (count (:methods a))))
317+
(is (= '[float] (-> a :methods first :parameter-types)))
313318
(is (:validated? a)))
314319

315320
(let [a (ana (r/read-string "^[long] Math/abs"))]
316321
(is (= :method-value (:op a)))
317322
(is (= 1 (count (:methods a))))
323+
(is (= '[long] (-> a :methods first :parameter-types)))
318324
(is (:validated? a)))
319325

320326
(let [a (ana (r/read-string "^[int] Math/abs"))]
321327
(is (= :method-value (:op a)))
322328
(is (= 1 (count (:methods a))))
329+
(is (= '[int] (-> a :methods first :parameter-types)))
323330
(is (:validated? a))))
324331

325332
(deftest param-tags-constructor-invocation-test
@@ -354,15 +361,34 @@
354361
(let [a (ana (r/read-string "^[long/1 long] java.util.Arrays/binarySearch"))]
355362
(is (= :method-value (:op a)))
356363
(is (= 1 (count (:methods a))))
364+
(is (= '[long<> long] (-> a :methods first :parameter-types)))
357365
(is (:validated? a)))
358366

359367
(let [a (ana (r/read-string "^[Object/1 _] java.util.Arrays/binarySearch"))]
360368
(is (= :method-value (:op a)))
361369
(is (= 1 (count (:methods a))))
370+
(is (= '[java.lang.Object<> java.lang.Object] (-> a :methods first :parameter-types)))
362371
(is (:validated? a))))
363372

364373
(deftest bad-param-tags-test
365374
(is (thrown? ExceptionInfo (ana (r/read-string "^[String String] Math/abs"))))
366375
(is (thrown? ExceptionInfo (ana (r/read-string "(^[] String/foo \"a\")"))))
367376
(is (thrown? ExceptionInfo (ana (r/read-string "(^[] String/.foo \"a\")"))))
368377
(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))))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package clojure.tools.analyzer.jvm.test;
2+
3+
public class FieldMethodOverload {
4+
public static final String doppelganger = "static-field";
5+
6+
public static String doppelganger() {
7+
return "";
8+
}
9+
10+
public static String doppelganger(int a, int b) {
11+
return "int-int";
12+
}
13+
}

0 commit comments

Comments
 (0)