Re: org.junit.Assert/assertArrayEquals massive confusion!

2013-05-28 Thread Cedric Greevey
YW. Though, you might want to refine it a bit to support BigDecimal and avoid reflection. (defn abs [x] (cond (instance? BigDecimal x) (let [^BigDecimal x x] (.abs x)) (instance? Double x) (let [^Double x x] (Math/abs x)) (instance? Float x) (let [^Float x x]

Re: org.junit.Assert/assertArrayEquals massive confusion!

2013-05-28 Thread Jim - FooBar();
aww cool! thanks Cedric :) On 28/05/13 18:02, Cedric Greevey wrote: (defn acmp [a1 a2 tolerance] (every? #(< % tolerance) (map #(Math/abs (- %1 %2)) (seq a1) (seq a2 user=> (acmp (double-array [0.01 0.7 2.2]) (double-array [0.011 0.695 2.199]) 0.01) true use

Re: org.junit.Assert/assertArrayEquals massive confusion!

2013-05-28 Thread Cedric Greevey
(defn acmp [a1 a2 tolerance] (every? #(< % tolerance) (map #(Math/abs (- %1 %2)) (seq a1) (seq a2 user=> (acmp (double-array [0.01 0.7 2.2]) (double-array [0.011 0.695 2.199]) 0.01) true user=> (acmp (double-array [0.01 0.7 2.2]) (double-array [0.01

Re: org.junit.Assert/assertArrayEquals massive confusion!

2013-05-28 Thread Jim - FooBar();
ooo thanks Chris! I was suspecting the exact same thing because I tried this: (is (= (seq (aget ready 0)) (seq (aget ready 1 and got this: expected: (= (seq (aget ready 0)) (seq (aget ready 1))) actual: (not (= (-0.5345224838248488 0.2672612419124244 0.801783725737273*1*)

Re: org.junit.Assert/assertArrayEquals massive confusion!

2013-05-28 Thread Chris Jeris
It doesn't seem to be in the published javadoc, but this is an array comparison with an epsilon tolerance, which was likely added after the published javadoc was generated. 0.01 here is the maximum permitted absolute difference between each compared number. https://github.com/junit-team/junit/blo

org.junit.Assert/assertArrayEquals massive confusion!

2013-05-28 Thread Jim - FooBar();
Hi everyone, sometimes I feel really stupid! I am currently looking at a well-known java library's tests and found this: Assert.assertArrayEquals(arrayOutput[0], arrayOutput[1], 0.01); //arrayOutput is a 2d double-array btw since I've basically wrapped this lib, I'd like to port the java tes