validate-array-like-object.js 589 B

1234567891011121314151617181920212223242526272829
  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.throws(function () {
  11. t("");
  12. }, TypeError, "String");
  13. a.throws(function () {
  14. t({});
  15. }, TypeError, "Plain Object");
  16. a.throws(function () {
  17. t(function () {});
  18. }, TypeError, "Function");
  19. a(t(x = new String("raz")), x, "String object"); // Jslint: ignore
  20. a(t(x = { length: 1 }), x, "Array like");
  21. a.throws(function () {
  22. t();
  23. }, TypeError, "Undefined");
  24. a.throws(function () {
  25. t(null);
  26. }, TypeError, "null");
  27. };