ensure-natural-number-value.js 472 B

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