diff options
| author | Alan Dipert <alan@dipert.org> | 2010-12-17 15:25:15 -0500 |
|---|---|---|
| committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-12-17 17:09:06 -0500 |
| commit | 2879523aaa72ca9cada4b54f4e4dabe6564de08a (patch) | |
| tree | 68ca252ff7d17b847d7d0009f8854fa13d8af62e /test | |
| parent | 4e677b34b33219811d66aa9dcb335145439dbecc (diff) | |
Fixed into-array behavior #678
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/clojure/test_clojure/java_interop.clj | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/test/clojure/test_clojure/java_interop.clj b/test/clojure/test_clojure/java_interop.clj index ae197a9f..b9133d04 100644 --- a/test/clojure/test_clojure/java_interop.clj +++ b/test/clojure/test_clojure/java_interop.clj @@ -269,7 +269,8 @@ (is (thrown? IllegalArgumentException (into-array [1 "abc" :kw]))) (is (thrown? IllegalArgumentException (into-array [1.2 4]))) (is (thrown? IllegalArgumentException (into-array [(byte 2) (short 3)]))) - + (is (thrown? IllegalArgumentException (into-array Byte/TYPE [100000000000000]))) + ; simple case (let [v [1 2 3 4 5] a (into-array v)] @@ -278,13 +279,22 @@ (vec a) v (class (first a)) (class (first v)) )) - ; given type - #_(let [a (into-array Integer/TYPE [(byte 2) (short 3) (int 4)])] - (are [x] (= x Long) - (class (aget a 0)) - (class (aget a 1)) - (class (aget a 2)) )) - + (is (= \a (aget (into-array Character/TYPE [\a \b \c]) 0))) + + (let [types [Integer/TYPE + Byte/TYPE + Float/TYPE + Short/TYPE + Double/TYPE + Long/TYPE] + values [(byte 2) (short 3) (int 4) 5]] + (for [t types] + (let [a (into-array t values)] + (is (== (aget a 0) 2)) + (is (== (aget a 1) 3)) + (is (== (aget a 2) 4)) + (is (== (aget a 3) 5))))) + ; different kinds of collections (are [x] (and (= (alength (into-array x)) (count x)) (= (vec (into-array x)) (vec x)) |
