ensure-finite-number.js 653 B

123456789101112131415161718
  1. "use strict";
  2. module.exports = function (t, a) {
  3. a.throws(function () { t(undefined); }, TypeError, "Undefined");
  4. a.throws(function () { t(null); }, TypeError, "Null");
  5. a(t(0), 0, "Zero");
  6. a.throws(function () { t(NaN); }, TypeError, "NaN");
  7. a.throws(function () { t(Infinity); }, TypeError, "Infinity");
  8. a(t(12), 12, "Number");
  9. a(t(false), 0, "Boolean");
  10. a(t(new Date(1000000)), 1000000, "Date");
  11. a(t(new Number(2)), 2, "Number object");
  12. a.throws(function () { t("asdfaf"); }, TypeError, "String");
  13. a(t(""), 0, "Empty String");
  14. if (typeof Symbol === "function") {
  15. a.throws(function () { t(Symbol("test")); }, TypeError, "Symbol");
  16. }
  17. };