ensure-array.js 736 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. module.exports = function (t, a) {
  3. var arr = [];
  4. a(t(arr), arr, "Array");
  5. a(t(""), "", "String");
  6. var args = (function () {
  7. return arguments;
  8. }());
  9. a(t(args), args, "Arguments");
  10. var arrayLike = { length: 0 };
  11. a(t(arrayLike), arrayLike, "Array like");
  12. a.throws(
  13. function () {
  14. t(function () {});
  15. },
  16. TypeError,
  17. "Function"
  18. );
  19. a.throws(
  20. function () {
  21. t({});
  22. },
  23. TypeError,
  24. "Plain object"
  25. );
  26. a.throws(
  27. function () {
  28. t(/raz/);
  29. },
  30. TypeError,
  31. "Regexp"
  32. );
  33. a.throws(
  34. function () {
  35. t();
  36. },
  37. TypeError,
  38. "No argument"
  39. );
  40. a.throws(
  41. function () {
  42. t(null);
  43. },
  44. TypeError,
  45. "Null"
  46. );
  47. a.throws(
  48. function () {
  49. t(undefined);
  50. },
  51. TypeError,
  52. "Undefined"
  53. );
  54. };