Math.pow.js 925 B

1234567891011121314151617181920212223242526272829
  1. load("test-common.js");
  2. try {
  3. assert(Math.pow(2, 0) === 1);
  4. assert(Math.pow(2, 1) === 2);
  5. assert(Math.pow(2, 2) === 4);
  6. assert(Math.pow(2, 3) === 8);
  7. assert(Math.pow(2, -3) === 0.125);
  8. assert(Math.pow(3, 2) === 9);
  9. assert(Math.pow(0, 0) === 1);
  10. assert(Math.pow(2, Math.pow(3, 2)) === 512);
  11. assert(Math.pow(Math.pow(2, 3), 2) === 64);
  12. assert(Math.pow("2", "3") === 8);
  13. assert(Math.pow("", []) === 1);
  14. assert(Math.pow([], null) === 1);
  15. assert(Math.pow(null, null) === 1);
  16. assert(Math.pow(undefined, null) === 1);
  17. assert(isNaN(Math.pow(NaN, 2)));
  18. assert(isNaN(Math.pow(2, NaN)));
  19. assert(isNaN(Math.pow(undefined, 2)));
  20. assert(isNaN(Math.pow(2, undefined)));
  21. assert(isNaN(Math.pow(null, undefined)));
  22. assert(isNaN(Math.pow(2, "foo")));
  23. assert(isNaN(Math.pow("foo", 2)));
  24. console.log("PASS");
  25. } catch (e) {
  26. console.log("FAIL: " + e);
  27. }