Skip to content

Commit 725547f

Browse files
tidy up and test #257, remove spurious .rej file
Signed-off-by: Stuart Halloway <[email protected]>
1 parent 2444242 commit 725547f

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

src/clj/clojure/core.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5675,6 +5675,7 @@
56755675
versions can replace arguments in the second and third
56765676
positions (y, z). Note that the function f can take any number of
56775677
arguments, not just the one(s) being nil-patched."
5678+
{:added "1.2"}
56785679
([f x]
56795680
(fn
56805681
([a] (f (if (nil? a) x a)))

src/clj/clojure/core_deftype.clj.rej

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/clojure/test_clojure/other_functions.clj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@
5151
"quux" "quux"))
5252

5353
(deftest test-fnil
54+
(let [f1 (fnil vector :a)
55+
f2 (fnil vector :a :b)
56+
f3 (fnil vector :a :b :c)]
57+
(are [result input] (= result [(apply f1 input) (apply f2 input) (apply f3 input)])
58+
[[1 2 3 4] [1 2 3 4] [1 2 3 4]] [1 2 3 4]
59+
[[:a 2 3 4] [:a 2 3 4] [:a 2 3 4]] [nil 2 3 4]
60+
[[:a nil 3 4] [:a :b 3 4] [:a :b 3 4]] [nil nil 3 4]
61+
[[:a nil nil 4] [:a :b nil 4] [:a :b :c 4]] [nil nil nil 4]
62+
[[:a nil nil nil] [:a :b nil nil] [:a :b :c nil]] [nil nil nil nil]))
5463
(are [x y] (= x y)
5564
((fnil + 0) nil 42) 42
5665
((fnil conj []) nil 42) [42]

0 commit comments

Comments
 (0)