validate-array-like.js 553 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. module.exports = function (t, a) {
  3. var x;
  4. a.throws(function () {
  5. t(0);
  6. }, TypeError, "0");
  7. a.throws(function () {
  8. t(false);
  9. }, TypeError, "false");
  10. a(t(""), "", "''");
  11. a.throws(function () {
  12. t({});
  13. }, TypeError, "Plain Object");
  14. a.throws(function () {
  15. t(function () {});
  16. }, TypeError, "Function");
  17. a(t(x = new String("raz")), x, "String object"); // Jslint: ignore
  18. a(t(x = { length: 1 }), x, "Array like");
  19. a.throws(function () {
  20. t();
  21. }, TypeError, "Undefined");
  22. a.throws(function () {
  23. t(null);
  24. }, TypeError, "null");
  25. };