validate.js 678 B

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