Closed mattfowler closed 11 years ago
Added several functions for complex numbers:
Also added to basic a method that will compare two floats given an epsilon. I used this in one test where this comparison was being done manually.
The complex number equals method can also be used to clean up some of the complex tests, for instance:
var res = A.subtract(B); assert.equal(2, res.re); assert.equal(4, res.im);
can become:
var res = A.subtract(B); var expected = new Complex(2, 4); assert.equal(true, expected.equals(res));
Which I'm not sure if you want to do everywhere, comparing the real and imaginary directly will give you a better error message.
It is probably a good idea to extend the assert library to have the following methods in the near future:
assert.equal(number, number, epsilon) assert.complexEqual(complex, complex, epsilon)
The implementations would contain separate asserts, so you would get better failure messages.
Added several functions for complex numbers:
Also added to basic a method that will compare two floats given an epsilon. I used this in one test where this comparison was being done manually.
The complex number equals method can also be used to clean up some of the complex tests, for instance:
can become:
Which I'm not sure if you want to do everywhere, comparing the real and imaginary directly will give you a better error message.
It is probably a good idea to extend the assert library to have the following methods in the near future:
assert.equal(number, number, epsilon) assert.complexEqual(complex, complex, epsilon)
The implementations would contain separate asserts, so you would get better failure messages.