ensure-natural-number.js 439 B

12345678910111213141516171819202122
  1. "use strict";
  2. module.exports = function (t, a) {
  3. a.throws(function () {
  4. t(undefined);
  5. }, TypeError, "Undefined");
  6. a(t(null), 0, "Null");
  7. a(t(2), 2, "Number");
  8. a.throws(function () {
  9. t(-2);
  10. }, TypeError, "Negative");
  11. a.throws(function () {
  12. t(2.34);
  13. }, TypeError, "Float");
  14. a(t("23"), 23, "Numeric string");
  15. a.throws(function () {
  16. t(NaN);
  17. }, TypeError, "NaN");
  18. a.throws(function () {
  19. t(Infinity);
  20. }, TypeError, "Infinity");
  21. };