javascript-exercises icon indicating copy to clipboard operation
javascript-exercises copied to clipboard

Unit test for 08_calculator power() function is too weak.

Open helloShen opened this issue 4 years ago • 0 comments

Only one test case for power() function is not enough,

expect(calculator.power(4,3)).toBe(64); 

I add more unit tests:

  1. tests with negative base.
  2. tests for the negative exponent.
  3. if exponent equals 0, result should always be 1. 3.1. except for a base of 0, which should return 0.
  4. if base equals 0, 4.1. return Infinity if exponent is negative. 4.2. otherwise, always return 0.

Here is my pull request: #223 08_calculator: add some unit test. And to keep solutions up to date, watch this pull request: #226 Keep calculator solution up to date

helloShen avatar Feb 07 '22 21:02 helloShen