Math.pow.js 949 B

12345678910111213141516171819202122232425
  1. test("basic functionality", () => {
  2. expect(Math.pow).toHaveLength(2);
  3. expect(Math.pow(2, 0)).toBe(1);
  4. expect(Math.pow(2, 1)).toBe(2);
  5. expect(Math.pow(2, 2)).toBe(4);
  6. expect(Math.pow(2, 3)).toBe(8);
  7. expect(Math.pow(2, -3)).toBe(0.125);
  8. expect(Math.pow(3, 2)).toBe(9);
  9. expect(Math.pow(0, 0)).toBe(1);
  10. expect(Math.pow(2, Math.pow(3, 2))).toBe(512);
  11. expect(Math.pow(Math.pow(2, 3), 2)).toBe(64);
  12. expect(Math.pow("2", "3")).toBe(8);
  13. expect(Math.pow("", [])).toBe(1);
  14. expect(Math.pow([], null)).toBe(1);
  15. expect(Math.pow(null, null)).toBe(1);
  16. expect(Math.pow(undefined, null)).toBe(1);
  17. expect(Math.pow(NaN, 2)).toBeNaN();
  18. expect(Math.pow(2, NaN)).toBeNaN();
  19. expect(Math.pow(undefined, 2)).toBeNaN();
  20. expect(Math.pow(2, undefined)).toBeNaN();
  21. expect(Math.pow(null, undefined)).toBeNaN();
  22. expect(Math.pow(2, "foo")).toBeNaN();
  23. expect(Math.pow("foo", 2)).toBeNaN();
  24. });