File tree Expand file tree Collapse file tree 3 files changed +10
-21
lines changed 
test/clojure/test_clojure Expand file tree Collapse file tree 3 files changed +10
-21
lines changed Original file line number Diff line number Diff line change 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)))
  Load Diff This file was deleted. 
Original file line number Diff line number Diff line change 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 ]
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments