validate-object.js 725 B

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