summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2011-02-02 10:04:58 -0500
committerRich Hickey <richhickey@gmail.com>2011-02-02 10:04:58 -0500
commitd93ef6293bbcc6059e6da77dbf6ed26167f36cdb (patch)
treeac5822d45aa027f5accaa07208693c09df21c966
parent13d9404b5227f3b9e8f86371d211be890e5302a9 (diff)
Revert "keys and vals check for instanceof Map"
breaks subseq This reverts commit 13d9404b5227f3b9e8f86371d211be890e5302a9.
-rw-r--r--src/jvm/clojure/lang/RT.java14
-rw-r--r--test/clojure/test_clojure/data_structures.clj22
2 files changed, 12 insertions, 24 deletions
diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java
index 6017aaf0..aad678c7 100644
--- a/src/jvm/clojure/lang/RT.java
+++ b/src/jvm/clojure/lang/RT.java
@@ -470,21 +470,11 @@ static ISeq seqFrom(Object coll){
}
static public ISeq keys(Object coll){
- if(coll == null)
- return null;
- else if (coll instanceof Map)
- return APersistentMap.KeySeq.create(seq(coll));
- else
- throw new IllegalArgumentException("Don't know how to get keys from: " + coll.getClass().getName());
+ return APersistentMap.KeySeq.create(seq(coll));
}
static public ISeq vals(Object coll){
- if(coll == null)
- return null;
- else if (coll instanceof Map)
- return APersistentMap.ValSeq.create(seq(coll));
- else
- throw new IllegalArgumentException("Don't know how to get vals from: " + coll.getClass().getName());
+ return APersistentMap.ValSeq.create(seq(coll));
}
static public IPersistentMap meta(Object x){
diff --git a/test/clojure/test_clojure/data_structures.clj b/test/clojure/test_clojure/data_structures.clj
index 08d0ee38..7679b2b6 100644
--- a/test/clojure/test_clojure/data_structures.clj
+++ b/test/clojure/test_clojure/data_structures.clj
@@ -440,12 +440,11 @@
(deftest test-keys
- (are [x] (thrown? Exception (keys x))
- ;; other than map data structures
- ()
- []
- #{}
- "")
+ (are [x y] (= x y) ; other than map data structures
+ (keys ()) nil
+ (keys []) nil
+ (keys #{}) nil
+ (keys "") nil )
(are [x y] (= x y)
; (class {:a 1}) => clojure.lang.PersistentArrayMap
@@ -465,12 +464,11 @@
(deftest test-vals
- (are [x] (thrown? Exception (vals x))
- ;; other than map data structures
- ()
- []
- #{}
- "")
+ (are [x y] (= x y) ; other than map data structures
+ (vals ()) nil
+ (vals []) nil
+ (vals #{}) nil
+ (vals "") nil )
(are [x y] (= x y)
; (class {:a 1}) => clojure.lang.PersistentArrayMap