Skip to content

Commit

Permalink
tidy up and test #257, remove spurious .rej file
Browse files Browse the repository at this point in the history
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information
stuarthalloway committed Jun 7, 2010
1 parent 2444242 commit 725547f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/clj/clojure/core.clj
Expand Up @@ -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)))
Expand Down
21 changes: 0 additions & 21 deletions src/clj/clojure/core_deftype.clj.rej

This file was deleted.

9 changes: 9 additions & 0 deletions test/clojure/test_clojure/other_functions.clj
Expand Up @@ -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]
Expand Down

0 comments on commit 725547f

Please sign in to comment.