diff src/clojure/test_clojure/sequences.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/test_clojure/sequences.clj	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,1162 @@
     1.4 +;   Copyright (c) Rich Hickey. All rights reserved.
     1.5 +;   The use and distribution terms for this software are covered by the
     1.6 +;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
     1.7 +;   which can be found in the file epl-v10.html at the root of this distribution.
     1.8 +;   By using this software in any fashion, you are agreeing to be bound by
     1.9 +;   the terms of this license.
    1.10 +;   You must not remove this notice, or any other, from this software.
    1.11 +
    1.12 +; Author: Frantisek Sodomka
    1.13 +; Contributors: Stuart Halloway
    1.14 +
    1.15 +(ns clojure.test-clojure.sequences
    1.16 +  (:use clojure.test))
    1.17 +
    1.18 +;; *** Tests ***
    1.19 +
    1.20 +; TODO:
    1.21 +; apply, map, filter, remove
    1.22 +; and more...
    1.23 +
    1.24 +(deftest test-reduce-from-chunked-into-unchunked
    1.25 +  (= [1 2 \a \b] (into [] (concat [1 2] "ab"))))
    1.26 + 
    1.27 +(deftest test-reduce
    1.28 +  (let [int+ (fn [a b] (+ (int a) (int b)))
    1.29 +        arange (range 100) ;; enough to cross nodes
    1.30 +        avec (into [] arange)
    1.31 +        alist (into () arange)
    1.32 +        obj-array (into-array arange)
    1.33 +        int-array (into-array Integer/TYPE arange)
    1.34 +        long-array (into-array Long/TYPE arange)
    1.35 +        float-array (into-array Float/TYPE arange)
    1.36 +        char-array (into-array Character/TYPE (map char arange))
    1.37 +        double-array (into-array Double/TYPE arange)
    1.38 +        byte-array (into-array Byte/TYPE (map byte arange))
    1.39 +        int-vec (into (vector-of :int) arange)
    1.40 +        long-vec (into (vector-of :long) arange)
    1.41 +        float-vec (into (vector-of :float) arange)
    1.42 +        char-vec (into (vector-of :char) (map char arange))
    1.43 +        double-vec (into (vector-of :double) arange)
    1.44 +        byte-vec (into (vector-of :byte) (map byte arange))
    1.45 +        all-true (into-array Boolean/TYPE (repeat 10 true))]
    1.46 +    (is (= 4950
    1.47 +           (reduce + arange)
    1.48 +           (reduce + avec)
    1.49 +           (reduce + alist)
    1.50 +           (reduce + obj-array)
    1.51 +           (reduce + int-array)
    1.52 +           (reduce + long-array)
    1.53 +           (reduce + float-array)
    1.54 +           (reduce int+ char-array)
    1.55 +           (reduce + double-array)
    1.56 +           (reduce int+ byte-array)
    1.57 +           (reduce + int-vec)
    1.58 +           (reduce + long-vec)
    1.59 +           (reduce + float-vec)
    1.60 +           (reduce int+ char-vec)
    1.61 +           (reduce + double-vec)
    1.62 +           (reduce int+ byte-vec)))
    1.63 +    (is (= 4951
    1.64 +           (reduce + 1 arange)
    1.65 +           (reduce + 1 avec)
    1.66 +           (reduce + 1 alist)
    1.67 +           (reduce + 1 obj-array)
    1.68 +           (reduce + 1 int-array)
    1.69 +           (reduce + 1 long-array)
    1.70 +           (reduce + 1 float-array)
    1.71 +           (reduce int+ 1 char-array)
    1.72 +           (reduce + 1 double-array)
    1.73 +           (reduce int+ 1 byte-array)
    1.74 +           (reduce + 1 int-vec)
    1.75 +           (reduce + 1 long-vec)
    1.76 +           (reduce + 1 float-vec)
    1.77 +           (reduce int+ 1 char-vec)
    1.78 +           (reduce + 1 double-vec)
    1.79 +           (reduce int+ 1 byte-vec)))
    1.80 +    (is (= true
    1.81 +           (reduce #(and %1 %2) all-true)
    1.82 +           (reduce #(and %1 %2) true all-true)))))
    1.83 +
    1.84 +(deftest test-equality
    1.85 +  ; lazy sequences
    1.86 +  (are [x y] (= x y)
    1.87 +      ; fixed SVN 1288 - LazySeq and EmptyList equals/equiv
    1.88 +      ; http://groups.google.com/group/clojure/browse_frm/thread/286d807be9cae2a5#
    1.89 +      (map inc nil) ()
    1.90 +      (map inc ()) ()
    1.91 +      (map inc []) ()
    1.92 +      (map inc #{}) ()
    1.93 +      (map inc {}) () ))
    1.94 +
    1.95 +
    1.96 +(deftest test-lazy-seq
    1.97 +  (are [x] (seq? x)
    1.98 +      (lazy-seq nil)
    1.99 +      (lazy-seq [])
   1.100 +      (lazy-seq [1 2]))
   1.101 +
   1.102 +  (are [x y] (= x y)
   1.103 +      (lazy-seq nil) ()
   1.104 +      (lazy-seq [nil]) '(nil)
   1.105 +
   1.106 +      (lazy-seq ()) ()
   1.107 +      (lazy-seq []) ()
   1.108 +      (lazy-seq #{}) ()
   1.109 +      (lazy-seq {}) ()
   1.110 +      (lazy-seq "") ()
   1.111 +      (lazy-seq (into-array [])) ()
   1.112 +
   1.113 +      (lazy-seq (list 1 2)) '(1 2)
   1.114 +      (lazy-seq [1 2]) '(1 2)
   1.115 +      (lazy-seq (sorted-set 1 2)) '(1 2)
   1.116 +      (lazy-seq (sorted-map :a 1 :b 2)) '([:a 1] [:b 2])
   1.117 +      (lazy-seq "abc") '(\a \b \c)
   1.118 +      (lazy-seq (into-array [1 2])) '(1 2) ))
   1.119 +
   1.120 +
   1.121 +(deftest test-seq
   1.122 +  (is (not (seq? (seq []))))
   1.123 +  (is (seq? (seq [1 2])))
   1.124 +  
   1.125 +  (are [x y] (= x y)
   1.126 +    (seq nil) nil
   1.127 +    (seq [nil]) '(nil)
   1.128 +
   1.129 +    (seq ()) nil
   1.130 +    (seq []) nil
   1.131 +    (seq #{}) nil
   1.132 +    (seq {}) nil
   1.133 +    (seq "") nil
   1.134 +    (seq (into-array [])) nil
   1.135 +
   1.136 +    (seq (list 1 2)) '(1 2)
   1.137 +    (seq [1 2]) '(1 2)
   1.138 +    (seq (sorted-set 1 2)) '(1 2)
   1.139 +    (seq (sorted-map :a 1 :b 2)) '([:a 1] [:b 2])
   1.140 +    (seq "abc") '(\a \b \c)
   1.141 +    (seq (into-array [1 2])) '(1 2) ))
   1.142 +
   1.143 +
   1.144 +(deftest test-cons
   1.145 +  (is (thrown? IllegalArgumentException (cons 1 2)))
   1.146 +  (are [x y] (= x y)
   1.147 +    (cons 1 nil) '(1)
   1.148 +    (cons nil nil) '(nil)
   1.149 +
   1.150 +    (cons \a nil) '(\a)
   1.151 +    (cons \a "") '(\a)
   1.152 +    (cons \a "bc") '(\a \b \c)
   1.153 +
   1.154 +    (cons 1 ()) '(1)
   1.155 +    (cons 1 '(2 3)) '(1 2 3)
   1.156 +
   1.157 +    (cons 1 []) [1]
   1.158 +    (cons 1 [2 3]) [1 2 3]
   1.159 +
   1.160 +    (cons 1 #{}) '(1)
   1.161 +    (cons 1 (sorted-set 2 3)) '(1 2 3)
   1.162 +
   1.163 +    (cons 1 (into-array [])) '(1)
   1.164 +    (cons 1 (into-array [2 3])) '(1 2 3) ))
   1.165 +
   1.166 +
   1.167 +(deftest test-empty
   1.168 +  (are [x y] (and (= (empty x) y)
   1.169 +                  (= (class (empty x)) (class y)))
   1.170 +      nil nil
   1.171 +
   1.172 +      () ()
   1.173 +      '(1 2) ()
   1.174 +
   1.175 +      [] []
   1.176 +      [1 2] []
   1.177 +
   1.178 +      {} {}
   1.179 +      {:a 1 :b 2} {}
   1.180 +
   1.181 +      (sorted-map) (sorted-map)
   1.182 +      (sorted-map :a 1 :b 2) (sorted-map)
   1.183 +
   1.184 +      #{} #{}
   1.185 +      #{1 2} #{}
   1.186 +
   1.187 +      (sorted-set) (sorted-set)
   1.188 +      (sorted-set 1 2) (sorted-set)
   1.189 +
   1.190 +      (seq ()) nil      ; (seq ()) => nil
   1.191 +      (seq '(1 2)) ()
   1.192 +
   1.193 +      (seq []) nil      ; (seq []) => nil
   1.194 +      (seq [1 2]) ()
   1.195 +
   1.196 +      (seq "") nil      ; (seq "") => nil
   1.197 +      (seq "ab") ()
   1.198 +
   1.199 +      (lazy-seq ()) ()
   1.200 +      (lazy-seq '(1 2)) ()
   1.201 +
   1.202 +      (lazy-seq []) ()
   1.203 +      (lazy-seq [1 2]) ()
   1.204 +
   1.205 +      ; non-coll, non-seq => nil
   1.206 +      42 nil
   1.207 +      1.2 nil
   1.208 +      "abc" nil ))
   1.209 +
   1.210 +;Tests that the comparator is preservered
   1.211 +;The first element should be the same in each set if preserved.
   1.212 +(deftest test-empty-sorted
   1.213 +  (let [inv-compare (comp - compare)]
   1.214 +    (are [x y] (= (first (into (empty x) x)) 
   1.215 +		  (first y))
   1.216 +	 (sorted-set 1 2 3) (sorted-set 1 2 3)
   1.217 +	 (sorted-set-by inv-compare 1 2 3) (sorted-set-by inv-compare 1 2 3)
   1.218 +
   1.219 +	 (sorted-map 1 :a 2 :b 3 :c) (sorted-map 1 :a 2 :b 3 :c)
   1.220 +	 (sorted-map-by inv-compare 1 :a 2 :b 3 :c) (sorted-map-by inv-compare 1 :a 2 :b 3 :c))))
   1.221 +
   1.222 +
   1.223 +(deftest test-not-empty
   1.224 +  ; empty coll/seq => nil
   1.225 +  (are [x] (= (not-empty x) nil)
   1.226 +      ()
   1.227 +      []
   1.228 +      {}
   1.229 +      #{}
   1.230 +      (seq ())
   1.231 +      (seq [])
   1.232 +      (lazy-seq ())
   1.233 +      (lazy-seq []) )
   1.234 +
   1.235 +  ; non-empty coll/seq => identity
   1.236 +  (are [x] (and (= (not-empty x) x)
   1.237 +                (= (class (not-empty x)) (class x)))
   1.238 +      '(1 2)
   1.239 +      [1 2]
   1.240 +      {:a 1}
   1.241 +      #{1 2}
   1.242 +      (seq '(1 2))
   1.243 +      (seq [1 2])
   1.244 +      (lazy-seq '(1 2))
   1.245 +      (lazy-seq [1 2]) ))
   1.246 +
   1.247 +
   1.248 +(deftest test-first
   1.249 +  (is (thrown? IllegalArgumentException (first)))
   1.250 +  (is (thrown? IllegalArgumentException (first true)))
   1.251 +  (is (thrown? IllegalArgumentException (first false)))
   1.252 +  (is (thrown? IllegalArgumentException (first 1)))
   1.253 +  (is (thrown? IllegalArgumentException (first 1 2)))
   1.254 +  (is (thrown? IllegalArgumentException (first \a)))
   1.255 +  (is (thrown? IllegalArgumentException (first 's)))
   1.256 +  (is (thrown? IllegalArgumentException (first :k)))
   1.257 +  (are [x y] (= x y)
   1.258 +    (first nil) nil
   1.259 +
   1.260 +    ; string
   1.261 +    (first "") nil
   1.262 +    (first "a") \a
   1.263 +    (first "abc") \a
   1.264 +
   1.265 +    ; list
   1.266 +    (first ()) nil
   1.267 +    (first '(1)) 1
   1.268 +    (first '(1 2 3)) 1
   1.269 +
   1.270 +    (first '(nil)) nil
   1.271 +    (first '(1 nil)) 1
   1.272 +    (first '(nil 2)) nil
   1.273 +    (first '(())) ()
   1.274 +    (first '(() nil)) ()
   1.275 +    (first '(() 2 nil)) ()
   1.276 +
   1.277 +    ; vector
   1.278 +    (first []) nil
   1.279 +    (first [1]) 1
   1.280 +    (first [1 2 3]) 1
   1.281 +
   1.282 +    (first [nil]) nil
   1.283 +    (first [1 nil]) 1
   1.284 +    (first [nil 2]) nil
   1.285 +    (first [[]]) []
   1.286 +    (first [[] nil]) []
   1.287 +    (first [[] 2 nil]) []
   1.288 +
   1.289 +    ; set
   1.290 +    (first #{}) nil
   1.291 +    (first #{1}) 1
   1.292 +    (first (sorted-set 1 2 3)) 1
   1.293 +
   1.294 +    (first #{nil}) nil
   1.295 +    (first (sorted-set 1 nil)) nil
   1.296 +    (first (sorted-set nil 2)) nil
   1.297 +    (first #{#{}}) #{}
   1.298 +    (first (sorted-set #{} nil)) nil
   1.299 +    ;(first (sorted-set #{} 2 nil)) nil
   1.300 +
   1.301 +    ; map
   1.302 +    (first {}) nil
   1.303 +    (first (sorted-map :a 1)) '(:a 1)
   1.304 +    (first (sorted-map :a 1 :b 2 :c 3)) '(:a 1)
   1.305 +
   1.306 +    ; array
   1.307 +    (first (into-array [])) nil
   1.308 +    (first (into-array [1])) 1
   1.309 +    (first (into-array [1 2 3])) 1
   1.310 +    (first (to-array [nil])) nil
   1.311 +    (first (to-array [1 nil])) 1
   1.312 +    (first (to-array [nil 2])) nil ))
   1.313 +
   1.314 +
   1.315 +(deftest test-next
   1.316 +  (is (thrown? IllegalArgumentException (next)))
   1.317 +  (is (thrown? IllegalArgumentException (next true)))
   1.318 +  (is (thrown? IllegalArgumentException (next false)))
   1.319 +  (is (thrown? IllegalArgumentException (next 1)))
   1.320 +  (is (thrown? IllegalArgumentException (next 1 2)))
   1.321 +  (is (thrown? IllegalArgumentException (next \a)))
   1.322 +  (is (thrown? IllegalArgumentException (next 's)))
   1.323 +  (is (thrown? IllegalArgumentException (next :k)))
   1.324 +  (are [x y] (= x y)
   1.325 +    (next nil) nil
   1.326 +
   1.327 +    ; string
   1.328 +    (next "") nil
   1.329 +    (next "a") nil
   1.330 +    (next "abc") '(\b \c)
   1.331 +
   1.332 +    ; list
   1.333 +    (next ()) nil
   1.334 +    (next '(1)) nil
   1.335 +    (next '(1 2 3)) '(2 3)
   1.336 +
   1.337 +    (next '(nil)) nil
   1.338 +    (next '(1 nil)) '(nil)
   1.339 +    (next '(1 ())) '(())
   1.340 +    (next '(nil 2)) '(2)
   1.341 +    (next '(())) nil
   1.342 +    (next '(() nil)) '(nil)
   1.343 +    (next '(() 2 nil)) '(2 nil)
   1.344 +
   1.345 +    ; vector
   1.346 +    (next []) nil
   1.347 +    (next [1]) nil
   1.348 +    (next [1 2 3]) [2 3]
   1.349 +
   1.350 +    (next [nil]) nil
   1.351 +    (next [1 nil]) [nil]
   1.352 +    (next [1 []]) [[]]
   1.353 +    (next [nil 2]) [2]
   1.354 +    (next [[]]) nil
   1.355 +    (next [[] nil]) [nil]
   1.356 +    (next [[] 2 nil]) [2 nil]
   1.357 +
   1.358 +    ; set
   1.359 +    (next #{}) nil
   1.360 +    (next #{1}) nil
   1.361 +    (next (sorted-set 1 2 3)) '(2 3)
   1.362 +
   1.363 +    (next #{nil}) nil
   1.364 +    (next (sorted-set 1 nil)) '(1)
   1.365 +    (next (sorted-set nil 2)) '(2)
   1.366 +    (next #{#{}}) nil
   1.367 +    (next (sorted-set #{} nil)) '(#{})
   1.368 +    ;(next (sorted-set #{} 2 nil)) #{}
   1.369 +
   1.370 +    ; map
   1.371 +    (next {}) nil
   1.372 +    (next (sorted-map :a 1)) nil
   1.373 +    (next (sorted-map :a 1 :b 2 :c 3)) '((:b 2) (:c 3))
   1.374 +
   1.375 +    ; array
   1.376 +    (next (into-array [])) nil
   1.377 +    (next (into-array [1])) nil
   1.378 +    (next (into-array [1 2 3])) '(2 3)
   1.379 +
   1.380 +    (next (to-array [nil])) nil
   1.381 +    (next (to-array [1 nil])) '(nil)
   1.382 +    ;(next (to-array [1 (into-array [])])) (list (into-array []))
   1.383 +    (next (to-array [nil 2])) '(2)
   1.384 +    (next (to-array [(into-array [])])) nil
   1.385 +    (next (to-array [(into-array []) nil])) '(nil)
   1.386 +    (next (to-array [(into-array []) 2 nil])) '(2 nil) ))
   1.387 +
   1.388 +
   1.389 +(deftest test-last
   1.390 +  (are [x y] (= x y)
   1.391 +      (last nil) nil
   1.392 +
   1.393 +      ; list
   1.394 +      (last ()) nil
   1.395 +      (last '(1)) 1
   1.396 +      (last '(1 2 3)) 3
   1.397 +
   1.398 +      (last '(nil)) nil
   1.399 +      (last '(1 nil)) nil
   1.400 +      (last '(nil 2)) 2
   1.401 +      (last '(())) ()
   1.402 +      (last '(() nil)) nil
   1.403 +      (last '(() 2 nil)) nil
   1.404 +
   1.405 +      ; vector
   1.406 +      (last []) nil
   1.407 +      (last [1]) 1
   1.408 +      (last [1 2 3]) 3
   1.409 +
   1.410 +      (last [nil]) nil
   1.411 +      (last [1 nil]) nil
   1.412 +      (last [nil 2]) 2
   1.413 +      (last [[]]) []
   1.414 +      (last [[] nil]) nil
   1.415 +      (last [[] 2 nil]) nil
   1.416 +
   1.417 +      ; set
   1.418 +      (last #{}) nil
   1.419 +      (last #{1}) 1
   1.420 +      (last (sorted-set 1 2 3)) 3
   1.421 +
   1.422 +      (last #{nil}) nil
   1.423 +      (last (sorted-set 1 nil)) 1
   1.424 +      (last (sorted-set nil 2)) 2
   1.425 +      (last #{#{}}) #{}
   1.426 +      (last (sorted-set #{} nil)) #{}
   1.427 +      ;(last (sorted-set #{} 2 nil)) nil
   1.428 +
   1.429 +      ; map
   1.430 +      (last {}) nil
   1.431 +      (last (sorted-map :a 1)) [:a 1]
   1.432 +      (last (sorted-map :a 1 :b 2 :c 3)) [:c 3]
   1.433 +
   1.434 +      ; string
   1.435 +      (last "") nil
   1.436 +      (last "a") \a
   1.437 +      (last "abc") \c
   1.438 +
   1.439 +      ; array
   1.440 +      (last (into-array [])) nil
   1.441 +      (last (into-array [1])) 1
   1.442 +      (last (into-array [1 2 3])) 3
   1.443 +      (last (to-array [nil])) nil
   1.444 +      (last (to-array [1 nil])) nil
   1.445 +      (last (to-array [nil 2])) 2 ))
   1.446 +
   1.447 +
   1.448 +;; (ffirst coll) = (first (first coll))
   1.449 +;;
   1.450 +(deftest test-ffirst
   1.451 +  (is (thrown? IllegalArgumentException (ffirst)))
   1.452 +  (are [x y] (= x y)
   1.453 +    (ffirst nil) nil
   1.454 +
   1.455 +    (ffirst ()) nil
   1.456 +    (ffirst '((1 2) (3 4))) 1
   1.457 +
   1.458 +    (ffirst []) nil
   1.459 +    (ffirst [[1 2] [3 4]]) 1
   1.460 +
   1.461 +    (ffirst {}) nil
   1.462 +    (ffirst {:a 1}) :a
   1.463 +
   1.464 +    (ffirst #{}) nil
   1.465 +    (ffirst #{[1 2]}) 1 ))
   1.466 +
   1.467 +
   1.468 +;; (fnext coll) = (first (next coll)) = (second coll)
   1.469 +;;
   1.470 +(deftest test-fnext
   1.471 +  (is (thrown? IllegalArgumentException (fnext)))
   1.472 +  (are [x y] (= x y)
   1.473 +    (fnext nil) nil
   1.474 +
   1.475 +    (fnext ()) nil
   1.476 +    (fnext '(1)) nil
   1.477 +    (fnext '(1 2 3 4)) 2
   1.478 +
   1.479 +    (fnext []) nil
   1.480 +    (fnext [1]) nil
   1.481 +    (fnext [1 2 3 4]) 2
   1.482 +
   1.483 +    (fnext {}) nil
   1.484 +    (fnext (sorted-map :a 1)) nil
   1.485 +    (fnext (sorted-map :a 1 :b 2)) [:b 2]
   1.486 +
   1.487 +    (fnext #{}) nil
   1.488 +    (fnext #{1}) nil
   1.489 +    (fnext (sorted-set 1 2 3 4)) 2 ))
   1.490 +
   1.491 +
   1.492 +;; (nfirst coll) = (next (first coll))
   1.493 +;;
   1.494 +(deftest test-nfirst
   1.495 +  (is (thrown? IllegalArgumentException (nfirst)))
   1.496 +  (are [x y] (= x y)
   1.497 +    (nfirst nil) nil
   1.498 +
   1.499 +    (nfirst ()) nil
   1.500 +    (nfirst '((1 2 3) (4 5 6))) '(2 3)
   1.501 +
   1.502 +    (nfirst []) nil
   1.503 +    (nfirst [[1 2 3] [4 5 6]]) '(2 3)
   1.504 +
   1.505 +    (nfirst {}) nil
   1.506 +    (nfirst {:a 1}) '(1)
   1.507 +
   1.508 +    (nfirst #{}) nil
   1.509 +    (nfirst #{[1 2]}) '(2) ))
   1.510 +
   1.511 +
   1.512 +;; (nnext coll) = (next (next coll))
   1.513 +;;
   1.514 +(deftest test-nnext
   1.515 +  (is (thrown? IllegalArgumentException (nnext)))
   1.516 +  (are [x y] (= x y)
   1.517 +    (nnext nil) nil
   1.518 +
   1.519 +    (nnext ()) nil
   1.520 +    (nnext '(1)) nil
   1.521 +    (nnext '(1 2)) nil
   1.522 +    (nnext '(1 2 3 4)) '(3 4)
   1.523 +
   1.524 +    (nnext []) nil
   1.525 +    (nnext [1]) nil
   1.526 +    (nnext [1 2]) nil
   1.527 +    (nnext [1 2 3 4]) '(3 4)
   1.528 +
   1.529 +    (nnext {}) nil
   1.530 +    (nnext (sorted-map :a 1)) nil
   1.531 +    (nnext (sorted-map :a 1 :b 2)) nil
   1.532 +    (nnext (sorted-map :a 1 :b 2 :c 3 :d 4)) '([:c 3] [:d 4])
   1.533 +
   1.534 +    (nnext #{}) nil
   1.535 +    (nnext #{1}) nil
   1.536 +    (nnext (sorted-set 1 2)) nil
   1.537 +    (nnext (sorted-set 1 2 3 4)) '(3 4) ))
   1.538 +
   1.539 +
   1.540 +(deftest test-nth
   1.541 +  ; maps, sets are not supported
   1.542 +  (is (thrown? UnsupportedOperationException (nth {} 0)))
   1.543 +  (is (thrown? UnsupportedOperationException (nth {:a 1 :b 2} 0)))
   1.544 +  (is (thrown? UnsupportedOperationException (nth #{} 0)))
   1.545 +  (is (thrown? UnsupportedOperationException (nth #{1 2 3} 0)))
   1.546 +
   1.547 +  ; out of bounds
   1.548 +  (is (thrown? IndexOutOfBoundsException (nth '() 0)))
   1.549 +  (is (thrown? IndexOutOfBoundsException (nth '(1 2 3) 5)))
   1.550 +  (is (thrown? IndexOutOfBoundsException (nth '() -1)))
   1.551 +  (is (thrown? IndexOutOfBoundsException (nth '(1 2 3) -1)))
   1.552 +
   1.553 +  (is (thrown? IndexOutOfBoundsException (nth [] 0)))
   1.554 +  (is (thrown? IndexOutOfBoundsException (nth [1 2 3] 5)))
   1.555 +  (is (thrown? IndexOutOfBoundsException (nth [] -1)))
   1.556 +  (is (thrown? IndexOutOfBoundsException (nth [1 2 3] -1)))  ; ???
   1.557 +
   1.558 +  (is (thrown? IndexOutOfBoundsException (nth (into-array []) 0)))
   1.559 +  (is (thrown? IndexOutOfBoundsException (nth (into-array [1 2 3]) 5)))
   1.560 +  (is (thrown? IndexOutOfBoundsException (nth (into-array []) -1)))
   1.561 +  (is (thrown? IndexOutOfBoundsException (nth (into-array [1 2 3]) -1)))
   1.562 +
   1.563 +  (is (thrown? StringIndexOutOfBoundsException (nth "" 0)))
   1.564 +  (is (thrown? StringIndexOutOfBoundsException (nth "abc" 5)))
   1.565 +  (is (thrown? StringIndexOutOfBoundsException (nth "" -1)))
   1.566 +  (is (thrown? StringIndexOutOfBoundsException (nth "abc" -1)))
   1.567 +
   1.568 +  (is (thrown? IndexOutOfBoundsException (nth (java.util.ArrayList. []) 0)))
   1.569 +  (is (thrown? IndexOutOfBoundsException (nth (java.util.ArrayList. [1 2 3]) 5)))
   1.570 +  (is (thrown? IndexOutOfBoundsException (nth (java.util.ArrayList. []) -1)))       ; ???
   1.571 +  (is (thrown? IndexOutOfBoundsException (nth (java.util.ArrayList. [1 2 3]) -1)))  ; ???
   1.572 +
   1.573 +  (are [x y] (= x y)
   1.574 +      (nth '(1) 0) 1
   1.575 +      (nth '(1 2 3) 0) 1
   1.576 +      (nth '(1 2 3 4 5) 1) 2
   1.577 +      (nth '(1 2 3 4 5) 4) 5
   1.578 +      (nth '(1 2 3) 5 :not-found) :not-found
   1.579 +
   1.580 +      (nth [1] 0) 1
   1.581 +      (nth [1 2 3] 0) 1
   1.582 +      (nth [1 2 3 4 5] 1) 2
   1.583 +      (nth [1 2 3 4 5] 4) 5
   1.584 +      (nth [1 2 3] 5 :not-found) :not-found
   1.585 +
   1.586 +      (nth (into-array [1]) 0) 1
   1.587 +      (nth (into-array [1 2 3]) 0) 1
   1.588 +      (nth (into-array [1 2 3 4 5]) 1) 2
   1.589 +      (nth (into-array [1 2 3 4 5]) 4) 5
   1.590 +      (nth (into-array [1 2 3]) 5 :not-found) :not-found
   1.591 +
   1.592 +      (nth "a" 0) \a
   1.593 +      (nth "abc" 0) \a
   1.594 +      (nth "abcde" 1) \b
   1.595 +      (nth "abcde" 4) \e
   1.596 +      (nth "abc" 5 :not-found) :not-found
   1.597 +
   1.598 +      (nth (java.util.ArrayList. [1]) 0) 1
   1.599 +      (nth (java.util.ArrayList. [1 2 3]) 0) 1
   1.600 +      (nth (java.util.ArrayList. [1 2 3 4 5]) 1) 2
   1.601 +      (nth (java.util.ArrayList. [1 2 3 4 5]) 4) 5
   1.602 +      (nth (java.util.ArrayList. [1 2 3]) 5 :not-found) :not-found )
   1.603 +
   1.604 +  ; regex Matchers
   1.605 +  (let [m (re-matcher #"(a)(b)" "ababaa")]
   1.606 +    (re-find m) ; => ["ab" "a" "b"]
   1.607 +    (are [x y] (= x y)
   1.608 +        (nth m 0) "ab"
   1.609 +        (nth m 1) "a"
   1.610 +        (nth m 2) "b"
   1.611 +        (nth m 3 :not-found) :not-found
   1.612 +        (nth m -1 :not-found) :not-found )
   1.613 +    (is (thrown? IndexOutOfBoundsException (nth m 3)))
   1.614 +    (is (thrown? IndexOutOfBoundsException (nth m -1))))
   1.615 +
   1.616 +  (let [m (re-matcher #"c" "ababaa")]
   1.617 +    (re-find m) ; => nil
   1.618 +    (are [x y] (= x y)
   1.619 +        (nth m 0 :not-found) :not-found
   1.620 +        (nth m 2 :not-found) :not-found
   1.621 +        (nth m -1 :not-found) :not-found )
   1.622 +    (is (thrown? IllegalStateException (nth m 0)))
   1.623 +    (is (thrown? IllegalStateException (nth m 2)))
   1.624 +    (is (thrown? IllegalStateException (nth m -1)))))
   1.625 +
   1.626 +
   1.627 +; distinct was broken for nil & false:
   1.628 +;   fixed in rev 1278:
   1.629 +;   http://code.google.com/p/clojure/source/detail?r=1278
   1.630 +;
   1.631 +(deftest test-distinct
   1.632 +  (are [x y] (= x y)
   1.633 +      (distinct ()) ()
   1.634 +      (distinct '(1)) '(1)
   1.635 +      (distinct '(1 2 3)) '(1 2 3)
   1.636 +      (distinct '(1 2 3 1 1 1)) '(1 2 3)
   1.637 +      (distinct '(1 1 1 2)) '(1 2)
   1.638 +      (distinct '(1 2 1 2)) '(1 2)
   1.639 +
   1.640 +      (distinct []) ()
   1.641 +      (distinct [1]) '(1)
   1.642 +      (distinct [1 2 3]) '(1 2 3)
   1.643 +      (distinct [1 2 3 1 2 2 1 1]) '(1 2 3)
   1.644 +      (distinct [1 1 1 2]) '(1 2)
   1.645 +      (distinct [1 2 1 2]) '(1 2)
   1.646 +
   1.647 +      (distinct "") ()
   1.648 +      (distinct "a") '(\a)
   1.649 +      (distinct "abc") '(\a \b \c)
   1.650 +      (distinct "abcabab") '(\a \b \c)
   1.651 +      (distinct "aaab") '(\a \b)
   1.652 +      (distinct "abab") '(\a \b) )
   1.653 +
   1.654 +  (are [x] (= (distinct [x x]) [x])   
   1.655 +      nil
   1.656 +      false true
   1.657 +      0 42
   1.658 +      0.0 3.14
   1.659 +      2/3
   1.660 +      0M 1M
   1.661 +      \c
   1.662 +      "" "abc"
   1.663 +      'sym
   1.664 +      :kw
   1.665 +      () '(1 2)
   1.666 +      [] [1 2]
   1.667 +      {} {:a 1 :b 2}
   1.668 +      #{} #{1 2} ))
   1.669 +
   1.670 +
   1.671 +(deftest test-interpose
   1.672 +  (are [x y] (= x y)
   1.673 +    (interpose 0 []) ()
   1.674 +    (interpose 0 [1]) '(1)
   1.675 +    (interpose 0 [1 2]) '(1 0 2)
   1.676 +    (interpose 0 [1 2 3]) '(1 0 2 0 3) ))
   1.677 +
   1.678 +
   1.679 +(deftest test-interleave
   1.680 +  (are [x y] (= x y)
   1.681 +    (interleave [1 2] [3 4]) '(1 3 2 4)
   1.682 +
   1.683 +    (interleave [1] [3 4]) '(1 3)
   1.684 +    (interleave [1 2] [3]) '(1 3)
   1.685 +
   1.686 +    (interleave [] [3 4]) ()
   1.687 +    (interleave [1 2] []) ()
   1.688 +    (interleave [] []) () ))
   1.689 +
   1.690 +
   1.691 +(deftest test-zipmap
   1.692 +  (are [x y] (= x y)
   1.693 +    (zipmap [:a :b] [1 2]) {:a 1 :b 2}
   1.694 +
   1.695 +    (zipmap [:a] [1 2]) {:a 1}
   1.696 +    (zipmap [:a :b] [1]) {:a 1}
   1.697 +
   1.698 +    (zipmap [] [1 2]) {}
   1.699 +    (zipmap [:a :b] []) {}
   1.700 +    (zipmap [] []) {} ))
   1.701 +
   1.702 +
   1.703 +(deftest test-concat
   1.704 +  (are [x y] (= x y)
   1.705 +    (concat) ()
   1.706 +
   1.707 +    (concat []) ()
   1.708 +    (concat [1 2]) '(1 2)
   1.709 +
   1.710 +    (concat [1 2] [3 4]) '(1 2 3 4)
   1.711 +    (concat [] [3 4]) '(3 4)
   1.712 +    (concat [1 2] []) '(1 2)
   1.713 +    (concat [] []) ()
   1.714 +
   1.715 +    (concat [1 2] [3 4] [5 6]) '(1 2 3 4 5 6) ))
   1.716 +
   1.717 +
   1.718 +(deftest test-cycle
   1.719 +  (are [x y] (= x y)
   1.720 +    (cycle []) ()
   1.721 +
   1.722 +    (take 3 (cycle [1])) '(1 1 1)
   1.723 +    (take 5 (cycle [1 2 3])) '(1 2 3 1 2)
   1.724 +
   1.725 +    (take 3 (cycle [nil])) '(nil nil nil) ))
   1.726 +
   1.727 +
   1.728 +(deftest test-partition
   1.729 +  (are [x y] (= x y)
   1.730 +    (partition 2 [1 2 3]) '((1 2))
   1.731 +    (partition 2 [1 2 3 4]) '((1 2) (3 4))
   1.732 +    (partition 2 []) ()
   1.733 +
   1.734 +    (partition 2 3 [1 2 3 4 5 6 7]) '((1 2) (4 5))
   1.735 +    (partition 2 3 [1 2 3 4 5 6 7 8]) '((1 2) (4 5) (7 8))
   1.736 +    (partition 2 3 []) ()
   1.737 +
   1.738 +    (partition 1 []) ()
   1.739 +    (partition 1 [1 2 3]) '((1) (2) (3))
   1.740 +
   1.741 +    (partition 5 [1 2 3]) ()
   1.742 +
   1.743 +;    (partition 0 [1 2 3]) (repeat nil)   ; infinite sequence of nil
   1.744 +    (partition -1 [1 2 3]) ()
   1.745 +    (partition -2 [1 2 3]) () ))
   1.746 +
   1.747 +
   1.748 +(deftest test-reverse
   1.749 +  (are [x y] (= x y)
   1.750 +    (reverse nil) ()    ; since SVN 1294
   1.751 +    (reverse []) ()
   1.752 +    (reverse [1]) '(1)
   1.753 +    (reverse [1 2 3]) '(3 2 1) ))
   1.754 +
   1.755 +
   1.756 +(deftest test-take
   1.757 +  (are [x y] (= x y)
   1.758 +    (take 1 [1 2 3 4 5]) '(1)
   1.759 +    (take 3 [1 2 3 4 5]) '(1 2 3)
   1.760 +    (take 5 [1 2 3 4 5]) '(1 2 3 4 5)
   1.761 +    (take 9 [1 2 3 4 5]) '(1 2 3 4 5)
   1.762 +
   1.763 +    (take 0 [1 2 3 4 5]) ()
   1.764 +    (take -1 [1 2 3 4 5]) ()
   1.765 +    (take -2 [1 2 3 4 5]) () ))
   1.766 +
   1.767 +
   1.768 +(deftest test-drop
   1.769 +  (are [x y] (= x y)
   1.770 +    (drop 1 [1 2 3 4 5]) '(2 3 4 5)
   1.771 +    (drop 3 [1 2 3 4 5]) '(4 5)
   1.772 +    (drop 5 [1 2 3 4 5]) ()
   1.773 +    (drop 9 [1 2 3 4 5]) ()
   1.774 +
   1.775 +    (drop 0 [1 2 3 4 5]) '(1 2 3 4 5)
   1.776 +    (drop -1 [1 2 3 4 5]) '(1 2 3 4 5)
   1.777 +    (drop -2 [1 2 3 4 5]) '(1 2 3 4 5) ))
   1.778 +
   1.779 +
   1.780 +(deftest test-take-nth
   1.781 +  (are [x y] (= x y)
   1.782 +     (take-nth 1 [1 2 3 4 5]) '(1 2 3 4 5)
   1.783 +     (take-nth 2 [1 2 3 4 5]) '(1 3 5)
   1.784 +     (take-nth 3 [1 2 3 4 5]) '(1 4)
   1.785 +     (take-nth 4 [1 2 3 4 5]) '(1 5)
   1.786 +     (take-nth 5 [1 2 3 4 5]) '(1)
   1.787 +     (take-nth 9 [1 2 3 4 5]) '(1)
   1.788 +
   1.789 +     ; infinite seq of 1s = (repeat 1)
   1.790 +     ;(take-nth 0 [1 2 3 4 5])
   1.791 +     ;(take-nth -1 [1 2 3 4 5])
   1.792 +     ;(take-nth -2 [1 2 3 4 5])
   1.793 +  ))
   1.794 +
   1.795 +
   1.796 +(deftest test-take-while
   1.797 +  (are [x y] (= x y)
   1.798 +    (take-while pos? []) ()
   1.799 +    (take-while pos? [1 2 3 4]) '(1 2 3 4)
   1.800 +    (take-while pos? [1 2 3 -1]) '(1 2 3)
   1.801 +    (take-while pos? [1 -1 2 3]) '(1)
   1.802 +    (take-while pos? [-1 1 2 3]) ()
   1.803 +    (take-while pos? [-1 -2 -3]) () ))
   1.804 +
   1.805 +
   1.806 +(deftest test-drop-while
   1.807 +  (are [x y] (= x y)
   1.808 +    (drop-while pos? []) ()
   1.809 +    (drop-while pos? [1 2 3 4]) ()
   1.810 +    (drop-while pos? [1 2 3 -1]) '(-1)
   1.811 +    (drop-while pos? [1 -1 2 3]) '(-1 2 3)
   1.812 +    (drop-while pos? [-1 1 2 3]) '(-1 1 2 3)
   1.813 +    (drop-while pos? [-1 -2 -3]) '(-1 -2 -3) ))
   1.814 +
   1.815 +
   1.816 +(deftest test-butlast
   1.817 +  (are [x y] (= x y)
   1.818 +    (butlast []) nil
   1.819 +    (butlast [1]) nil
   1.820 +    (butlast [1 2 3]) '(1 2) ))
   1.821 +
   1.822 +
   1.823 +(deftest test-drop-last
   1.824 +  (are [x y] (= x y)
   1.825 +    ; as butlast
   1.826 +    (drop-last []) ()
   1.827 +    (drop-last [1]) ()
   1.828 +    (drop-last [1 2 3]) '(1 2)
   1.829 +
   1.830 +    ; as butlast, but lazy
   1.831 +    (drop-last 1 []) ()
   1.832 +    (drop-last 1 [1]) ()
   1.833 +    (drop-last 1 [1 2 3]) '(1 2)
   1.834 +
   1.835 +    (drop-last 2 []) ()
   1.836 +    (drop-last 2 [1]) ()
   1.837 +    (drop-last 2 [1 2 3]) '(1)
   1.838 +
   1.839 +    (drop-last 5 []) ()
   1.840 +    (drop-last 5 [1]) ()
   1.841 +    (drop-last 5 [1 2 3]) ()
   1.842 +
   1.843 +    (drop-last 0 []) ()
   1.844 +    (drop-last 0 [1]) '(1)
   1.845 +    (drop-last 0 [1 2 3]) '(1 2 3)
   1.846 +
   1.847 +    (drop-last -1 []) ()
   1.848 +    (drop-last -1 [1]) '(1)
   1.849 +    (drop-last -1 [1 2 3]) '(1 2 3)
   1.850 +
   1.851 +    (drop-last -2 []) ()
   1.852 +    (drop-last -2 [1]) '(1)
   1.853 +    (drop-last -2 [1 2 3]) '(1 2 3) ))
   1.854 +
   1.855 +
   1.856 +(deftest test-split-at
   1.857 +  (is (vector? (split-at 2 [])))
   1.858 +  (is (vector? (split-at 2 [1 2 3])))
   1.859 +
   1.860 +  (are [x y] (= x y)
   1.861 +    (split-at 2 []) [() ()]
   1.862 +    (split-at 2 [1 2 3 4 5]) [(list 1 2) (list 3 4 5)]
   1.863 +
   1.864 +    (split-at 5 [1 2 3]) [(list 1 2 3) ()]
   1.865 +    (split-at 0 [1 2 3]) [() (list 1 2 3)]
   1.866 +    (split-at -1 [1 2 3]) [() (list 1 2 3)]
   1.867 +    (split-at -5 [1 2 3]) [() (list 1 2 3)] ))
   1.868 +
   1.869 +
   1.870 +(deftest test-split-with
   1.871 +  (is (vector? (split-with pos? [])))
   1.872 +  (is (vector? (split-with pos? [1 2 -1 0 3 4])))
   1.873 +
   1.874 +  (are [x y] (= x y)
   1.875 +    (split-with pos? []) [() ()]
   1.876 +    (split-with pos? [1 2 -1 0 3 4]) [(list 1 2) (list -1 0 3 4)]
   1.877 +
   1.878 +    (split-with pos? [-1 2 3 4 5]) [() (list -1 2 3 4 5)]
   1.879 +    (split-with number? [1 -2 "abc" \x]) [(list 1 -2) (list "abc" \x)] ))
   1.880 +
   1.881 +
   1.882 +(deftest test-repeat
   1.883 +  (is (thrown? IllegalArgumentException (repeat)))
   1.884 +
   1.885 +  ; infinite sequence => use take
   1.886 +  (are [x y] (= x y)
   1.887 +      (take 0 (repeat 7)) ()
   1.888 +      (take 1 (repeat 7)) '(7)
   1.889 +      (take 2 (repeat 7)) '(7 7)
   1.890 +      (take 5 (repeat 7)) '(7 7 7 7 7) )
   1.891 +
   1.892 +  ; limited sequence
   1.893 +  (are [x y] (= x y)
   1.894 +      (repeat 0 7) ()
   1.895 +      (repeat 1 7) '(7)
   1.896 +      (repeat 2 7) '(7 7)
   1.897 +      (repeat 5 7) '(7 7 7 7 7)
   1.898 +
   1.899 +      (repeat -1 7) ()
   1.900 +      (repeat -3 7) () )
   1.901 +
   1.902 +  ; test different data types
   1.903 +  (are [x] (= (repeat 3 x) (list x x x))
   1.904 +      nil
   1.905 +      false true
   1.906 +      0 42
   1.907 +      0.0 3.14
   1.908 +      2/3
   1.909 +      0M 1M
   1.910 +      \c
   1.911 +      "" "abc"
   1.912 +      'sym
   1.913 +      :kw
   1.914 +      () '(1 2)
   1.915 +      [] [1 2]
   1.916 +      {} {:a 1 :b 2}
   1.917 +      #{} #{1 2} ))
   1.918 +
   1.919 +
   1.920 +(deftest test-range
   1.921 +  (are [x y] (= x y)
   1.922 +      (range 0) ()   ; exclusive end!
   1.923 +      (range 1) '(0)
   1.924 +      (range 5) '(0 1 2 3 4)
   1.925 +
   1.926 +      (range -1) ()
   1.927 +      (range -3) ()
   1.928 +
   1.929 +      (range 2.5) '(0 1 2)
   1.930 +      (range 7/3) '(0 1 2)
   1.931 +
   1.932 +      (range 0 3) '(0 1 2)
   1.933 +      (range 0 1) '(0)
   1.934 +      (range 0 0) ()
   1.935 +      (range 0 -3) ()
   1.936 +
   1.937 +      (range 3 6) '(3 4 5)
   1.938 +      (range 3 4) '(3)
   1.939 +      (range 3 3) ()
   1.940 +      (range 3 1) ()
   1.941 +      (range 3 0) ()
   1.942 +      (range 3 -2) ()
   1.943 +
   1.944 +      (range -2 5) '(-2 -1 0 1 2 3 4)
   1.945 +      (range -2 0) '(-2 -1)
   1.946 +      (range -2 -1) '(-2)
   1.947 +      (range -2 -2) ()
   1.948 +      (range -2 -5) ()
   1.949 +
   1.950 +      (range 3 9 0) ()
   1.951 +      (range 3 9 1) '(3 4 5 6 7 8)
   1.952 +      (range 3 9 2) '(3 5 7)
   1.953 +      (range 3 9 3) '(3 6)
   1.954 +      (range 3 9 10) '(3)
   1.955 +      (range 3 9 -1) () ))
   1.956 +
   1.957 +
   1.958 +(deftest test-empty?
   1.959 +  (are [x] (empty? x)
   1.960 +    nil
   1.961 +    ()
   1.962 +    (lazy-seq nil)    ; => ()
   1.963 +    []
   1.964 +    {}
   1.965 +    #{}
   1.966 +    ""
   1.967 +    (into-array []) )
   1.968 +
   1.969 +  (are [x] (not (empty? x))
   1.970 +    '(1 2)
   1.971 +    (lazy-seq [1 2])
   1.972 +    [1 2]
   1.973 +    {:a 1 :b 2}
   1.974 +    #{1 2}
   1.975 +    "abc"
   1.976 +    (into-array [1 2]) ))
   1.977 +
   1.978 +
   1.979 +(deftest test-every?
   1.980 +  ; always true for nil or empty coll/seq
   1.981 +  (are [x] (= (every? pos? x) true)
   1.982 +      nil
   1.983 +      () [] {} #{}
   1.984 +      (lazy-seq [])
   1.985 +      (into-array []) )
   1.986 +
   1.987 +  (are [x y] (= x y)
   1.988 +      true (every? pos? [1])
   1.989 +      true (every? pos? [1 2])
   1.990 +      true (every? pos? [1 2 3 4 5])
   1.991 +
   1.992 +      false (every? pos? [-1])
   1.993 +      false (every? pos? [-1 -2])
   1.994 +      false (every? pos? [-1 -2 3])
   1.995 +      false (every? pos? [-1 2])
   1.996 +      false (every? pos? [1 -2])
   1.997 +      false (every? pos? [1 2 -3])
   1.998 +      false (every? pos? [1 2 -3 4]) )
   1.999 +
  1.1000 +  (are [x y] (= x y)
  1.1001 +      true (every? #{:a} [:a :a])
  1.1002 +;!      false (every? #{:a} [:a :b])   ; Issue 68: every? returns nil instead of false
  1.1003 +;!      false (every? #{:a} [:b :b])   ; http://code.google.com/p/clojure/issues/detail?id=68
  1.1004 +  ))
  1.1005 +
  1.1006 +
  1.1007 +(deftest test-not-every?
  1.1008 +  ; always false for nil or empty coll/seq
  1.1009 +  (are [x] (= (not-every? pos? x) false)
  1.1010 +      nil
  1.1011 +      () [] {} #{}
  1.1012 +      (lazy-seq [])
  1.1013 +      (into-array []) )
  1.1014 +
  1.1015 +  (are [x y] (= x y)
  1.1016 +      false (not-every? pos? [1])
  1.1017 +      false (not-every? pos? [1 2])
  1.1018 +      false (not-every? pos? [1 2 3 4 5])
  1.1019 +
  1.1020 +      true (not-every? pos? [-1])
  1.1021 +      true (not-every? pos? [-1 -2])
  1.1022 +      true (not-every? pos? [-1 -2 3])
  1.1023 +      true (not-every? pos? [-1 2])
  1.1024 +      true (not-every? pos? [1 -2])
  1.1025 +      true (not-every? pos? [1 2 -3])
  1.1026 +      true (not-every? pos? [1 2 -3 4]) )
  1.1027 +
  1.1028 +  (are [x y] (= x y)
  1.1029 +      false (not-every? #{:a} [:a :a])
  1.1030 +      true (not-every? #{:a} [:a :b])
  1.1031 +      true (not-every? #{:a} [:b :b]) ))
  1.1032 +
  1.1033 +
  1.1034 +(deftest test-not-any?
  1.1035 +  ; always true for nil or empty coll/seq
  1.1036 +  (are [x] (= (not-any? pos? x) true)
  1.1037 +      nil
  1.1038 +      () [] {} #{}
  1.1039 +      (lazy-seq [])
  1.1040 +      (into-array []) )
  1.1041 +
  1.1042 +  (are [x y] (= x y)
  1.1043 +      false (not-any? pos? [1])
  1.1044 +      false (not-any? pos? [1 2])
  1.1045 +      false (not-any? pos? [1 2 3 4 5])
  1.1046 +
  1.1047 +      true (not-any? pos? [-1])
  1.1048 +      true (not-any? pos? [-1 -2])
  1.1049 +
  1.1050 +      false (not-any? pos? [-1 -2 3])
  1.1051 +      false (not-any? pos? [-1 2])
  1.1052 +      false (not-any? pos? [1 -2])
  1.1053 +      false (not-any? pos? [1 2 -3])
  1.1054 +      false (not-any? pos? [1 2 -3 4]) )
  1.1055 +
  1.1056 +  (are [x y] (= x y)
  1.1057 +      false (not-any? #{:a} [:a :a])
  1.1058 +      false (not-any? #{:a} [:a :b])
  1.1059 +      true (not-any? #{:a} [:b :b]) ))
  1.1060 +
  1.1061 +
  1.1062 +(deftest test-some
  1.1063 +  ;; always nil for nil or empty coll/seq
  1.1064 +  (are [x] (= (some pos? x) nil)
  1.1065 +       nil
  1.1066 +       () [] {} #{}
  1.1067 +       (lazy-seq [])
  1.1068 +       (into-array []))
  1.1069 +  
  1.1070 +  (are [x y] (= x y)
  1.1071 +       nil (some nil nil)
  1.1072 +       
  1.1073 +       true (some pos? [1])
  1.1074 +       true (some pos? [1 2])
  1.1075 +       
  1.1076 +       nil (some pos? [-1])
  1.1077 +       nil (some pos? [-1 -2])
  1.1078 +       true (some pos? [-1 2])
  1.1079 +       true (some pos? [1 -2])
  1.1080 +       
  1.1081 +       :a (some #{:a} [:a :a])
  1.1082 +       :a (some #{:a} [:b :a])
  1.1083 +       nil (some #{:a} [:b :b])
  1.1084 +       
  1.1085 +       :a (some #{:a} '(:a :b))
  1.1086 +       :a (some #{:a} #{:a :b})
  1.1087 +       ))
  1.1088 +
  1.1089 +(deftest test-flatten-present
  1.1090 +  (are [expected nested-val] (= (flatten nested-val) expected)
  1.1091 +       ;simple literals
  1.1092 +       [] nil
  1.1093 +       [] 1
  1.1094 +       [] 'test
  1.1095 +       [] :keyword
  1.1096 +       [] 1/2
  1.1097 +       [] #"[\r\n]"
  1.1098 +       [] true
  1.1099 +       [] false
  1.1100 +       ;vectors
  1.1101 +       [1 2 3 4 5] [[1 2] [3 4 [5]]]
  1.1102 +       [1 2 3 4 5] [1 2 3 4 5]
  1.1103 +       [#{1 2} 3 4 5] [#{1 2} 3 4 5]
  1.1104 +       ;sets
  1.1105 +       [] #{}
  1.1106 +       [] #{#{1 2} 3 4 5}
  1.1107 +       [] #{1 2 3 4 5}
  1.1108 +       [] #{#{1 2} 3 4 5}
  1.1109 +       ;lists
  1.1110 +       [] '()
  1.1111 +       [1 2 3 4 5] `(1 2 3 4 5)
  1.1112 +       ;maps
  1.1113 +       [] {:a 1 :b 2}
  1.1114 +       [:a 1 :b 2] (seq {:a 1 :b 2})
  1.1115 +       [] {[:a :b] 1 :c 2}
  1.1116 +       [:a :b 1 :c 2] (seq {[:a :b] 1 :c 2})
  1.1117 +       [:a 1 2 :b 3] (seq {:a [1 2] :b 3})
  1.1118 +       ;Strings
  1.1119 +       [] "12345"
  1.1120 +       [\1 \2 \3 \4 \5] (seq "12345")
  1.1121 +       ;fns
  1.1122 +       [] count
  1.1123 +       [count even? odd?] [count even? odd?]))
  1.1124 +
  1.1125 +(deftest test-group-by
  1.1126 +  (is (= (group-by even? [1 2 3 4 5]) 
  1.1127 +	 {false [1 3 5], true [2 4]})))
  1.1128 +
  1.1129 +(deftest test-partition-by
  1.1130 +  (are [test-seq] (= (partition-by (comp even? count) test-seq)
  1.1131 +		     [["a"] ["bb" "cccc" "dd"] ["eee" "f"] ["" "hh"]])
  1.1132 +       ["a" "bb" "cccc" "dd" "eee" "f" "" "hh"]
  1.1133 +       '("a" "bb" "cccc" "dd" "eee" "f" "" "hh"))
  1.1134 +  (is (=(partition-by #{\a \e \i \o \u} "abcdefghijklm")
  1.1135 +       [[\a] [\b \c \d] [\e] [\f \g \h] [\i] [\j \k \l \m]])))
  1.1136 +
  1.1137 +(deftest test-frequencies
  1.1138 +  (are [expected test-seq] (= (frequencies test-seq) expected)
  1.1139 +       {\p 2, \s 4, \i 4, \m 1} "mississippi"
  1.1140 +       {1 4 2 2 3 1} [1 1 1 1 2 2 3]
  1.1141 +       {1 4 2 2 3 1} '(1 1 1 1 2 2 3)))
  1.1142 +
  1.1143 +(deftest test-reductions
  1.1144 +  (is (= (reductions + nil)
  1.1145 +         [0]))
  1.1146 +  (is (= (reductions + [1 2 3 4 5])
  1.1147 +	 [1 3 6 10 15]))
  1.1148 +  (is (= (reductions + 10 [1 2 3 4 5])
  1.1149 +	 [10 11 13 16 20 25])))
  1.1150 +
  1.1151 +(deftest test-rand-nth-invariants
  1.1152 +  (let [elt (rand-nth [:a :b :c :d])]
  1.1153 +    (is (#{:a :b :c :d} elt))))
  1.1154 +
  1.1155 +(deftest test-partition-all
  1.1156 +  (is (= (partition-all 4 [1 2 3 4 5 6 7 8 9])
  1.1157 +	 [[1 2 3 4] [5 6 7 8] [9]]))
  1.1158 +  (is (= (partition-all 4 2 [1 2 3 4 5 6 7 8 9])
  1.1159 +	 [[1 2 3 4] [3 4 5 6] [5 6 7 8] [7 8 9] [9]])))
  1.1160 +
  1.1161 +(deftest test-shuffle-invariants
  1.1162 +  (is (= (count (shuffle [1 2 3 4])) 4))
  1.1163 +  (let [shuffled-seq (shuffle [1 2 3 4])]
  1.1164 +    (is (every? #{1 2 3 4} shuffled-seq))))
  1.1165 +