ensure-finite-number.js 743 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. module.exports = function (t, a) {
  3. a.throws(
  4. function () {
  5. t(undefined);
  6. },
  7. TypeError,
  8. "Undefined"
  9. );
  10. a.throws(
  11. function () {
  12. t(null);
  13. },
  14. TypeError,
  15. "Null"
  16. );
  17. a(t(0), 0, "Zero");
  18. a.throws(
  19. function () {
  20. t(NaN);
  21. },
  22. TypeError,
  23. "NaN"
  24. );
  25. a.throws(
  26. function () {
  27. t(Infinity);
  28. },
  29. TypeError,
  30. "Infinity"
  31. );
  32. a(t(12), 12, "Number");
  33. a(t(false), 0, "Boolean");
  34. a(t(new Date(1000000)), 1000000, "Date");
  35. a(t(new Number(2)), 2, "Number object");
  36. a.throws(
  37. function () {
  38. t("asdfaf");
  39. },
  40. TypeError,
  41. "String"
  42. );
  43. a(t(""), 0, "Empty String");
  44. if (typeof Symbol === "function") {
  45. a.throws(
  46. function () {
  47. t(Symbol("test"));
  48. },
  49. TypeError,
  50. "Symbol"
  51. );
  52. }
  53. };