get.js 698 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. var iteratorSymbol = require("es6-symbol").iterator
  3. , Iterator = require("../");
  4. module.exports = function (t, a) {
  5. var iterator;
  6. a.throws(function () {
  7. t();
  8. }, TypeError, "Null");
  9. a.throws(function () {
  10. t({});
  11. }, TypeError, "Plain object");
  12. a.throws(function () {
  13. t({ length: 0 });
  14. }, TypeError, "Array-like");
  15. iterator = {};
  16. iterator[iteratorSymbol] = function () {
  17. return new Iterator([]);
  18. };
  19. a(t(iterator) instanceof Iterator, true, "Iterator");
  20. a(String(t([])), "[object Array Iterator]", " Array");
  21. a(String(t(function () {
  22. return arguments;
  23. }())), "[object Array Iterator]", " Arguments");
  24. a(String(t("foo")), "[object String Iterator]", "String");
  25. };