comparison src/clojure/contrib/test_contrib/test_core.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
comparison
equal deleted inserted replaced
9:35cf337adfcf 10:ef7dbbd6452c
1 ; Copyright (c) Laurent Petit, March 2009. All rights reserved.
2
3 ; The use and distribution terms for this software are covered by the
4 ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5 ; which can be found in the file epl-v10.html at the root of this
6 ; distribution.
7 ; By using this software in any fashion, you are agreeing to be bound by
8 ; the terms of this license.
9 ; You must not remove this notice, or any other, from this software.
10
11 ;; test namespace for clojure.contrib.core
12
13 ;; note to other contrib members: feel free to add to this lib
14
15 (ns clojure.contrib.test-core
16 (:use clojure.test)
17 (:use clojure.contrib.core))
18
19 (deftest test-classic-versions
20 (testing "Classic -> throws NPE if passed nil"
21 (is (thrown? NullPointerException (-> nil .toString)))
22 (is (thrown? NullPointerException (-> "foo" seq next next next .toString))))
23 (testing "Classic .. throws NPE if one of the intermediate threaded values is nil"
24 (is (thrown? NullPointerException (.. nil toString)))
25 (is (thrown? NullPointerException (.. [nil] (get 0) toString)))))
26
27 (deftest test-new-versions
28 (testing "Version -?>> falls out on nil"
29 (is (nil? (-?>> nil .toString)))
30 (is (nil? (-?>> [] seq (map inc))))
31 (is (= [] (->> [] seq (map inc)))))
32 (testing "Version -?>> completes for non-nil"
33 (is (= [3 4] (-?>> [1 2] (map inc) (map inc)))))
34 (testing "Version -?> falls out on nil"
35 (is (nil? (-?> nil .toString)))
36 (is (nil? (-?> "foo" seq next next next .toString))))
37 (testing "Version -?> completes for non-nil"
38 (is (= [\O \O] (-?> "foo" .toUpperCase rest))))
39 (testing "Version .?. returns nil if one of the intermediate threaded values is nil"
40 (is (nil? (.?. nil toString)))
41 (is (nil? (.?. [nil] (get 0) toString)))))
42