Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tidy up and test #257, remove spurious .rej file

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
commit 725547f4587f75c063c51659e582cfdbcc140f80 1 parent 2444242
@stuarthalloway stuarthalloway authored
View
1  src/clj/clojure/core.clj
@@ -5675,6 +5675,7 @@
versions can replace arguments in the second and third
positions (y, z). Note that the function f can take any number of
arguments, not just the one(s) being nil-patched."
+ {:added "1.2"}
([f x]
(fn
([a] (f (if (nil? a) x a)))
View
21 src/clj/clojure/core_deftype.clj.rej
@@ -1,21 +0,0 @@
-diff a/src/clj/clojure/core_deftype.clj b/src/clj/clojure/core_deftype.clj (rejected hunks)
-@@ -10,13 +10,18 @@
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;; definterface ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-+(defn namespace-munge
-+ "Convert a Clojure namespace name to a legal Java package name."
-+ [ns]
-+ (.replace (str ns) \- \_))
-+
- ;for now, built on gen-interface
- (defmacro definterface
- [name & sigs]
- (let [tag (fn [x] (or (:tag (meta x)) Object))
- psig (fn [[name [& args]]]
- (vector name (vec (map tag args)) (tag name)))
-- cname (symbol (str *ns* "." name))]
-+ cname (symbol (str (namespace-munge *ns*) "." name))]
- `(do (gen-interface :name ~cname :methods ~(vec (map psig sigs)))
- (import ~cname))))
-
View
9 test/clojure/test_clojure/other_functions.clj
@@ -51,6 +51,15 @@
"quux" "quux"))
(deftest test-fnil
+ (let [f1 (fnil vector :a)
+ f2 (fnil vector :a :b)
+ f3 (fnil vector :a :b :c)]
+ (are [result input] (= result [(apply f1 input) (apply f2 input) (apply f3 input)])
+ [[1 2 3 4] [1 2 3 4] [1 2 3 4]] [1 2 3 4]
+ [[:a 2 3 4] [:a 2 3 4] [:a 2 3 4]] [nil 2 3 4]
+ [[:a nil 3 4] [:a :b 3 4] [:a :b 3 4]] [nil nil 3 4]
+ [[:a nil nil 4] [:a :b nil 4] [:a :b :c 4]] [nil nil nil 4]
+ [[:a nil nil nil] [:a :b nil nil] [:a :b :c nil]] [nil nil nil nil]))
(are [x y] (= x y)
((fnil + 0) nil 42) 42
((fnil conj []) nil 42) [42]
Please sign in to comment.
Something went wrong with that request. Please try again.