TheOdinProject / javascript-exercises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

helloShen opened this issue · comments

commented

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

Closing due to inactivity, and adding such additional tests may be straying too much into the maths side of things rather than writing tests.